[PATCH] progress: fall back to indeterminate progress if position is >= total
Augie Fackler
durin42 at gmail.com
Thu Apr 8 15:05:20 CDT 2010
# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1270757040 18000
# Node ID cdc6f9b05ccbb1bafb90eafd42440b3c498bcff6
# Parent 3f30190781a38abc8a05aca3be3d8a9d8092700a
progress: fall back to indeterminate progress if position is >= total
diff --git a/hgext/progress.py b/hgext/progress.py
--- a/hgext/progress.py
+++ b/hgext/progress.py
@@ -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 --git a/tests/test-progress b/tests/test-progress
--- a/tests/test-progress
+++ b/tests/test-progress
@@ -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 --git a/tests/test-progress.out b/tests/test-progress.out
--- a/tests/test-progress.out
+++ b/tests/test-progress.out
@@ -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
More information about the Mercurial-devel
mailing list