Mercurial > hg
changeset 41145:963462786f6e
progress: check what type of progress bar to use only once per topic
This seems to have sped up `hg perfprogress` from 1.78 s to 1.41 s.
Differential Revision: https://phab.mercurial-scm.org/D5530
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 08 Jan 2019 00:30:30 -0800 |
parents | 3025fd3c2e71 |
children | eb172f9c208c |
files | mercurial/scmutil.py |
diffstat | 1 files changed, 18 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/scmutil.py Tue Jan 08 00:17:41 2019 -0800 +++ b/mercurial/scmutil.py Tue Jan 08 00:30:30 2019 -0800 @@ -1422,6 +1422,24 @@ self.unit = unit self.total = total self.debug = ui.configbool('progress', 'debug') + if getattr(ui._fmsgerr, 'structured', False): + # channel for machine-readable output with metadata, just send + # raw information + # TODO: consider porting some useful information (e.g. estimated + # time) from progbar. we might want to support update delay to + # reduce the cost of transferring progress messages. + def updatebar(item): + ui._fmsgerr.write(None, type=b'progress', topic=self.topic, + pos=self.pos, item=item, unit=self.unit, + total=self.total) + elif ui._progbar is not None: + def updatebar(item): + ui._progbar.progress(self.topic, self.pos, item=item, + unit=self.unit, total=self.total) + else: + def updatebar(item): + pass + self._updatebar = updatebar def __enter__(self): return self @@ -1447,20 +1465,6 @@ self.total = None self._updatebar("") - def _updatebar(self, item): - if getattr(self.ui._fmsgerr, 'structured', False): - # channel for machine-readable output with metadata, just send - # raw information - # TODO: consider porting some useful information (e.g. estimated - # time) from progbar. we might want to support update delay to - # reduce the cost of transferring progress messages. - self.ui._fmsgerr.write(None, type=b'progress', topic=self.topic, - pos=self.pos, item=item, unit=self.unit, - total=self.total) - elif self.ui._progbar is not None: - self.ui._progbar.progress(self.topic, self.pos, item=item, - unit=self.unit, total=self.total) - def _printdebug(self, item): if self.unit: unit = ' ' + self.unit