Patchwork D9467: upgrade: directly use the upgrade action constant

login
register
mail settings
Submitter phabricator
Date Nov. 30, 2020, 3:43 p.m.
Message ID <differential-rev-PHID-DREV-y453i6srjbjrghqubrq7-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47745/
State Superseded
Headers show

Comments

phabricator - Nov. 30, 2020, 3:43 p.m.
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




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

Patch

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