Patchwork D11871: upgrade: only process revlogs that needs it by default

login
register
mail settings
Submitter phabricator
Date Dec. 7, 2021, 8:53 a.m.
Message ID <differential-rev-PHID-DREV-44nwmqjbeuvhuislykfh-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50198/
State Superseded
Headers show

Comments

phabricator - Dec. 7, 2021, 8:53 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS




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

Patch

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -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
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
@@ -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
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -99,6 +99,20 @@ 
     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
+            # if any(specified_revlogs.values()):
+            #     revlogs = set()
+            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 +161,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 +173,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 +181,7 @@ 
         repo.requirements,
         up_actions,
         removed_actions,
-        revlogs,
+        touched_revlogs,
         backup,
     )