changeset 46238:9796cf108e4e

sharesafe: make warning about outdated share configurable If the source repository upgrades to use sharesafe mode, we show a warning in shares. This patch makes that warning configurable and some might not want their users see this warning. Differential Revision: https://phab.mercurial-scm.org/D9691
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 08 Jan 2021 21:34:16 +0530
parents bc884e31b8c8
children d159d0fafa78
files mercurial/configitems.py mercurial/localrepo.py mercurial/upgrade.py tests/test-share-safe.t
diffstat 4 files changed, 26 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/configitems.py	Fri Jan 08 18:07:33 2021 +0530
+++ b/mercurial/configitems.py	Fri Jan 08 21:34:16 2021 +0530
@@ -1084,6 +1084,11 @@
 )
 coreconfigitem(
     b'experimental',
+    b'sharesafe-warn-outdated-shares',
+    default=True,
+)
+coreconfigitem(
+    b'experimental',
     b'single-head-per-branch',
     default=False,
 )
--- a/mercurial/localrepo.py	Fri Jan 08 18:07:33 2021 +0530
+++ b/mercurial/localrepo.py	Fri Jan 08 21:34:16 2021 +0530
@@ -607,7 +607,9 @@
                     storevfs,
                     requirements,
                 )
-            else:
+            elif ui.configbool(
+                b'experimental', b'sharesafe-warn-outdated-shares'
+            ):
                 ui.warn(
                     _(
                         b'warning: source repository supports share-safe functionality.'
--- a/mercurial/upgrade.py	Fri Jan 08 18:07:33 2021 +0530
+++ b/mercurial/upgrade.py	Fri Jan 08 21:34:16 2021 +0530
@@ -257,10 +257,11 @@
         current_requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
         ui.warn(_(b'repository upgraded to use share-safe mode\n'))
     except error.LockError as e:
-        ui.warn(
-            _(b'failed to upgrade share, got error: %s\n')
-            % stringutil.forcebytestr(e.strerror)
-        )
+        if ui.configbool(b'experimental', b'sharesafe-warn-outdated-shares'):
+            ui.warn(
+                _(b'failed to upgrade share, got error: %s\n')
+                % stringutil.forcebytestr(e.strerror)
+            )
     finally:
         if wlock:
             wlock.release()
--- a/tests/test-share-safe.t	Fri Jan 08 18:07:33 2021 +0530
+++ b/tests/test-share-safe.t	Fri Jan 08 21:34:16 2021 +0530
@@ -392,6 +392,12 @@
 
 Make sure existing shares still works
 
+  $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config experimental.sharesafe-warn-outdated-shares=false
+  @  f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
+  |
+  o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
+  
+
   $ hg log -GT "{node}: {desc}\n" -R ../nss-share
   warning: source repository supports share-safe functionality. Reshare to upgrade.
   @  f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
@@ -544,6 +550,13 @@
   |
   o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
   
+
+  $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config experimental.sharesafe-auto-upgrade-shares=true --config experimental.sharesafe-warn-outdated-shares=false
+  @  f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
+  |
+  o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
+  
+
   $ rm ../nss-share/.hg/wlock
   $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config experimental.sharesafe-auto-upgrade-shares=true
   repository upgraded to use share-safe mode