Show More
@@ -1,65 +1,100 b'' | |||||
1 | #!/bin/sh |
|
|||
2 |
|
||||
3 | cat > loop.py <<EOF |
|
|||
4 | from mercurial import commands |
|
|||
5 |
|
||||
6 | def loop(ui, loops, **opts): |
|
|||
7 | loops = int(loops) |
|
|||
8 | total = None |
|
|||
9 | if loops >= 0: |
|
|||
10 | total = loops |
|
|||
11 | if opts.get('total', None): |
|
|||
12 | total = int(opts.get('total')) |
|
|||
13 | loops = abs(loops) |
|
|||
14 |
|
1 | |||
15 | for i in range(loops): |
|
2 | $ cat > loop.py <<EOF | |
16 | ui.progress('loop', i, 'loop.%d' % i, 'loopnum', total) |
|
3 | > from mercurial import commands | |
17 | ui.progress('loop', None, 'loop.done', 'loopnum', total) |
|
4 | > | |
18 |
|
5 | > def loop(ui, loops, **opts): | ||
19 | commands.norepo += " loop" |
|
6 | > loops = int(loops) | |
|
7 | > total = None | |||
|
8 | > if loops >= 0: | |||
|
9 | > total = loops | |||
|
10 | > if opts.get('total', None): | |||
|
11 | > total = int(opts.get('total')) | |||
|
12 | > loops = abs(loops) | |||
|
13 | > | |||
|
14 | > for i in range(loops): | |||
|
15 | > ui.progress('loop', i, 'loop.%d' % i, 'loopnum', total) | |||
|
16 | > ui.progress('loop', None, 'loop.done', 'loopnum', total) | |||
|
17 | > | |||
|
18 | > commands.norepo += " loop" | |||
|
19 | > | |||
|
20 | > cmdtable = { | |||
|
21 | > "loop": (loop, [('', 'total', '', 'override for total')], | |||
|
22 | > 'hg loop LOOPS'), | |||
|
23 | > } | |||
|
24 | > EOF | |||
20 |
|
25 | |||
21 | cmdtable = { |
|
26 | $ cat > filtercr.py <<EOF | |
22 | "loop": (loop, [('', 'total', '', 'override for total')], |
|
27 | > import sys, re | |
23 | 'hg loop LOOPS'), |
|
28 | > for line in sys.stdin: | |
24 | } |
|
29 | > line = re.sub(r'\r+[^\n]', lambda m: '\n' + m.group()[-1:], line) | |
25 | EOF |
|
30 | > sys.stdout.write(line) | |
|
31 | ||||
|
32 | > EOF | |||
26 |
|
33 | |||
27 | cat > filtercr.py <<EOF |
|
34 | $ echo "[extensions]" >> $HGRCPATH | |
28 | import sys, re |
|
35 | $ echo "progress=" >> $HGRCPATH | |
29 | for line in sys.stdin: |
|
36 | $ echo "loop=`pwd`/loop.py" >> $HGRCPATH | |
30 | line = re.sub(r'\r+[^\n]', lambda m: '\n' + m.group()[-1:], line) |
|
37 | $ echo "[progress]" >> $HGRCPATH | |
31 | sys.stdout.write(line) |
|
38 | $ echo "assume-tty=1" >> $HGRCPATH | |
32 | EOF |
|
39 | ||
|
40 | test default params, display nothing because of delay | |||
|
41 | ||||
|
42 | $ hg -y loop 3 2>&1 | python filtercr.py | |||
|
43 | ||||
|
44 | $ echo "delay=0" >> $HGRCPATH | |||
|
45 | $ echo "refresh=0" >> $HGRCPATH | |||
|
46 | ||||
|
47 | test with delay=0, refresh=0 | |||
33 |
|
48 | |||
34 | echo "[extensions]" >> $HGRCPATH |
|
49 | $ hg -y loop 3 2>&1 | python filtercr.py | |
35 | echo "progress=" >> $HGRCPATH |
|
50 | ||
36 | echo "loop=`pwd`/loop.py" >> $HGRCPATH |
|
51 | loop [ ] 0/3 | |
37 | echo "[progress]" >> $HGRCPATH |
|
52 | loop [=====================> ] 1/3 | |
38 | echo "assume-tty=1" >> $HGRCPATH |
|
53 | loop [============================================> ] 2/3 | |
|
54 | ||||
|
55 | ||||
|
56 | test refresh is taken in account | |||
39 |
|
57 | |||
40 | echo '% test default params, display nothing because of delay' |
|
58 | $ hg -y --config progress.refresh=100 loop 3 2>&1 | python filtercr.py | |
41 | hg -y loop 3 2>&1 | python filtercr.py |
|
59 | ||
|
60 | ||||
|
61 | test format options 1 | |||
42 |
|
62 | |||
43 | echo "delay=0" >> $HGRCPATH |
|
63 | $ hg -y --config 'progress.format=number topic item+2' loop 2 2>&1 | python filtercr.py | |
44 | echo "refresh=0" >> $HGRCPATH |
|
64 | ||
|
65 | 0/2 loop lo | |||
|
66 | 1/2 loop lo | |||
|
67 | ||||
45 |
|
68 | |||
46 | echo '% test with delay=0, refresh=0' |
|
69 | test format options 2 | |
47 | hg -y loop 3 2>&1 | python filtercr.py |
|
|||
48 |
|
70 | |||
49 | echo '% test refresh is taken in account' |
|
71 | $ hg -y --config 'progress.format=number item-3 bar' loop 2 2>&1 | python filtercr.py | |
50 | hg -y --config progress.refresh=100 loop 3 2>&1 | python filtercr.py |
|
72 | ||
|
73 | 0/2 p.0 [ ] | |||
|
74 | 1/2 p.1 [=================================> ] | |||
|
75 | ||||
51 |
|
76 | |||
52 | echo '% test format options 1' |
|
77 | test format options and indeterminate progress | |
53 | hg -y --config 'progress.format=number topic item+2' loop 2 2>&1 | python filtercr.py |
|
|||
54 |
|
78 | |||
55 | echo '% test format options 2' |
|
79 | $ hg -y --config 'progress.format=number item 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 |
|
80 | ||
|
81 | 0 loop.0 [ <=> ] | |||
|
82 | 1 loop.1 [ <=> ] | |||
|
83 | ||||
57 |
|
84 | |||
58 | echo '% test format options and indeterminate progress' |
|
85 | make sure things don't fall over if count > total | |
59 | hg -y --config 'progress.format=number item bar' loop -- -2 2>&1 | python filtercr.py |
|
|||
60 |
|
86 | |||
61 | echo "% make sure things don't fall over if count > total" |
|
87 | $ hg -y loop --total 4 6 2>&1 | python filtercr.py | |
62 | hg -y loop --total 4 6 2>&1 | python filtercr.py |
|
88 | ||
|
89 | loop [ ] 0/4 | |||
|
90 | loop [================> ] 1/4 | |||
|
91 | loop [=================================> ] 2/4 | |||
|
92 | loop [==================================================> ] 3/4 | |||
|
93 | loop [===================================================================>] 4/4 | |||
|
94 | loop [ <=> ] 5/4 | |||
|
95 | ||||
63 |
|
96 | |||
64 |
|
|
97 | test immediate progress completion | |
65 | hg -y loop 0 2>&1 | python filtercr.py |
|
98 | ||
|
99 | $ hg -y loop 0 2>&1 | python filtercr.py | |||
|
100 |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now