Patchwork D9574: upgrade: move `print_affected_revlogs()` to UpgradeOperation class

login
register
mail settings
Submitter phabricator
Date Dec. 14, 2020, 9:55 a.m.
Message ID <differential-rev-PHID-DREV-tfj77j6t2drz42ed3hje-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47872/
State Superseded
Headers show

Comments

phabricator - Dec. 14, 2020, 9:55 a.m.
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/D9574

AFFECTED FILES
  mercurial/upgrade.py
  mercurial/upgrade_utils/actions.py

CHANGE DETAILS




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

Patch

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
@@ -557,11 +557,21 @@ 
 class UpgradeOperation(object):
     """represent the work to be done during an upgrade"""
 
-    def __init__(self, requirements, actions, revlogs_to_process):
+    def __init__(self, ui, requirements, actions, revlogs_to_process):
+        self.ui = ui
         self.requirements = requirements
         self.actions = actions
         self.revlogs_to_process = revlogs_to_process
 
+    def print_affected_revlogs(self):
+        if not self.revlogs_to_process:
+            self.ui.write((b'no revlogs to process\n'))
+        else:
+            self.ui.write((b'processed revlogs:\n'))
+            for r in sorted(self.revlogs_to_process):
+                self.ui.write((b'  - %s\n' % r))
+        self.ui.write((b'\n'))
+
 
 ###  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
@@ -167,16 +167,8 @@ 
         for a in actions:
             ui.status(b'%s\n   %s\n\n' % (a.name, a.upgrademessage))
 
-    def print_affected_revlogs():
-        if not revlogs:
-            ui.write((b'no revlogs to process\n'))
-        else:
-            ui.write((b'processed revlogs:\n'))
-            for r in sorted(revlogs):
-                ui.write((b'  - %s\n' % r))
-        ui.write((b'\n'))
-
     upgrade_op = upgrade_actions.UpgradeOperation(
+        ui,
         newreqs,
         [a.name for a in actions],
         revlogs,
@@ -233,7 +225,7 @@ 
         printrequirements()
         printoptimisations()
         printupgradeactions()
-        print_affected_revlogs()
+        upgrade_op.print_affected_revlogs()
 
         unusedoptimize = [i for i in alloptimizations if i not in actions]
 
@@ -253,7 +245,7 @@ 
     printrequirements()
     printoptimisations()
     printupgradeactions()
-    print_affected_revlogs()
+    upgrade_op.print_affected_revlogs()
 
     ui.status(_(b'beginning upgrade...\n'))
     with repo.wlock(), repo.lock():