comparison mercurial/scmutil.py @ 38419:6dea017eb6ba

progress: enforce use of complete() on the helper class complete() is preferred over update(None), so let's enforce that. Differential Revision: https://phab.mercurial-scm.org/D3822
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 19 Jun 2018 22:19:37 -0700
parents 800f5a2c869e
children 32fba6fe893d
comparison
equal deleted inserted replaced
38418:b34d0a6ef936 38419:6dea017eb6ba
1298 1298
1299 def __exit__(self, exc_type, exc_value, exc_tb): 1299 def __exit__(self, exc_type, exc_value, exc_tb):
1300 self.complete() 1300 self.complete()
1301 1301
1302 def update(self, pos, item="", total=None): 1302 def update(self, pos, item="", total=None):
1303 assert pos is not None
1303 if total: 1304 if total:
1304 self.total = total 1305 self.total = total
1305 self.pos = pos 1306 self.pos = pos
1306 self._print(item) 1307 self._print(item)
1307 1308
1308 def increment(self, step=1, item="", total=None): 1309 def increment(self, step=1, item="", total=None):
1309 self.update(self.pos + step, item, total) 1310 self.update(self.pos + step, item, total)
1310 1311
1311 def complete(self): 1312 def complete(self):
1312 self.update(None) 1313 self.ui.progress(self.topic, None)
1313 1314
1314 def _print(self, item): 1315 def _print(self, item):
1315 self.ui.progress(self.topic, self.pos, item, self.unit, 1316 self.ui.progress(self.topic, self.pos, item, self.unit,
1316 self.total) 1317 self.total)
1317 1318