changeset 41144:3025fd3c2e71

progress: split up _print() method in bar-updating and debug-printing I just thought this was clearer, but it turned out to also simplify the next patch. This seems to have sped up `hg perfprogress` from 1.85 s to 1.78 s. Differential Revision: https://phab.mercurial-scm.org/D5529
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 08 Jan 2019 00:17:41 -0800
parents 7b80406b8271
children 963462786f6e
files mercurial/scmutil.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/scmutil.py	Tue Jan 08 00:12:08 2019 -0800
+++ b/mercurial/scmutil.py	Tue Jan 08 00:17:41 2019 -0800
@@ -1434,7 +1434,9 @@
         if total:
             self.total = total
         self.pos = pos
-        self._print(item)
+        self._updatebar(item)
+        if self.debug:
+            self._printdebug(item)
 
     def increment(self, step=1, item="", total=None):
         self.update(self.pos + step, item, total)
@@ -1443,9 +1445,9 @@
         self.pos = None
         self.unit = ""
         self.total = None
-        self._print("")
+        self._updatebar("")
 
-    def _print(self, item):
+    def _updatebar(self, item):
         if getattr(self.ui._fmsgerr, 'structured', False):
             # channel for machine-readable output with metadata, just send
             # raw information
@@ -1459,9 +1461,7 @@
             self.ui._progbar.progress(self.topic, self.pos, item=item,
                                       unit=self.unit, total=self.total)
 
-        if self.pos is None or not self.debug:
-            return
-
+    def _printdebug(self, item):
         if self.unit:
             unit = ' ' + self.unit
         if item: