Mercurial > public > mercurial-scm > hg
diff mercurial/scmutil.py @ 41210:929999d963b8
progress: specify updatebar() function by constructor argument
This makes it easy for ui extensions to intercept progress messages. It also
seems slightly nicer in that scmutil.progress doesn't touch ui internals.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 13 Jan 2019 14:36:45 +0900 |
parents | b223fc1c6b4c |
children | 24a1f67bb75a |
line wrap: on
line diff
--- a/mercurial/scmutil.py Sun Jan 13 14:21:35 2019 +0900 +++ b/mercurial/scmutil.py Sun Jan 13 14:36:45 2019 +0900 @@ -1415,28 +1415,13 @@ **kwargs) class progress(object): - def __init__(self, ui, topic, unit="", total=None): + def __init__(self, ui, updatebar, topic, unit="", total=None): self.ui = ui self.pos = 0 self.topic = topic 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(topic, pos, item, unit, total): - ui._fmsgerr.write(None, type=b'progress', topic=topic, - pos=pos, item=item, unit=unit, - total=total) - elif ui._progbar is not None: - updatebar = ui._progbar.progress - else: - def updatebar(topic, pos, item, unit, total): - pass self._updatebar = updatebar def __enter__(self):