# HG changeset patch # User Augie Fackler # Date 1270757040 18000 # Node ID 83af68e38be31075828769a5cbfcc2057933fcaa # Parent 301633755dec7e07a06d127ae679793cb9d3c8bd progress: fall back to indeterminate progress if position is >= total diff -r 301633755dec -r 83af68e38be3 hgext/progress.py --- a/hgext/progress.py Sun Apr 11 14:25:02 2010 -0500 +++ b/hgext/progress.py Thu Apr 08 15:04:00 2010 -0500 @@ -114,7 +114,7 @@ if tail: used += len(tail) + 1 progwidth = termwidth - used - 3 - if total: + if total and pos <= total: amt = pos * progwidth // total bar = '=' * (amt - 1) if amt > 0: diff -r 301633755dec -r 83af68e38be3 tests/test-progress --- a/tests/test-progress Sun Apr 11 14:25:02 2010 -0500 +++ b/tests/test-progress Thu Apr 08 15:04:00 2010 -0500 @@ -8,6 +8,8 @@ total = None if loops >= 0: total = loops + if opts.get('total', None): + total = int(opts.get('total')) loops = abs(loops) for i in range(loops): @@ -17,7 +19,8 @@ commands.norepo += " loop" cmdtable = { - "loop": (loop, [], 'hg loop LOOPS'), + "loop": (loop, [('', 'total', '', 'override for total')], + 'hg loop LOOPS'), } EOF @@ -55,5 +58,8 @@ echo '% test format options and indeterminate progress' hg -y --config 'progress.format=number item bar' loop -- -2 2>&1 | python filtercr.py +echo "% make sure things don't fall over if count > total" +hg -y loop --total 4 6 2>&1 | python filtercr.py + echo '% test immediate progress completion' hg -y loop 0 2>&1 | python filtercr.py diff -r 301633755dec -r 83af68e38be3 tests/test-progress.out --- a/tests/test-progress.out Sun Apr 11 14:25:02 2010 -0500 +++ b/tests/test-progress.out Thu Apr 08 15:04:00 2010 -0500 @@ -17,4 +17,12 @@ 0 loop.0 [ <=> ] 1 loop.1 [ <=> ] + % make sure things don't fall over if count > total + +loop [ ] 0/4 +loop [================> ] 1/4 +loop [=================================> ] 2/4 +loop [==================================================> ] 3/4 +loop [===================================================================>] 4/4 +loop [ <=> ] 5/4 % test immediate progress completion