# HG changeset patch # User Martin von Zweigbergk # Date 2019-01-08 08:17:41 # Node ID 3025fd3c2e71a64125affe558c24181ec1305281 # Parent 7b80406b82710e3469625b42b43cb0c1a08b7d51 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 diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -1434,7 +1434,9 @@ class progress(object): 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 @@ class progress(object): 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 @@ class progress(object): 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: