[PATCH 2 of 4] Add a progress bar for events in which the maxval is unknown
Stefano Tortarolo
stefano at inventati.org
Wed Apr 30 13:04:31 UTC 2008
# HG changeset patch
# User Stefano Tortarolo <stefano at inventati.org>
# Date 1209560014 -7200
# Node ID f79d4a6ce30fb62c9ea05478767cafef56575407
# Parent a360beb5ab203fc71988535bdb9b29a6fa0a1e24
Add a progress bar for events in which the maxval is unknown
diff -r a360beb5ab20 -r f79d4a6ce30f mercurial/progress.py
--- a/mercurial/progress.py Mon Jul 23 09:26:59 2007 +0200
+++ b/mercurial/progress.py Wed Apr 30 14:53:34 2008 +0200
@@ -76,3 +76,28 @@
self._clean = True
self._fd.write('\n')
+class progressnoval(noprogress):
+
+ """Simple progress indicator with no maxval"""
+
+ def __init__(self, msg, fd):
+ self._msg = msg
+ self._fd = fd
+ self._clean = True
+ self.update()
+
+ def update(self):
+ if self._clean:
+ self._clean = False
+ self._fd.write('%s' % self._msg)
+ else:
+ self._fd.write('.')
+
+ def finish(self):
+ self._fd.write('done!')
+ self.interrupt()
+
+ def interrupt(self):
+ if not self._clean:
+ self._clean = True
+ self._fd.write('\n')
diff -r a360beb5ab20 -r f79d4a6ce30f mercurial/ui.py
--- a/mercurial/ui.py Mon Jul 23 09:26:59 2007 +0200
+++ b/mercurial/ui.py Wed Apr 30 14:53:34 2008 +0200
@@ -484,11 +484,13 @@
traceback.print_exc()
return self.traceback
- def progress(self, msg, maxval):
+ def progress(self, msg, maxval=None):
"""Return progress indicator object"""
fd = sys.stderr
- if self.quiet or maxval < 1 or not fd.isatty():
+ if self.quiet or not fd.isatty():
self._progress = progress.noprogress(msg, maxval, fd)
+ elif not maxval or maxval < 1:
+ self._progress = progress.progressnoval(msg, fd)
else:
self._progress = progress.progress(msg, maxval, fd)
return self._progress
More information about the Mercurial-devel
mailing list