[PATCH] progress: don't compute estimate without a total

Adrian Buehlmann adrian at cadifra.com
Thu Dec 16 01:54:52 CST 2010


On 2010-12-16 05:05, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <durin42 at gmail.com>
> # Date 1292472327 21600
> # Node ID 3b79ee2fca7d1f00d4fef7164e8d6e88f42c0dfe
> # Parent  94507fd06ebc1516d4141a411cb27ec7534fa3a9
> progress: don't compute estimate without a total
> 
> Without this, computing an estimate explodes gloriously. Test
> included.

A word like 'explode' might be funny for some people in a mailing list
post or in IRC chat, but IMHO it shouldn't be used in change message
text, tests or code.

I assume you mean: 'fails with a traceback'?

> diff --git a/hgext/progress.py b/hgext/progress.py
> --- a/hgext/progress.py
> +++ b/hgext/progress.py
> @@ -183,6 +183,8 @@
>          return min(int(self.ui.config('progress', 'width', default=tw)), tw)
>  
>      def estimate(self, topic, pos, total, now):
> +        if total is None:
> +            return ''
>          initialpos = self.startvals[topic]
>          target = total - initialpos
>          delta = pos - initialpos
> diff --git a/tests/test-progress.t b/tests/test-progress.t
> --- a/tests/test-progress.t
> +++ b/tests/test-progress.t
> @@ -141,3 +141,9 @@
>    loop [==============================>           ] 3/4 2h47m
>                                                                \r (esc)
>  
> +Time estimates should not explode when there's no end point:

ditto

> +  $ hg -y loop -- -4 2>&1 | python $TESTDIR/filtercr.py
> +  
> +  loop [ <=>                                              ] 2
> +  loop [  <=>                                             ] 3
> +                                                              \r (esc)


More information about the Mercurial-devel mailing list