[PATCH] progress: handle non zero starts
Augie Fackler
durin42 at gmail.com
Sun Nov 14 20:22:15 CST 2010
Probably wants to be folded into the other progress time estimation patch, but I'd rather make that decision when looking at the series as a whole. This one looks good to me, with that caveat.
On Nov 14, 2010, at 8:14 PM, timeless wrote:
> # HG changeset patch
> # User timeless <timeless at gmail.com>
> # Date 1289787260 21600
> # Node ID 784da27bb453418e244de22a87496379cf48d445
> # Parent a862577669b427374281d19f2002e4e08141db77
> progress: handle non zero starts
> this handles hg rebase --cont where you start from 90/100
>
> diff --git a/hgext/progress.py b/hgext/progress.py
> --- a/hgext/progress.py
> +++ b/hgext/progress.py
> @@ -66,6 +66,7 @@ class progbar(object):
> self.topicstates = {}
> self.pendingtopics = {}
> self.starttimes = {}
> + self.startvals = {}
> self.printed = False
> self.lastprint = time.time() + float(self.ui.config(
> 'progress', 'delay', default=3))
> @@ -130,11 +131,14 @@ class progbar(object):
> used += len(tail) + 1
> progwidth = termwidth - used - 3
> if total and pos <= total:
> - if pos > 0:
> + initial = self.startvals[topic]
> + target = total - initial
> + delta = pos - initial
> + if delta > 0:
> elapsed = now - self.starttimes[topic]
> if elapsed > float(
> self.ui.config('progress', 'estimate', default=2)):
> - seconds = (elapsed * (total - pos)) // pos + 1
> + seconds = (elapsed * (target - delta)) // delta + 1
> minutes = seconds // 60
> if minutes < 10:
> seconds -= minutes * 60
> @@ -191,6 +195,7 @@ class progbar(object):
> if pos is None:
> self.pendingtopics.pop(topic, None)
> self.starttimes.pop(topic, None)
> + self.startvals.pop(topic, None)
> if self.topics and self.topics[0] == topic and self.printed:
> self.complete()
> self.resetstate()
> @@ -208,6 +213,7 @@ class progbar(object):
> if topic not in self.topics:
> self.pendingtopics[topic] = 0
> self.starttimes[topic] = now
> + self.startvals[topic] = pos
> self.topics.append(topic)
> self.topicstates[topic] = pos, item, unit, total
> if now - self.lastprint >= self.refresh and self.topics:
More information about the Mercurial-devel
mailing list