author | Matt Mackall <mpm@selenic.com> |
Mon, 05 Apr 2010 15:25:08 -0500 | |
changeset 10848 | 01346cea5485 |
parent 10788 | ca6ba6cac6cd |
child 10891 | 83af68e38be3 |
permissions | -rwxr-xr-x |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
1 |
#!/bin/sh |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
2 |
|
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
3 |
cat > loop.py <<EOF |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
4 |
from mercurial import commands |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
5 |
|
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
6 |
def loop(ui, loops, **opts): |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
7 |
loops = int(loops) |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
8 |
total = None |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
9 |
if loops >= 0: |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
10 |
total = loops |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
11 |
loops = abs(loops) |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
12 |
|
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
13 |
for i in range(loops): |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
14 |
ui.progress('loop', i, 'loop.%d' % i, 'loopnum', total) |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
15 |
ui.progress('loop', None, 'loop.done', 'loopnum', total) |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
16 |
|
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
17 |
commands.norepo += " loop" |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
18 |
|
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
19 |
cmdtable = { |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
20 |
"loop": (loop, [], 'hg loop LOOPS'), |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
21 |
} |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
22 |
EOF |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
23 |
|
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
24 |
cat > filtercr.py <<EOF |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
25 |
import sys, re |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
26 |
for line in sys.stdin: |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
27 |
line = re.sub(r'\r+[^\n]', lambda m: '\n' + m.group()[-1:], line) |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
28 |
sys.stdout.write(line) |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
29 |
EOF |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
30 |
|
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
31 |
echo "[extensions]" >> $HGRCPATH |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
32 |
echo "progress=" >> $HGRCPATH |
10775
c52057614c72
Tests with spaces in paths
Mads Kiilerich <mads@kiilerich.com>
parents:
10465
diff
changeset
|
33 |
echo "loop=`pwd`/loop.py" >> $HGRCPATH |
10788
ca6ba6cac6cd
progress: use stderr instead of stdout; check stderr.isatty()
Augie Fackler <durin42@gmail.com>
parents:
10775
diff
changeset
|
34 |
echo "[progress]" >> $HGRCPATH |
ca6ba6cac6cd
progress: use stderr instead of stdout; check stderr.isatty()
Augie Fackler <durin42@gmail.com>
parents:
10775
diff
changeset
|
35 |
echo "assume-tty=1" >> $HGRCPATH |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
36 |
|
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
37 |
echo '% test default params, display nothing because of delay' |
10788
ca6ba6cac6cd
progress: use stderr instead of stdout; check stderr.isatty()
Augie Fackler <durin42@gmail.com>
parents:
10775
diff
changeset
|
38 |
hg -y loop 3 2>&1 | python filtercr.py |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
39 |
|
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
40 |
echo "delay=0" >> $HGRCPATH |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
41 |
echo "refresh=0" >> $HGRCPATH |
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
42 |
|
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
43 |
echo '% test with delay=0, refresh=0' |
10788
ca6ba6cac6cd
progress: use stderr instead of stdout; check stderr.isatty()
Augie Fackler <durin42@gmail.com>
parents:
10775
diff
changeset
|
44 |
hg -y loop 3 2>&1 | python filtercr.py |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
45 |
|
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
46 |
echo '% test refresh is taken in account' |
10788
ca6ba6cac6cd
progress: use stderr instead of stdout; check stderr.isatty()
Augie Fackler <durin42@gmail.com>
parents:
10775
diff
changeset
|
47 |
hg -y --config progress.refresh=100 loop 3 2>&1 | python filtercr.py |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
48 |
|
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
49 |
echo '% test format options 1' |
10788
ca6ba6cac6cd
progress: use stderr instead of stdout; check stderr.isatty()
Augie Fackler <durin42@gmail.com>
parents:
10775
diff
changeset
|
50 |
hg -y --config 'progress.format=number topic item+2' loop 2 2>&1 | python filtercr.py |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
51 |
|
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
52 |
echo '% test format options 2' |
10788
ca6ba6cac6cd
progress: use stderr instead of stdout; check stderr.isatty()
Augie Fackler <durin42@gmail.com>
parents:
10775
diff
changeset
|
53 |
hg -y --config 'progress.format=number item-3 bar' loop 2 2>&1 | python filtercr.py |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
54 |
|
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
55 |
echo '% test format options and indeterminate progress' |
10788
ca6ba6cac6cd
progress: use stderr instead of stdout; check stderr.isatty()
Augie Fackler <durin42@gmail.com>
parents:
10775
diff
changeset
|
56 |
hg -y --config 'progress.format=number item bar' loop -- -2 2>&1 | python filtercr.py |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
57 |
|
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
58 |
echo '% test immediate progress completion' |
10788
ca6ba6cac6cd
progress: use stderr instead of stdout; check stderr.isatty()
Augie Fackler <durin42@gmail.com>
parents:
10775
diff
changeset
|
59 |
hg -y loop 0 2>&1 | python filtercr.py |