changeset 46188:945b33a7edfd

upgrade: move `print_affected_revlogs()` to UpgradeOperation class Part of refactor where we make things more arranged and integrated into single `UpgradeOperation` class. Differential Revision: https://phab.mercurial-scm.org/D9574
author Pulkit Goyal <7895pulkit@gmail.com>
date Sat, 12 Dec 2020 17:51:27 +0530
parents 95d6f31e88db
children dfddcbb0c244
files mercurial/upgrade.py mercurial/upgrade_utils/actions.py
diffstat 2 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/upgrade.py	Tue Dec 29 10:53:45 2020 +0100
+++ b/mercurial/upgrade.py	Sat Dec 12 17:51:27 2020 +0530
@@ -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():
--- a/mercurial/upgrade_utils/actions.py	Tue Dec 29 10:53:45 2020 +0100
+++ b/mercurial/upgrade_utils/actions.py	Sat Dec 12 17:51:27 2020 +0530
@@ -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. #