[PATCH 2 of 4] Add a progress bar for events in which the maxval is unknown
Matt Mackall
mpm at selenic.com
Thu May 1 13:00:18 CDT 2008
On Wed, 2008-04-30 at 15:04 +0200, Stefano Tortarolo wrote:
> # 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('.')
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.
Here's an idea: let's do logarithmic dots. Something like this:
import sys
pos = 0
for x in xrange(20000):
sum = 0
for y in xrange(5000):
sum += y
# dynamic range roughly 400 - 500000
if x > 2**(.13 * (pos + 66)):
sys.stdout.write('.')
sys.stdout.flush()
pos += 1
It doesn't give much sense of how long the operation is going to take,
of course, but it does show that things haven't hung.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list