1437 |
1437 |
1438 def increment(self, step=1, item="", total=None): |
1438 def increment(self, step=1, item="", total=None): |
1439 self.update(self.pos + step, item, total) |
1439 self.update(self.pos + step, item, total) |
1440 |
1440 |
1441 def complete(self): |
1441 def complete(self): |
1442 self.ui.progress(self.topic, None) |
1442 self.pos = None |
|
1443 self.unit = "" |
|
1444 self.total = None |
|
1445 self._print("") |
1443 |
1446 |
1444 def _print(self, item): |
1447 def _print(self, item): |
1445 self.ui.progress(self.topic, self.pos, item, self.unit, |
1448 if getattr(self.ui._fmsgerr, 'structured', False): |
1446 self.total) |
1449 # channel for machine-readable output with metadata, just send |
|
1450 # raw information |
|
1451 # TODO: consider porting some useful information (e.g. estimated |
|
1452 # time) from progbar. we might want to support update delay to |
|
1453 # reduce the cost of transferring progress messages. |
|
1454 self.ui._fmsgerr.write(None, type=b'progress', topic=self.topic, |
|
1455 pos=self.pos, item=item, unit=self.unit, |
|
1456 total=self.total) |
|
1457 elif self.ui._progbar is not None: |
|
1458 self.ui._progbar.progress(self.topic, self.pos, item=item, |
|
1459 unit=self.unit, total=self.total) |
|
1460 |
|
1461 # Looking up progress.debug in tight loops is expensive. The value |
|
1462 # is cached on the progbar object and we can avoid the lookup in |
|
1463 # the common case where a progbar is active. |
|
1464 if self.pos is None or not self.ui._progbar.debug: |
|
1465 return |
|
1466 |
|
1467 # Keep this logic in sync with above. |
|
1468 if self.pos is None or not self.ui.configbool('progress', 'debug'): |
|
1469 return |
|
1470 |
|
1471 if self.unit: |
|
1472 unit = ' ' + self.unit |
|
1473 if item: |
|
1474 item = ' ' + item |
|
1475 |
|
1476 if self.total: |
|
1477 pct = 100.0 * self.pos / self.total |
|
1478 self.ui.debug('%s:%s %d/%d%s (%4.2f%%)\n' |
|
1479 % (self.topic, item, self.pos, self.total, unit, pct)) |
|
1480 else: |
|
1481 self.ui.debug('%s:%s %d%s\n' % (self.topic, item, self.pos, unit)) |
1447 |
1482 |
1448 def gdinitconfig(ui): |
1483 def gdinitconfig(ui): |
1449 """helper function to know if a repo should be created as general delta |
1484 """helper function to know if a repo should be created as general delta |
1450 """ |
1485 """ |
1451 # experimental config: format.generaldelta |
1486 # experimental config: format.generaldelta |