mercurial/localrepo.py
changeset 46235 0babe12ef35d
parent 46234 9804162a4053
child 46236 eec47efe219d
--- a/mercurial/localrepo.py	Wed Jan 06 16:01:19 2021 +0530
+++ b/mercurial/localrepo.py	Wed Jan 06 16:18:06 2021 +0530
@@ -582,12 +582,23 @@
     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'
+            if ui.configbool(b'experimental', b'sharesafe-auto-upgrade-shares'):
+                # prevent cyclic import localrepo -> upgrade -> localrepo
+                from . import upgrade
+
+                upgrade.upgrade_share_to_safe(
+                    ui,
+                    hgvfs,
+                    storevfs,
+                    requirements,
                 )
-            )
+            else:
+                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