[Request] [+- ] D9575: upgrade: move `printupgradeactions()` to UpgradeOperation class
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Mon Dec 14 09:55:25 UTC 2020
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
Part of refactor where we make things more arranged and integrated into single
`UpgradeOperation` class.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D9575
AFFECTED FILES
mercurial/upgrade.py
mercurial/upgrade_utils/actions.py
mercurial/upgrade_utils/engine.py
CHANGE DETAILS
diff --git a/mercurial/upgrade_utils/engine.py b/mercurial/upgrade_utils/engine.py
--- a/mercurial/upgrade_utils/engine.py
+++ b/mercurial/upgrade_utils/engine.py
@@ -403,13 +403,13 @@
)
)
- if b're-delta-all' in upgrade_op.actions:
+ if upgrade_op.has_action(b're-delta-all'):
deltareuse = revlog.revlog.DELTAREUSENEVER
- elif b're-delta-parent' in upgrade_op.actions:
+ elif upgrade_op.has_action(b're-delta-parent'):
deltareuse = revlog.revlog.DELTAREUSESAMEREVS
- elif b're-delta-multibase' in upgrade_op.actions:
+ elif upgrade_op.has_action(b're-delta-multibase'):
deltareuse = revlog.revlog.DELTAREUSESAMEREVS
- elif b're-delta-fulladd' in upgrade_op.actions:
+ elif upgrade_op.has_action(b're-delta-fulladd'):
deltareuse = revlog.revlog.DELTAREUSEFULLADD
else:
deltareuse = revlog.revlog.DELTAREUSEALWAYS
@@ -421,7 +421,7 @@
dstrepo,
tr,
deltareuse,
- b're-delta-multibase' in upgrade_op.actions,
+ upgrade_op.has_action(b're-delta-multibase'),
revlogs=upgrade_op.revlogs_to_process,
)
diff --git a/mercurial/upgrade_utils/actions.py b/mercurial/upgrade_utils/actions.py
--- a/mercurial/upgrade_utils/actions.py
+++ b/mercurial/upgrade_utils/actions.py
@@ -561,8 +561,13 @@
self.ui = ui
self.requirements = requirements
self.actions = actions
+ self._actions_names = set([a.name for a in actions])
self.revlogs_to_process = revlogs_to_process
+ def print_upgrade_actions(self):
+ for a in self.actions:
+ self.ui.status(b'%s\n %s\n\n' % (a.name, a.upgrademessage))
+
def print_affected_revlogs(self):
if not self.revlogs_to_process:
self.ui.write((b'no revlogs to process\n'))
@@ -572,6 +577,10 @@
self.ui.write((b' - %s\n' % r))
self.ui.write((b'\n'))
+ def has_action(self, name):
+ """ Check whether the upgrade operation will perform this action """
+ return name in self._actions_names
+
### Code checking if a repository can got through the upgrade process at all. #
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -163,14 +163,10 @@
)
ui.write(b'\n\n')
- def printupgradeactions():
- for a in actions:
- ui.status(b'%s\n %s\n\n' % (a.name, a.upgrademessage))
-
upgrade_op = upgrade_actions.UpgradeOperation(
ui,
newreqs,
- [a.name for a in actions],
+ actions,
revlogs,
)
@@ -224,7 +220,7 @@
printrequirements()
printoptimisations()
- printupgradeactions()
+ upgrade_op.print_upgrade_actions()
upgrade_op.print_affected_revlogs()
unusedoptimize = [i for i in alloptimizations if i not in actions]
@@ -244,7 +240,7 @@
ui.write(_(b'upgrade will perform the following actions:\n\n'))
printrequirements()
printoptimisations()
- printupgradeactions()
+ upgrade_op.print_upgrade_actions()
upgrade_op.print_affected_revlogs()
ui.status(_(b'beginning upgrade...\n'))
To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20201214/1968eef0/attachment-0001.html>
More information about the Mercurial-patches
mailing list