# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2021-01-15 06:38:07 # Node ID 2eb5fe13461b81dc20468885deeb7cbe44240eea # Parent cc3452d2dfa49c603055804f6fb80cd45ef25b1d share: rename share-safe warning config Config introduced in previous patch was `share.source-safe-mismatch`. Let's rename the warn as `share.source-safe-mismatch.warn`. While we are here, made sure we have different configs for upgrade and downgrade. Differential Revision: https://phab.mercurial-scm.org/D9786 diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -1098,11 +1098,6 @@ coreconfigitem( ) coreconfigitem( b'experimental', - b'sharesafe-warn-outdated-shares', - default=True, -) -coreconfigitem( - b'experimental', b'single-head-per-branch', default=False, ) @@ -1921,6 +1916,16 @@ coreconfigitem( default=b'abort', ) coreconfigitem( + b'share', + b'safe-mismatch.source-not-safe.warn', + default=True, +) +coreconfigitem( + b'share', + b'safe-mismatch.source-safe.warn', + default=True, +) +coreconfigitem( b'shelve', b'maxbackups', default=10, diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt --- a/mercurial/helptext/config.txt +++ b/mercurial/helptext/config.txt @@ -1965,6 +1965,16 @@ Alias definitions for revsets. See :hg:` source setting +``safe-mismatch.source-safe.warn`` + Shows a warning on operations if the shared repository does not use + share-safe, but the source repository does. + (default: True) + +``safe-mismatch.source-not-safe.warn`` + Shows a warning on operations if the shared repository uses share-safe, + but the source repository does not. + (default: True) + ``storage`` ----------- diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -575,6 +575,9 @@ def makelocalrepository(baseui, path, in and requirementsmod.SHARESAFE_REQUIREMENT not in _readrequires(sharedvfs, True) ): + mismatch_warn = ui.configbool( + b'share', b'safe-mismatch.source-not-safe.warn' + ) mismatch_config = ui.config( b'share', b'safe-mismatch.source-not-safe' ) @@ -592,6 +595,7 @@ def makelocalrepository(baseui, path, in sharedvfs, requirements, mismatch_config, + mismatch_warn, ) elif mismatch_config == b'abort': raise error.Abort( @@ -618,6 +622,9 @@ def makelocalrepository(baseui, path, in sourcerequires = _readrequires(sharedvfs, False) if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires: mismatch_config = ui.config(b'share', b'safe-mismatch.source-safe') + mismatch_warn = ui.configbool( + b'share', b'safe-mismatch.source-safe.warn' + ) if mismatch_config in ( b'upgrade-allow', b'allow', @@ -632,6 +639,7 @@ def makelocalrepository(baseui, path, in storevfs, requirements, mismatch_config, + mismatch_warn, ) elif mismatch_config == b'abort': raise error.Abort( diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py --- a/mercurial/upgrade.py +++ b/mercurial/upgrade.py @@ -242,7 +242,12 @@ def upgraderepo( def upgrade_share_to_safe( - ui, hgvfs, storevfs, current_requirements, mismatch_config + ui, + hgvfs, + storevfs, + current_requirements, + mismatch_config, + mismatch_warn, ): """Upgrades a share to use share-safe mechanism""" wlock = None @@ -282,7 +287,7 @@ def upgrade_share_to_safe( _(b'failed to upgrade share, got error: %s') % stringutil.forcebytestr(e.strerror) ) - elif ui.configbool(b'experimental', b'sharesafe-warn-outdated-shares'): + elif mismatch_warn: ui.warn( _(b'failed to upgrade share, got error: %s\n') % stringutil.forcebytestr(e.strerror) @@ -298,6 +303,7 @@ def downgrade_share_to_non_safe( sharedvfs, current_requirements, mismatch_config, + mismatch_warn, ): """Downgrades a share which use share-safe to not use it""" wlock = None @@ -335,6 +341,11 @@ def downgrade_share_to_non_safe( _(b'failed to downgrade share, got error: %s') % stringutil.forcebytestr(e.strerror) ) + elif mismatch_warn: + ui.warn( + _(b'failed to downgrade share, got error: %s\n') + % stringutil.forcebytestr(e.strerror) + ) finally: if wlock: wlock.release() 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 @@ -546,7 +546,7 @@ Check that if lock is taken, upgrade fai o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo - $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-allow --config experimental.sharesafe-warn-outdated-shares=false + $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-allow --config share.safe-mismatch.source-safe.warn=False @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo