comparison tests/test-progress @ 10891:83af68e38be3

progress: fall back to indeterminate progress if position is >= total
author Augie Fackler <durin42@gmail.com>
date Thu, 08 Apr 2010 15:04:00 -0500
parents ca6ba6cac6cd
children
comparison
equal deleted inserted replaced
10890:301633755dec 10891:83af68e38be3
6 def loop(ui, loops, **opts): 6 def loop(ui, loops, **opts):
7 loops = int(loops) 7 loops = int(loops)
8 total = None 8 total = None
9 if loops >= 0: 9 if loops >= 0:
10 total = loops 10 total = loops
11 if opts.get('total', None):
12 total = int(opts.get('total'))
11 loops = abs(loops) 13 loops = abs(loops)
12 14
13 for i in range(loops): 15 for i in range(loops):
14 ui.progress('loop', i, 'loop.%d' % i, 'loopnum', total) 16 ui.progress('loop', i, 'loop.%d' % i, 'loopnum', total)
15 ui.progress('loop', None, 'loop.done', 'loopnum', total) 17 ui.progress('loop', None, 'loop.done', 'loopnum', total)
16 18
17 commands.norepo += " loop" 19 commands.norepo += " loop"
18 20
19 cmdtable = { 21 cmdtable = {
20 "loop": (loop, [], 'hg loop LOOPS'), 22 "loop": (loop, [('', 'total', '', 'override for total')],
23 'hg loop LOOPS'),
21 } 24 }
22 EOF 25 EOF
23 26
24 cat > filtercr.py <<EOF 27 cat > filtercr.py <<EOF
25 import sys, re 28 import sys, re
53 hg -y --config 'progress.format=number item-3 bar' loop 2 2>&1 | python filtercr.py 56 hg -y --config 'progress.format=number item-3 bar' loop 2 2>&1 | python filtercr.py
54 57
55 echo '% test format options and indeterminate progress' 58 echo '% test format options and indeterminate progress'
56 hg -y --config 'progress.format=number item bar' loop -- -2 2>&1 | python filtercr.py 59 hg -y --config 'progress.format=number item bar' loop -- -2 2>&1 | python filtercr.py
57 60
61 echo "% make sure things don't fall over if count > total"
62 hg -y loop --total 4 6 2>&1 | python filtercr.py
63
58 echo '% test immediate progress completion' 64 echo '% test immediate progress completion'
59 hg -y loop 0 2>&1 | python filtercr.py 65 hg -y loop 0 2>&1 | python filtercr.py