Mercurial > hg
comparison mercurial/ui.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 | 8cf92ca92bfe |
children | 44914de4e915 |
comparison
equal
deleted
inserted
replaced
41209:b223fc1c6b4c | 41210:929999d963b8 |
---|---|
1696 progress.update(pos, item=item) | 1696 progress.update(pos, item=item) |
1697 else: | 1697 else: |
1698 progress.complete() | 1698 progress.complete() |
1699 | 1699 |
1700 def makeprogress(self, topic, unit="", total=None): | 1700 def makeprogress(self, topic, unit="", total=None): |
1701 '''exists only so low-level modules won't need to import scmutil''' | 1701 """Create a progress helper for the specified topic""" |
1702 return scmutil.progress(self, topic, unit, total) | 1702 if getattr(self._fmsgerr, 'structured', False): |
1703 # channel for machine-readable output with metadata, just send | |
1704 # raw information | |
1705 # TODO: consider porting some useful information (e.g. estimated | |
1706 # time) from progbar. we might want to support update delay to | |
1707 # reduce the cost of transferring progress messages. | |
1708 def updatebar(topic, pos, item, unit, total): | |
1709 self._fmsgerr.write(None, type=b'progress', topic=topic, | |
1710 pos=pos, item=item, unit=unit, total=total) | |
1711 elif self._progbar is not None: | |
1712 updatebar = self._progbar.progress | |
1713 else: | |
1714 def updatebar(topic, pos, item, unit, total): | |
1715 pass | |
1716 return scmutil.progress(self, updatebar, topic, unit, total) | |
1703 | 1717 |
1704 def getlogger(self, name): | 1718 def getlogger(self, name): |
1705 """Returns a logger of the given name; or None if not registered""" | 1719 """Returns a logger of the given name; or None if not registered""" |
1706 return self._loggers.get(name) | 1720 return self._loggers.get(name) |
1707 | 1721 |