upgrade: only process revlogs that needs it by default
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 06 Dec 2021 17:54:39 +0100
changeset 48448 62e6222cc5b6
parent 48447 8405c1bffacf
child 48449 dc2ef4b4d9a9
upgrade: only process revlogs that needs it by default We have more and more requirement that does not affect revlog or that only affect some of them. It is silly to force a full processing of all revlog to juste move the requirement around, or to simply rewrite the dirstate. So now, only the revlog that needs to be touched will be touched. Unless the --changelog & al flags are used. Differential Revision: https://phab.mercurial-scm.org/D11871
mercurial/upgrade.py
tests/test-share-safe.t
tests/test-upgrade-repo.t
--- a/mercurial/upgrade.py	Mon Dec 06 17:13:26 2021 +0100
+++ b/mercurial/upgrade.py	Mon Dec 06 17:54:39 2021 +0100
@@ -99,6 +99,18 @@
     MN = upgrade_engine.UPGRADE_MANIFEST
     CL = upgrade_engine.UPGRADE_CHANGELOG
 
+    if optimizations:
+        if any(specified_revlogs.values()):
+            # we have some limitation on revlogs to be recloned
+            for rl, enabled in specified_revlogs.items():
+                if enabled:
+                    touched_revlogs.add(rl)
+        else:
+            touched_revlogs = set(upgrade_engine.UPGRADE_ALL_REVLOGS)
+            for rl, enabled in specified_revlogs.items():
+                if not enabled:
+                    touched_revlogs.discard(rl)
+
     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:
@@ -147,22 +159,9 @@
     elif msg_issued >= 1:
         ui.status((b"\n"))
 
-    revlogs = set(upgrade_engine.UPGRADE_ALL_REVLOGS)
-    if specified_revlogs:
-        # we have some limitation on revlogs to be recloned
-        if any(specified_revlogs.values()):
-            revlogs = set()
-            for upgrade, enabled in specified_revlogs.items():
-                if enabled:
-                    revlogs.add(upgrade)
-        else:
-            # none are enabled
-            for upgrade in specified_revlogs.keys():
-                revlogs.discard(upgrade)
-
     # check the consistency of the revlog selection with the planned action
 
-    if revlogs != upgrade_engine.UPGRADE_ALL_REVLOGS:
+    if touched_revlogs != upgrade_engine.UPGRADE_ALL_REVLOGS:
         incompatible = upgrade_actions.RECLONES_REQUIREMENTS & (
             removedreqs | addedreqs
         )
@@ -172,7 +171,7 @@
                 b'change: %s\n'
             )
             ui.warn(msg % b', '.join(sorted(incompatible)))
-            revlogs = upgrade_engine.UPGRADE_ALL_REVLOGS
+            touched_revlogs = upgrade_engine.UPGRADE_ALL_REVLOGS
 
     upgrade_op = upgrade_actions.UpgradeOperation(
         ui,
@@ -180,7 +179,7 @@
         repo.requirements,
         up_actions,
         removed_actions,
-        revlogs,
+        touched_revlogs,
         backup,
     )
 
--- a/tests/test-share-safe.t	Mon Dec 06 17:13:26 2021 +0100
+++ b/tests/test-share-safe.t	Mon Dec 06 17:54:39 2021 +0100
@@ -363,10 +363,7 @@
      preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
      added: share-safe
   
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
+  no revlogs to process
   
   $ hg debugupgraderepo --run
   upgrade will perform the following actions:
@@ -379,10 +376,7 @@
   share-safe
      Upgrades a repository to share-safe format so that future shares of this repository share its requirements and configs.
   
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
+  no revlogs to process
   
   beginning upgrade...
   repository locked and read-only
@@ -457,10 +451,7 @@
      preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
      removed: share-safe
   
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
+  no revlogs to process
   
   $ hg debugupgraderepo --run
   upgrade will perform the following actions:
@@ -470,10 +461,7 @@
      preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
      removed: share-safe
   
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
+  no revlogs to process
   
   beginning upgrade...
   repository locked and read-only
@@ -556,10 +544,7 @@
      preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
      added: share-safe
   
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
+  no revlogs to process
   
   repository upgraded to share safe mode, existing shares will still work in old non-safe mode. Re-share existing shares to use them in safe mode New shares will be created in safe mode.
   $ hg debugrequirements
--- a/tests/test-upgrade-repo.t	Mon Dec 06 17:13:26 2021 +0100
+++ b/tests/test-upgrade-repo.t	Mon Dec 06 17:54:39 2021 +0100
@@ -213,10 +213,7 @@
      preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-rust !)
      preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (rust !)
   
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
+  no revlogs to process
   
   additional optimizations are available by specifying "--optimize <name>":
   
@@ -238,10 +235,7 @@
      preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-rust !)
      preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (rust !)
   
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
+  no revlogs to process
   
 
 --optimize can be used to add optimizations
@@ -963,7 +957,6 @@
   $ hg debugupgrade --optimize re-delta-parent --no-manifest --no-backup --quiet
   warning: ignoring  --no-manifest, as upgrade is changing: sparserevlog
   
-  ignoring revlogs selection flags, format requirements change: sparserevlog
   requirements
      preserved: dotencode, fncache, generaldelta, revlogv1, store (no-rust !)
      preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, store (rust !)
@@ -980,7 +973,6 @@
   note:    selecting all-filelogs for processing to change: sparserevlog
   note:    selecting changelog for processing to change: sparserevlog
   
-  ignoring revlogs selection flags, format requirements change: sparserevlog
   upgrade will perform the following actions:
   
   requirements
@@ -1038,7 +1030,6 @@
   note:    selecting all-filelogs for processing to change: sparserevlog
   note:    selecting changelog for processing to change: sparserevlog
   
-  ignoring revlogs selection flags, format requirements change: sparserevlog
   upgrade will perform the following actions:
   
   requirements
@@ -1695,10 +1686,7 @@
   dirstate-v2
      "hg status" will be faster
   
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
+  no revlogs to process
   
   beginning upgrade...
   repository locked and read-only
@@ -1724,10 +1712,7 @@
      preserved: * (glob)
      removed: dirstate-v2
   
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
+  no revlogs to process
   
   beginning upgrade...
   repository locked and read-only
@@ -1762,10 +1747,7 @@
   dirstate-v2
      "hg status" will be faster
   
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
+  no revlogs to process
   
   beginning upgrade...
   repository locked and read-only
@@ -1786,10 +1768,7 @@
      preserved: * (glob)
      removed: dirstate-v2
   
-  processed revlogs:
-    - all-filelogs
-    - changelog
-    - manifest
+  no revlogs to process
   
   beginning upgrade...
   repository locked and read-only