upgrade: make the list of explicitly specified revlog a dict
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 06 Dec 2021 14:40:13 +0100
changeset 48445 e7420f75d90d
parent 48444 6e045497b20b
child 48446 1d0978cfe968
upgrade: make the list of explicitly specified revlog a dict This makes various logic simpler and will help making future patch clearer. Differential Revision: https://phab.mercurial-scm.org/D11868
mercurial/upgrade.py
--- a/mercurial/upgrade.py	Mon Dec 06 11:59:48 2021 +0100
+++ b/mercurial/upgrade.py	Mon Dec 06 14:40:13 2021 +0100
@@ -45,11 +45,13 @@
         optimize = {}
     repo = repo.unfiltered()
 
-    specentries = (
-        (upgrade_engine.UPGRADE_CHANGELOG, changelog),
-        (upgrade_engine.UPGRADE_MANIFEST, manifest),
-        (upgrade_engine.UPGRADE_FILELOGS, filelogs),
-    )
+    specified_revlogs = {}
+    if changelog is not None:
+        specified_revlogs[upgrade_engine.UPGRADE_CHANGELOG] = changelog
+    if manifest is not None:
+        specified_revlogs[upgrade_engine.UPGRADE_MANIFEST] = manifest
+    if filelogs is not None:
+        specified_revlogs[upgrade_engine.UPGRADE_FILELOGS] = filelogs
 
     # Ensure the repository can be upgraded.
     upgrade_actions.check_source_requirements(repo)
@@ -89,17 +91,16 @@
     # check if we need to touch revlog and if so, which ones
 
     revlogs = set(upgrade_engine.UPGRADE_ALL_REVLOGS)
-    specified = [(y, x) for (y, x) in specentries if x is not None]
-    if specified:
+    if specified_revlogs:
         # we have some limitation on revlogs to be recloned
-        if any(x for y, x in specified):
+        if any(specified_revlogs.values()):
             revlogs = set()
-            for upgrade, enabled in specified:
+            for upgrade, enabled in specified_revlogs.items():
                 if enabled:
                     revlogs.add(upgrade)
         else:
             # none are enabled
-            for upgrade, __ in specified:
+            for upgrade in specified_revlogs.keys():
                 revlogs.discard(upgrade)
 
     # check the consistency of the revlog selection with the planned action