auto-upgrade: add an option to silence the share-safe message
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 14 Jun 2022 15:11:36 +0200
changeset 49339 9e203cda3238
parent 49338 4b239acb23a0
child 49340 1b9114709428
auto-upgrade: add an option to silence the share-safe message For well tested case, the message can get in the way, so we add a way to disable it.
mercurial/configitems.py
mercurial/helptext/config.txt
mercurial/upgrade_utils/auto_upgrade.py
tests/test-help.t
tests/test-upgrade-repo.t
--- a/mercurial/configitems.py	Tue Jun 14 15:45:37 2022 +0200
+++ b/mercurial/configitems.py	Tue Jun 14 15:11:36 2022 +0200
@@ -1409,6 +1409,12 @@
 )
 coreconfigitem(
     b'format',
+    b'use-share-safe.automatic-upgrade-of-mismatching-repositories:quiet',
+    default=False,
+    experimental=True,
+)
+coreconfigitem(
+    b'format',
     b'internal-phase',
     default=False,
     experimental=True,
--- a/mercurial/helptext/config.txt	Tue Jun 14 15:45:37 2022 +0200
+++ b/mercurial/helptext/config.txt	Tue Jun 14 15:11:36 2022 +0200
@@ -1098,6 +1098,9 @@
    `share-safe` requirement if `format.use-share-safe=no`. So we recommend
    setting both this value and `format.use-share-safe` at the same time.
 
+``use-share-safe.automatic-upgrade-of-mismatching-repositories:quiet``
+    Hide message when performing such automatic upgrade.
+
 ``usestore``
     Enable or disable the "store" repository format which improves
     compatibility with systems that fold case or otherwise mangle
--- a/mercurial/upgrade_utils/auto_upgrade.py	Tue Jun 14 15:45:37 2022 +0200
+++ b/mercurial/upgrade_utils/auto_upgrade.py	Tue Jun 14 15:11:36 2022 +0200
@@ -44,6 +44,10 @@
         b'format',
         b'use-share-safe.automatic-upgrade-of-mismatching-repositories',
     )
+    auto_upgrade_quiet = ui.configbool(
+        b'format',
+        b'use-share-safe.automatic-upgrade-of-mismatching-repositories:quiet',
+    )
 
     action = None
 
@@ -61,7 +65,7 @@
             hint = b"(see `hg help config.format.use-share-safe` for details)\n"
 
             def action():
-                if not ui.quiet:
+                if not (ui.quiet or auto_upgrade_quiet):
                     ui.write_err(msg)
                     ui.write_err(hint)
                 requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
@@ -75,7 +79,7 @@
             hint = b"(see `hg help config.format.use-share-safe` for details)\n"
 
             def action():
-                if not ui.quiet:
+                if not (ui.quiet or auto_upgrade_quiet):
                     ui.write_err(msg)
                     ui.write_err(hint)
                 requirements.discard(requirementsmod.SHARESAFE_REQUIREMENT)
--- a/tests/test-help.t	Tue Jun 14 15:45:37 2022 +0200
+++ b/tests/test-help.t	Tue Jun 14 15:11:36 2022 +0200
@@ -1615,6 +1615,8 @@
   
       "use-share-safe.automatic-upgrade-of-mismatching-repositories"
   
+      "use-share-safe.automatic-upgrade-of-mismatching-repositories:quiet"
+  
       "usestore"
   
       "sparse-revlog"
--- a/tests/test-upgrade-repo.t	Tue Jun 14 15:45:37 2022 +0200
+++ b/tests/test-upgrade-repo.t	Tue Jun 14 15:11:36 2022 +0200
@@ -2075,11 +2075,10 @@
   >     --config format.use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories=yes \
   >     --config format.use-dirstate-tracked-hint=yes \
   >     --config format.use-share-safe.automatic-upgrade-of-mismatching-repositories=yes \
+  >     --config format.use-share-safe.automatic-upgrade-of-mismatching-repositories:quiet=yes \
   >     --config format.use-share-safe=no
   automatically downgrading repository from the `dirstate-v2` feature
   (see `hg help config.format.use-dirstate-v2` for details)
-  automatically downgrading repository from the `share-safe` feature
-  (see `hg help config.format.use-share-safe` for details)
   automatically upgrading repository to the `tracked-hint` feature
   (see `hg help config.format.use-dirstate-tracked-hint` for details)
 
@@ -2094,11 +2093,10 @@
   >     --config format.use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories=yes \
   >     --config format.use-dirstate-tracked-hint=no\
   >     --config format.use-share-safe.automatic-upgrade-of-mismatching-repositories=yes \
+  >     --config format.use-share-safe.automatic-upgrade-of-mismatching-repositories:quiet=yes \
   >     --config format.use-share-safe=yes
   automatically upgrading repository to the `dirstate-v2` feature
   (see `hg help config.format.use-dirstate-v2` for details)
-  automatically upgrading repository to the `share-safe` feature
-  (see `hg help config.format.use-share-safe` for details)
   automatically downgrading repository from the `tracked-hint` feature
   (see `hg help config.format.use-dirstate-tracked-hint` for details)
   $ hg debugformat -R auto-upgrade | egrep '(dirstate-v2|tracked|share-safe)'