diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -1906,7 +1906,12 @@ ) coreconfigitem( b'share', - b'source-safe-mismatch', + b'safe-mismatch.source-not-safe', + default=b'abort', +) +coreconfigitem( + b'share', + b'safe-mismatch.source-safe', default=b'abort', ) coreconfigitem( diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt --- a/mercurial/helptext/config.txt +++ b/mercurial/helptext/config.txt @@ -1941,17 +1941,35 @@ ``share`` --------- -``source-safe-mismatch`` - - Control what happens when there is a mismatch between share-safe feature - presence with share source in a share. +``safe-mismatch.source-safe`` + + Controls what happens when the shared repository does not uses share-safe + mechanism but it source repository does. + Possible values are `abort` (default), `allow`, `upgrade-abort` and `upgrade-abort`. - `abort`: Disallows running any command and aborts - `allow`: Respects the feature presence in share source - `upgrade-abort`: tries to upgrade the share, if it fails aborts - `upgrade-allow`: tries to upgrade the share, if it fails continue by - respecting the share source setting + `abort`: Disallows running any command and aborts + `allow`: Respects the feature presence in share source + `upgrade-abort`: tries to upgrade the share to use sharesafe + if it fails aborts + `upgrade-allow`: tries to upgrade the share, if it fails continue by + respecting the share source setting + +``safe-mismatch.source-not-safe`` + + Controls what happens when the shared repository uses share-safe mechanism + however it source does not. + + Possible values are `abort` (default), `allow`, `downgrade-abort` and + `downgrade-abort`. + `abort`: Disallows running any command and aborts + `allow`: Respects the feature presence in share source + `downgrade-abort`: tries to downgrade the share to not use share-safe + if it fails aborts + `downgrade-allow`: tries to downgrade the share to not use share safe + if it fails continue by respecting the shared + source setting + ``source-safe-mismatch.warn`` diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -568,7 +568,6 @@ # repository was shared the old way. We check the share source .hg/requires # for SHARESAFE_REQUIREMENT to detect whether the current repository needs # to be reshared - mismatch_config = ui.config(b'share', b'source-safe-mismatch') mismatch_warn = ui.configbool(b'share', b'source-safe-mismatch.warn') if requirementsmod.SHARESAFE_REQUIREMENT in requirements: @@ -577,10 +576,13 @@ and requirementsmod.SHARESAFE_REQUIREMENT not in _readrequires(sharedvfs, True) ): + mismatch_config = ui.config( + b'share', b'safe-mismatch.source-not-safe' + ) if mismatch_config in ( - b'upgrade-allow', + b'downgrade-allow', b'allow', - b'upgrade-abort', + b'downgrade-abort', ): # prevent cyclic import localrepo -> upgrade -> localrepo from . import upgrade @@ -600,11 +602,14 @@ ) ) else: - hint = _("run `hg help config.share.source-safe-mismatch`") + hint = _( + "run `hg help config.share.safe-mismatch.source-not-safe`" + ) raise error.Abort( _( b"share-safe mismatch with source.\nUnrecognized" - b" value '%s 'of `share.source-safe-mismatch` set." + b" value '%s 'of `share.safe-mismatch.source-not-safe`" + b" set." ) % mismatch_config, hint=hint, @@ -614,6 +619,7 @@ elif shared: sourcerequires = _readrequires(sharedvfs, False) if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires: + mismatch_config = ui.config(b'share', b'safe-mismatch.source-safe') if mismatch_config in ( b'upgrade-allow', b'allow', @@ -638,11 +644,11 @@ ) ) else: - hint = _("run `hg help config.share.source-safe-mismatch`") + hint = _("run `hg help config.share.safe-mismatch.source-safe`") raise error.Abort( _( b"share-safe mismatch with source.\nUnrecognized" - b" value '%s' of `share.source-safe-mismatch` set." + b" value '%s' of `share.safe-mismatch.source-safe` set." ) % mismatch_config, hint=hint, diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py --- a/mercurial/upgrade.py +++ b/mercurial/upgrade.py @@ -340,7 +340,7 @@ except error.LockError as e: # If upgrade-abort is set, abort when upgrade fails, else let the # process continue as `upgrade-allow` is set - if mismatch_config == b'upgrade-abort': + if mismatch_config == b'downgrade-abort': raise error.Abort( _(b'failed to downgrade share, got error: %s') % stringutil.forcebytestr(e.strerror) diff --git a/tests/test-share-safe.t b/tests/test-share-safe.t --- a/tests/test-share-safe.t +++ b/tests/test-share-safe.t @@ -486,12 +486,12 @@ Testing automatic downgrade of shares when config is set $ touch ../ss-share/.hg/wlock - $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config share.source-safe-mismatch=upgrade-abort + $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config share.safe-mismatch.source-not-safe=downgrade-abort abort: failed to downgrade share, got error: Lock held [255] $ rm ../ss-share/.hg/wlock - $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config share.source-safe-mismatch=upgrade-abort + $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config share.safe-mismatch.source-not-safe=downgrade-abort repository downgraded to not use share-safe mode @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | @@ -533,31 +533,31 @@ [255] Check that if lock is taken, upgrade fails but read operation are successful - $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.source-safe-mismatch=upgra + $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgra abort: share-safe mismatch with source. - Unrecognized value 'upgra' of `share.source-safe-mismatch` set. - (run `hg help config.share.source-safe-mismatch`) + Unrecognized value 'upgra' of `share.safe-mismatch.source-safe` set. + (run `hg help config.share.safe-mismatch.source-safe`) [255] $ touch ../nss-share/.hg/wlock - $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.source-safe-mismatch=upgrade-allow + $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-allow failed to upgrade share, got error: Lock held @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo - $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.source-safe-mismatch=upgrade-allow --config share.source-safe-mismatch.warn=False + $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-allow --config share.source-safe-mismatch.warn=False @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo - $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.source-safe-mismatch=upgrade-abort + $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-abort abort: failed to upgrade share, got error: Lock held [255] $ rm ../nss-share/.hg/wlock - $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.source-safe-mismatch=upgrade-abort + $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-abort repository upgraded to use share-safe mode @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar |