##// END OF EJS Templates
progress: specify updatebar() function by constructor argument...
Yuya Nishihara -
r41246:929999d9 default
parent child Browse files
Show More
@@ -1415,28 +1415,13 b' def wlocksub(repo, cmd, *args, **kwargs)'
1415 **kwargs)
1415 **kwargs)
1416
1416
1417 class progress(object):
1417 class progress(object):
1418 def __init__(self, ui, topic, unit="", total=None):
1418 def __init__(self, ui, updatebar, topic, unit="", total=None):
1419 self.ui = ui
1419 self.ui = ui
1420 self.pos = 0
1420 self.pos = 0
1421 self.topic = topic
1421 self.topic = topic
1422 self.unit = unit
1422 self.unit = unit
1423 self.total = total
1423 self.total = total
1424 self.debug = ui.configbool('progress', 'debug')
1424 self.debug = ui.configbool('progress', 'debug')
1425 if getattr(ui._fmsgerr, 'structured', False):
1426 # channel for machine-readable output with metadata, just send
1427 # raw information
1428 # TODO: consider porting some useful information (e.g. estimated
1429 # time) from progbar. we might want to support update delay to
1430 # reduce the cost of transferring progress messages.
1431 def updatebar(topic, pos, item, unit, total):
1432 ui._fmsgerr.write(None, type=b'progress', topic=topic,
1433 pos=pos, item=item, unit=unit,
1434 total=total)
1435 elif ui._progbar is not None:
1436 updatebar = ui._progbar.progress
1437 else:
1438 def updatebar(topic, pos, item, unit, total):
1439 pass
1440 self._updatebar = updatebar
1425 self._updatebar = updatebar
1441
1426
1442 def __enter__(self):
1427 def __enter__(self):
@@ -1698,8 +1698,22 b' class ui(object):'
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"""
General Comments 0
You need to be logged in to leave comments. Login now