diff mercurial/upgrade.py @ 48779:17eaeb06562c

upgrade: prepare code (and output) for the idea of upgrading share This would work for a subset of action only. Our first target is dirstate-v2. Differential Revision: https://phab.mercurial-scm.org/D12196
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 15 Feb 2022 23:09:07 +0100
parents a4d8de93023c
children 6000f5b25c9b
line wrap: on
line diff
--- a/mercurial/upgrade.py	Tue Feb 15 13:32:30 2022 -0500
+++ b/mercurial/upgrade.py	Tue Feb 15 23:09:07 2022 +0100
@@ -108,6 +108,22 @@
                 if not enabled:
                     touched_revlogs.discard(rl)
 
+    if repo.shared():
+        unsafe_actions = set()
+        unsafe_actions.update(up_actions)
+        unsafe_actions.update(removed_actions)
+        unsafe_actions.update(optimizations)
+        unsafe_actions = [
+            a for a in unsafe_actions if not a.compatible_with_share
+        ]
+        unsafe_actions.sort(key=lambda a: a.name)
+        if unsafe_actions:
+            m = _(b'cannot use these actions on a share repository: %s')
+            h = _(b'upgrade the main repository directly')
+            actions = b', '.join(a.name for a in unsafe_actions)
+            m %= actions
+            raise error.Abort(m, hint=h)
+
     for action in sorted(up_actions + removed_actions, key=lambda a: a.name):
         # optimisation does not "requires anything, they just needs it.
         if action.type != upgrade_actions.FORMAT_VARIANT: