# HG changeset patch # User Benoit Boissinot # Date 1266051328 -3600 # Node ID 509f4ed56509bdc79663d71cce81e9f56aeb6095 # Parent e6dc4414723499cf63b3c7318900186b1c8fef8f progress: correctly handle empty progress topic diff -r e6dc44147234 -r 509f4ed56509 hgext/progress.py --- a/hgext/progress.py Fri Feb 12 19:59:09 2010 -0500 +++ b/hgext/progress.py Sat Feb 13 09:55:28 2010 +0100 @@ -140,25 +140,29 @@ def clear(self): sys.stdout.write('\r%s\r' % (' ' * self.width())) + def complete(self): + if self.ui.configbool('progress', 'clear-complete', default=True): + self.clear() + else: + sys.stdout.write('\n') + sys.stdout.flush() + def width(self): tw = util.termwidth() return min(int(self.ui.config('progress', 'width', default=tw)), tw) def progress(self, orig, topic, pos, item='', unit='', total=None): - now = time.time() - if pos is None and self.topics[-1] == topic and self.printed: - if self.ui.configbool('progress', 'clear-complete', default=True): - self.clear() - else: - sys.stdout.write('\n') - sys.stdout.flush() + if pos is None: + if self.topics and self.topics[-1] == topic and self.printed: + self.complete() self.resetstate() - elif topic not in self.topics: - self.topics.append(topic) - - if now - self.lastprint > 0.1 and topic == self.topics[-1]: - self.lastprint = now - self.show(topic, pos, item, unit, total) + else: + if topic not in self.topics: + self.topics.append(topic) + now = time.time() + if now - self.lastprint > 0.1 and topic == self.topics[-1]: + self.lastprint = now + self.show(topic, pos, item, unit, total) return orig(topic, pos, item=item, unit=unit, total=total) def write(self, orig, *args):