changeset 46004:49b4ab1d9f5e

share: show warning if share is outdated while source supports share-safe 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 message 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. Differential Revision: https://phab.mercurial-scm.org/D9369
author Pulkit Goyal <pulkit@yandex-team.ru>
date Mon, 23 Nov 2020 14:15:26 +0530
parents c6a1fa42e325
children 2c0ddb79a8cd
files mercurial/localrepo.py tests/test-share-safe.t
diffstat 2 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Fri Oct 16 18:57:55 2020 +0530
+++ b/mercurial/localrepo.py	Mon Nov 23 14:15:26 2020 +0530
@@ -557,6 +557,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 (
@@ -575,6 +580,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(
+                _(
+                    b'warning: source repository supports share-safe functionality.'
+                    b' Reshare to upgrade.\n'
+                )
+            )
 
     # The .hg/hgrc file may load extensions or contain config options
     # that influence repository construction. Attempt to load it and
--- a/tests/test-share-safe.t	Fri Oct 16 18:57:55 2020 +0530
+++ b/tests/test-share-safe.t	Mon Nov 23 14:15:26 2020 +0530
@@ -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