D9369: share: show warning if share is outdated while source supports share-safe

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Mon Nov 23 09:29:25 UTC 2020


pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Previous patches in the series and some which are already committed implements
  share safe functionality where config and requirements will be shared too.
  
  Rolling this feature has a problem that existing shares may never upgrade as
  they will never learn about the new config. To help the transition, we show a
  warning messafe if the share source supports share-safe mechanism. This provides
  the source repo ability to upgrade and pass on the message to shares that you
  should reshare and upgrade too.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D9369

AFFECTED FILES
  mercurial/localrepo.py
  tests/test-share-safe.t

CHANGE DETAILS

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
@@ -373,6 +373,7 @@
 Make sure existing shares still works
 
   $ hg log -GT "{node}: {desc}\n" -R ../nss-share
+  warning: source repository supports share-safe functionality. Reshare to upgrade.
   @  f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
   |
   o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -558,6 +558,11 @@
     # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement
     # is present. We never write SHARESAFE_REQUIREMENT for a repo if store
     # is not present, refer checkrequirementscompat() for that
+    #
+    # However, if SHARESAFE_REQUIREMENT is not present, it means that the
+    # 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
     if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
         if shared:
             # This is a shared repo
@@ -566,6 +571,15 @@
             storevfs = vfsmod.vfs(hgvfs.join(b'store'))
 
         requirements |= _readrequires(storevfs, False)
+    elif shared:
+        sourcerequires = _readrequires(sharedvfs, False)
+        if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires:
+            ui.warn(
+                _(
+                    'warning: source repository supports share-safe functionality.'
+                    ' Reshare to upgrade.\n'
+                )
+            )
 
     # The .hg/hgrc file may load extensions or contain config options
     # that influence repository construction. Attempt to load it and



To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list