From patchwork Mon Nov 30 15:43:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D9467: upgrade: directly use the upgrade action constant From: phabricator X-Patchwork-Id: 47745 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Mon, 30 Nov 2020 15:43:22 +0000 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 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