D9467: upgrade: directly use the upgrade action constant

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Mon Nov 30 15:43:22 UTC 2020


marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This make the code simpler and will make it simpler to add more case in the
  future.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/upgrade.py

CHANGE DETAILS

diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -1154,25 +1154,22 @@
     repo = repo.unfiltered()
 
     revlogs = set(UPGRADE_ALL_REVLOGS)
-    specentries = ((b'c', changelog), (b'm', manifest))
+    specentries = (
+        (UPGRADE_CHANGELOG, changelog),
+        (UPGRADE_MANIFEST, manifest)
+    )
     specified = [(y, x) for (y, x) in specentries if x is not None]
     if specified:
         # we have some limitation on revlogs to be recloned
         if any(x for y, x in specified):
             revlogs = set()
-            for r, enabled in specified:
+            for upgrade, enabled in specified:
                 if enabled:
-                    if r == b'c':
-                        revlogs.add(UPGRADE_CHANGELOG)
-                    elif r == b'm':
-                        revlogs.add(UPGRADE_MANIFEST)
+                    revlogs.add(upgrade)
         else:
             # none are enabled
-            for r, __ in specified:
-                if r == b'c':
-                    revlogs.discard(UPGRADE_CHANGELOG)
-                elif r == b'm':
-                    revlogs.discard(UPGRADE_MANIFEST)
+            for upgrade, __ in specified:
+                revlogs.discard(upgrade)
 
     # Ensure the repository can be upgraded.
     missingreqs = requiredsourcerequirements(repo) - repo.requirements



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


More information about the Mercurial-devel mailing list