[PATCH 2 of 4] Add a progress bar for events in which the maxval is unknown

Stefano stefano at inventati.org
Fri May 2 08:28:21 CDT 2008

Matt Mackall wrote:
> So we print a dot for every step in the op? What if there are 100k
> steps? Also, seems this should have been derived from the other class.
Actually during cloning that's not an issue since it prints less than 10 
Anyway you're right, it would be better to do logarithmic dots.

What do you think about something like using a rotating bar? (see patch 
It works on Unix, Windows and MacOs as well.

I think that for this to make sense I should update the 'progress bar' more
often in clone. Could this lead to performance issues?

As far as the inheritance from noprogress is concerned, there are no 
practical consequences
in this case (indeed in the attached patch I derive from progress) since 
every function has
been overridden.
 From a logical point of view it depends on whether we call the 
percentage class 'progress' or 'progresspercentage'. In the second case 
progressnoval would be a logical specialization
of noprogress (I mean, at the same level of progresspercentage).


diff --git a/mercurial/progress.py b/mercurial/progress.py
--- a/mercurial/progress.py
+++ b/mercurial/progress.py
@@ -76,7 +76,7 @@
             self._clean = True

-class progressnoval(noprogress):
+class progressnoval(progress):

     """Simple progress indicator with no maxval"""

@@ -85,13 +85,17 @@
         self._fd = fd
         self._clean = True
+        self.pos = 0
+        self._status = '|/-\\|/-\\'

     def update(self):
         if self._clean:
                 self._clean = False
-                self._fd.write('%s' % self._msg)
+                self._fd.write('%s\n' % self._msg)
-            self._fd.write('.')
+            self.pos = (self.pos + 1) % len(self._status)
+            self._fd.write('\r%s' % self._status[self.pos])
+            self._fd.flush()

     def finish(self):

More information about the Mercurial-devel mailing list