share: rename share-safe warning config
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 15 Jan 2021 12:08:07 +0530
changeset 46333 2eb5fe13461b
parent 46332 cc3452d2dfa4
child 46334 4b0192f592cf
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
mercurial/configitems.py
mercurial/helptext/config.txt
mercurial/localrepo.py
mercurial/upgrade.py
tests/test-share-safe.t
--- a/mercurial/configitems.py	Mon Jan 18 21:37:20 2021 +0530
+++ b/mercurial/configitems.py	Fri Jan 15 12:08:07 2021 +0530
@@ -1098,11 +1098,6 @@
 )
 coreconfigitem(
     b'experimental',
-    b'sharesafe-warn-outdated-shares',
-    default=True,
-)
-coreconfigitem(
-    b'experimental',
     b'single-head-per-branch',
     default=False,
 )
@@ -1921,6 +1916,16 @@
     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,
--- a/mercurial/helptext/config.txt	Mon Jan 18 21:37:20 2021 +0530
+++ b/mercurial/helptext/config.txt	Fri Jan 15 12:08:07 2021 +0530
@@ -1965,6 +1965,16 @@
                            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``
 -----------
 
--- a/mercurial/localrepo.py	Mon Jan 18 21:37:20 2021 +0530
+++ b/mercurial/localrepo.py	Fri Jan 15 12:08:07 2021 +0530
@@ -575,6 +575,9 @@
             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 @@
                     sharedvfs,
                     requirements,
                     mismatch_config,
+                    mismatch_warn,
                 )
             elif mismatch_config == b'abort':
                 raise error.Abort(
@@ -618,6 +622,9 @@
         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 @@
                     storevfs,
                     requirements,
                     mismatch_config,
+                    mismatch_warn,
                 )
             elif mismatch_config == b'abort':
                 raise error.Abort(
--- a/mercurial/upgrade.py	Mon Jan 18 21:37:20 2021 +0530
+++ b/mercurial/upgrade.py	Fri Jan 15 12:08:07 2021 +0530
@@ -242,7 +242,12 @@
 
 
 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 @@
                 _(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 @@
     sharedvfs,
     current_requirements,
     mismatch_config,
+    mismatch_warn,
 ):
     """Downgrades a share which use share-safe to not use it"""
     wlock = None
@@ -335,6 +341,11 @@
                 _(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()
--- a/tests/test-share-safe.t	Mon Jan 18 21:37:20 2021 +0530
+++ b/tests/test-share-safe.t	Fri Jan 15 12:08:07 2021 +0530
@@ -546,7 +546,7 @@
   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