changeset 46344:4a58561ace0f stable

share-share: have the hint issue more consistently and point to the right doc This should help user in trouble to find solution in the documentation. Differential Revision: https://phab.mercurial-scm.org/D9841
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 20 Jan 2021 12:23:40 +0100
parents 5249ac2bc7a4
children 86842c4accc1
files mercurial/localrepo.py mercurial/upgrade.py tests/test-share-safe.t
diffstat 3 files changed, 25 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Wed Jan 20 12:13:17 2021 +0100
+++ b/mercurial/localrepo.py	Wed Jan 20 12:23:40 2021 +0100
@@ -568,6 +568,7 @@
     # 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
+    hint = _("see `hg help config.format.use-share-safe` for more information")
     if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
 
         if (
@@ -601,12 +602,10 @@
                 raise error.Abort(
                     _(
                         b"share source does not support exp-sharesafe requirement"
-                    )
+                    ),
+                    hint=hint,
                 )
             else:
-                hint = _(
-                    "run `hg help config.share.safe-mismatch.source-not-safe`"
-                )
                 raise error.Abort(
                     _(
                         b"share-safe mismatch with source.\nUnrecognized"
@@ -646,10 +645,10 @@
                     _(
                         b'version mismatch: source uses share-safe'
                         b' functionality while the current share does not'
-                    )
+                    ),
+                    hint=hint,
                 )
             else:
-                hint = _("run `hg help config.share.safe-mismatch.source-safe`")
                 raise error.Abort(
                     _(
                         b"share-safe mismatch with source.\nUnrecognized"
--- a/mercurial/upgrade.py	Wed Jan 20 12:13:17 2021 +0100
+++ b/mercurial/upgrade.py	Wed Jan 20 12:23:40 2021 +0100
@@ -282,15 +282,20 @@
         scmutil.writerequires(hgvfs, diffrequires)
         ui.warn(_(b'repository upgraded to use share-safe mode\n'))
     except error.LockError as e:
+        hint = _(
+            "see `hg help config.format.use-share-safe` for more information"
+        )
         if mismatch_config == b'upgrade-abort':
             raise error.Abort(
                 _(b'failed to upgrade share, got error: %s')
-                % stringutil.forcebytestr(e.strerror)
+                % stringutil.forcebytestr(e.strerror),
+                hint=hint,
             )
         elif mismatch_warn:
             ui.warn(
                 _(b'failed to upgrade share, got error: %s\n')
-                % stringutil.forcebytestr(e.strerror)
+                % stringutil.forcebytestr(e.strerror),
+                hint=hint,
             )
     finally:
         if wlock:
@@ -334,17 +339,22 @@
         scmutil.writerequires(hgvfs, current_requirements)
         ui.warn(_(b'repository downgraded to not use share-safe mode\n'))
     except error.LockError as e:
+        hint = _(
+            "see `hg help config.format.use-share-safe` for more information"
+        )
         # If upgrade-abort is set, abort when upgrade fails, else let the
         # process continue as `upgrade-allow` is set
         if mismatch_config == b'downgrade-abort':
             raise error.Abort(
                 _(b'failed to downgrade share, got error: %s')
-                % stringutil.forcebytestr(e.strerror)
+                % stringutil.forcebytestr(e.strerror),
+                hint=hint,
             )
         elif mismatch_warn:
             ui.warn(
                 _(b'failed to downgrade share, got error: %s\n')
-                % stringutil.forcebytestr(e.strerror)
+                % stringutil.forcebytestr(e.strerror),
+                hint=hint,
             )
     finally:
         if wlock:
--- a/tests/test-share-safe.t	Wed Jan 20 12:13:17 2021 +0100
+++ b/tests/test-share-safe.t	Wed Jan 20 12:23:40 2021 +0100
@@ -396,6 +396,7 @@
 
   $ hg log -GT "{node}: {desc}\n" -R ../nss-share
   abort: version mismatch: source uses share-safe functionality while the current share does not
+  (see `hg help config.format.use-share-safe` for more information)
   [255]
 
 
@@ -481,6 +482,7 @@
 
   $ hg log -GT "{node}: {desc}\n" -R ../ss-share
   abort: share source does not support exp-sharesafe requirement
+  (see `hg help config.format.use-share-safe` for more information)
   [255]
 
 Testing automatic downgrade of shares when config is set
@@ -488,6 +490,7 @@
   $ touch ../ss-share/.hg/wlock
   $ 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
+  (see `hg help config.format.use-share-safe` for more information)
   [255]
   $ rm ../ss-share/.hg/wlock
 
@@ -530,13 +533,14 @@
   store
   $ hg log -GT "{node}: {desc}\n" -R ../nss-share
   abort: version mismatch: source uses share-safe functionality while the current share does not
+  (see `hg help config.format.use-share-safe` for more information)
   [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.safe-mismatch.source-safe=upgra
   abort: share-safe mismatch with source.
   Unrecognized value 'upgra' of `share.safe-mismatch.source-safe` set.
-  (run `hg help config.share.safe-mismatch.source-safe`)
+  (see `hg help config.format.use-share-safe` for more information)
   [255]
   $ touch ../nss-share/.hg/wlock
   $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-allow
@@ -554,6 +558,7 @@
 
   $ 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
+  (see `hg help config.format.use-share-safe` for more information)
   [255]
 
   $ rm ../nss-share/.hg/wlock