##// END OF EJS Templates
progress: fall back to indeterminate progress if position is >= total
Augie Fackler -
r10891:83af68e3 default
parent child Browse files
Show More
@@ -114,7 +114,7 b' class progbar(object):'
114 if tail:
114 if tail:
115 used += len(tail) + 1
115 used += len(tail) + 1
116 progwidth = termwidth - used - 3
116 progwidth = termwidth - used - 3
117 if total:
117 if total and pos <= total:
118 amt = pos * progwidth // total
118 amt = pos * progwidth // total
119 bar = '=' * (amt - 1)
119 bar = '=' * (amt - 1)
120 if amt > 0:
120 if amt > 0:
@@ -8,6 +8,8 b' def loop(ui, loops, **opts):'
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):
@@ -17,7 +19,8 b' def loop(ui, loops, **opts):'
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
@@ -55,5 +58,8 b" hg -y --config 'progress.format=number i"
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
@@ -17,4 +17,12 b' 1/2 p.1 [==============================='
17
17
18 0 loop.0 [ <=> ]
18 0 loop.0 [ <=> ]
19 1 loop.1 [ <=> ]
19 1 loop.1 [ <=> ]
20 % make sure things don't fall over if count > total
21
22 loop [ ] 0/4
23 loop [================> ] 1/4
24 loop [=================================> ] 2/4
25 loop [==================================================> ] 3/4
26 loop [===================================================================>] 4/4
27 loop [ <=> ] 5/4
20 % test immediate progress completion
28 % test immediate progress completion
General Comments 0
You need to be logged in to leave comments. Login now