Show More
@@ -1,403 +1,409 b'' | |||||
1 |
|
1 | |||
2 | $ cat > loop.py <<EOF |
|
2 | $ cat > loop.py <<EOF | |
3 | > from __future__ import absolute_import |
|
3 | > from __future__ import absolute_import | |
4 | > import time |
|
4 | > import time | |
5 | > from mercurial import commands, registrar |
|
5 | > from mercurial import commands, registrar | |
6 | > |
|
6 | > | |
7 | > cmdtable = {} |
|
7 | > cmdtable = {} | |
8 | > command = registrar.command(cmdtable) |
|
8 | > command = registrar.command(cmdtable) | |
9 | > |
|
9 | > | |
10 | > class incrementingtime(object): |
|
10 | > class incrementingtime(object): | |
11 | > def __init__(self): |
|
11 | > def __init__(self): | |
12 | > self._time = 0.0 |
|
12 | > self._time = 0.0 | |
13 | > def __call__(self): |
|
13 | > def __call__(self): | |
14 | > self._time += 0.25 |
|
14 | > self._time += 0.25 | |
15 | > return self._time |
|
15 | > return self._time | |
16 | > time.time = incrementingtime() |
|
16 | > time.time = incrementingtime() | |
17 | > |
|
17 | > | |
18 | > @command(b'loop', |
|
18 | > @command(b'loop', | |
19 | > [(b'', b'total', b'', b'override for total'), |
|
19 | > [(b'', b'total', b'', b'override for total'), | |
20 | > (b'', b'nested', False, b'show nested results'), |
|
20 | > (b'', b'nested', False, b'show nested results'), | |
21 | > (b'', b'parallel', False, b'show parallel sets of results'), |
|
21 | > (b'', b'parallel', False, b'show parallel sets of results'), | |
22 | > (b'', b'warn', False, b'show warning if step divisible by 3')], |
|
22 | > (b'', b'warn', False, b'show warning if step divisible by 3')], | |
23 | > b'hg loop LOOPS', |
|
23 | > b'hg loop LOOPS', | |
24 | > norepo=True) |
|
24 | > norepo=True) | |
25 | > def loop(ui, loops, **opts): |
|
25 | > def loop(ui, loops, **opts): | |
26 | > loops = int(loops) |
|
26 | > loops = int(loops) | |
27 | > total = None |
|
27 | > total = None | |
28 | > if loops >= 0: |
|
28 | > if loops >= 0: | |
29 | > total = loops |
|
29 | > total = loops | |
30 | > if opts.get('total', None): |
|
30 | > if opts.get('total', None): | |
31 | > total = int(opts.get('total')) |
|
31 | > total = int(opts.get('total')) | |
32 | > nested = False |
|
32 | > nested = False | |
33 | > if opts.get('nested', None): |
|
33 | > if opts.get('nested', None): | |
34 | > nested = True |
|
34 | > nested = True | |
35 | > loops = abs(loops) |
|
35 | > loops = abs(loops) | |
36 | > showwarn = opts.get('warn', False) |
|
36 | > showwarn = opts.get('warn', False) | |
37 | > |
|
37 | > | |
38 | > progress = ui.makeprogress(topiclabel, unit=b'loopnum', total=total) |
|
38 | > progress = ui.makeprogress(topiclabel, unit=b'loopnum', total=total) | |
39 | > other = ui.makeprogress(b'other', unit=b'othernum', total=total) |
|
39 | > other = ui.makeprogress(b'other', unit=b'othernum', total=total) | |
40 | > for i in range(loops): |
|
40 | > for i in range(loops): | |
41 | > progress.update(i, item=getloopitem(i)) |
|
41 | > progress.update(i, item=getloopitem(i)) | |
42 | > if opts.get('parallel'): |
|
42 | > if opts.get('parallel'): | |
43 | > other.update(i, item=b'other.%d' % i) |
|
43 | > other.update(i, item=b'other.%d' % i) | |
44 | > if nested: |
|
44 | > if nested: | |
45 | > nested_steps = 2 |
|
45 | > nested_steps = 2 | |
46 | > if i and i % 4 == 0: |
|
46 | > if i and i % 4 == 0: | |
47 | > nested_steps = 5 |
|
47 | > nested_steps = 5 | |
48 | > nested = ui.makeprogress(b'nested', unit=b'nestnum', |
|
48 | > nested = ui.makeprogress(b'nested', unit=b'nestnum', | |
49 | > total=nested_steps) |
|
49 | > total=nested_steps) | |
50 | > for j in range(nested_steps): |
|
50 | > for j in range(nested_steps): | |
51 | > nested.update(j, item=b'nested.%d' % j) |
|
51 | > nested.update(j, item=b'nested.%d' % j) | |
52 | > nested.complete() |
|
52 | > nested.complete() | |
53 | > if showwarn and i % 3 == 0: |
|
53 | > if showwarn and i % 3 == 0: | |
54 | > ui.warn(b'reached step %d\n' %i) |
|
54 | > ui.warn(b'reached step %d\n' %i) | |
55 | > progress.complete() |
|
55 | > progress.complete() | |
56 | > |
|
56 | > | |
57 | > topiclabel = b'loop' |
|
57 | > topiclabel = b'loop' | |
58 | > def getloopitem(i): |
|
58 | > def getloopitem(i): | |
59 | > return b'loop.%d' % i |
|
59 | > return b'loop.%d' % i | |
60 | > |
|
60 | > | |
61 | > EOF |
|
61 | > EOF | |
62 |
|
62 | |||
63 | $ cp $HGRCPATH $HGRCPATH.orig |
|
63 | $ cp $HGRCPATH $HGRCPATH.orig | |
64 | $ echo "[extensions]" >> $HGRCPATH |
|
64 | $ echo "[extensions]" >> $HGRCPATH | |
65 | $ echo "progress=" >> $HGRCPATH |
|
65 | $ echo "progress=" >> $HGRCPATH | |
66 | $ echo "loop=`pwd`/loop.py" >> $HGRCPATH |
|
66 | $ echo "loop=`pwd`/loop.py" >> $HGRCPATH | |
67 | $ echo "[progress]" >> $HGRCPATH |
|
67 | $ echo "[progress]" >> $HGRCPATH | |
68 | $ echo "format = topic bar number" >> $HGRCPATH |
|
68 | $ echo "format = topic bar number" >> $HGRCPATH | |
69 | $ echo "assume-tty=1" >> $HGRCPATH |
|
69 | $ echo "assume-tty=1" >> $HGRCPATH | |
70 | $ echo "width=60" >> $HGRCPATH |
|
70 | $ echo "width=60" >> $HGRCPATH | |
71 |
|
71 | |||
72 | test default params, display nothing because of delay |
|
72 | test default params, display nothing because of delay | |
73 |
|
73 | |||
74 | $ hg -y loop 3 |
|
74 | $ hg -y loop 3 | |
75 | $ echo "delay=0" >> $HGRCPATH |
|
75 | $ echo "delay=0" >> $HGRCPATH | |
76 | $ echo "refresh=0" >> $HGRCPATH |
|
76 | $ echo "refresh=0" >> $HGRCPATH | |
77 |
|
77 | |||
78 | test with delay=0, refresh=0 |
|
78 | test with delay=0, refresh=0 | |
79 |
|
79 | |||
80 | $ hg -y loop 3 |
|
80 | $ hg -y loop 3 | |
81 | \r (no-eol) (esc) |
|
81 | \r (no-eol) (esc) | |
82 | loop [ ] 0/3\r (no-eol) (esc) |
|
82 | loop [ ] 0/3\r (no-eol) (esc) | |
83 | loop [===============> ] 1/3\r (no-eol) (esc) |
|
83 | loop [===============> ] 1/3\r (no-eol) (esc) | |
84 | loop [===============================> ] 2/3\r (no-eol) (esc) |
|
84 | loop [===============================> ] 2/3\r (no-eol) (esc) | |
85 | \r (no-eol) (esc) |
|
85 | \r (no-eol) (esc) | |
86 | no progress with --quiet |
|
86 | no progress with --quiet | |
87 | $ hg -y loop 3 --quiet |
|
87 | $ hg -y loop 3 --quiet | |
88 |
|
88 | |||
89 | test plain mode exception |
|
89 | test plain mode exception | |
90 | $ HGPLAINEXCEPT=progress hg -y loop 1 |
|
90 | $ HGPLAINEXCEPT=progress hg -y loop 1 | |
91 | \r (no-eol) (esc) |
|
91 | \r (no-eol) (esc) | |
92 | loop [ ] 0/1\r (no-eol) (esc) |
|
92 | loop [ ] 0/1\r (no-eol) (esc) | |
93 | \r (no-eol) (esc) |
|
93 | \r (no-eol) (esc) | |
94 |
|
94 | |||
95 | test nested short-lived topics (which shouldn't display with nestdelay): |
|
95 | test nested short-lived topics (which shouldn't display with nestdelay): | |
96 |
|
96 | |||
97 | $ hg -y loop 3 --nested |
|
97 | $ hg -y loop 3 --nested | |
98 | \r (no-eol) (esc) |
|
98 | \r (no-eol) (esc) | |
99 | loop [ ] 0/3\r (no-eol) (esc) |
|
99 | loop [ ] 0/3\r (no-eol) (esc) | |
100 | loop [===============> ] 1/3\r (no-eol) (esc) |
|
100 | loop [===============> ] 1/3\r (no-eol) (esc) | |
101 | loop [===============================> ] 2/3\r (no-eol) (esc) |
|
101 | loop [===============================> ] 2/3\r (no-eol) (esc) | |
102 | \r (no-eol) (esc) |
|
102 | \r (no-eol) (esc) | |
103 |
|
103 | |||
104 | Test nested long-lived topic which has the same name as a short-lived |
|
104 | Test nested long-lived topic which has the same name as a short-lived | |
105 | peer. We shouldn't get stuck showing the short-lived inner steps, and |
|
105 | peer. We shouldn't get stuck showing the short-lived inner steps, and | |
106 | should go back to skipping the inner steps when the slow nested step |
|
106 | should go back to skipping the inner steps when the slow nested step | |
107 | finishes. |
|
107 | finishes. | |
108 |
|
108 | |||
109 | $ hg -y loop 7 --nested |
|
109 | $ hg -y loop 7 --nested | |
110 | \r (no-eol) (esc) |
|
110 | \r (no-eol) (esc) | |
111 | loop [ ] 0/7\r (no-eol) (esc) |
|
111 | loop [ ] 0/7\r (no-eol) (esc) | |
112 | loop [=====> ] 1/7\r (no-eol) (esc) |
|
112 | loop [=====> ] 1/7\r (no-eol) (esc) | |
113 | loop [============> ] 2/7\r (no-eol) (esc) |
|
113 | loop [============> ] 2/7\r (no-eol) (esc) | |
114 | loop [===================> ] 3/7\r (no-eol) (esc) |
|
114 | loop [===================> ] 3/7\r (no-eol) (esc) | |
115 | loop [==========================> ] 4/7\r (no-eol) (esc) |
|
115 | loop [==========================> ] 4/7\r (no-eol) (esc) | |
116 | nested [==========================> ] 3/5\r (no-eol) (esc) |
|
116 | nested [==========================> ] 3/5\r (no-eol) (esc) | |
117 | nested [===================================> ] 4/5\r (no-eol) (esc) |
|
117 | nested [===================================> ] 4/5\r (no-eol) (esc) | |
118 | loop [=================================> ] 5/7\r (no-eol) (esc) |
|
118 | loop [=================================> ] 5/7\r (no-eol) (esc) | |
119 | loop [========================================> ] 6/7\r (no-eol) (esc) |
|
119 | loop [========================================> ] 6/7\r (no-eol) (esc) | |
120 | \r (no-eol) (esc) |
|
120 | \r (no-eol) (esc) | |
121 |
|
121 | |||
122 |
|
122 | |||
123 | $ hg --config progress.changedelay=0 -y loop 3 --nested |
|
123 | $ hg --config progress.changedelay=0 -y loop 3 --nested | |
124 | \r (no-eol) (esc) |
|
124 | \r (no-eol) (esc) | |
125 | loop [ ] 0/3\r (no-eol) (esc) |
|
125 | loop [ ] 0/3\r (no-eol) (esc) | |
126 | nested [ ] 0/2\r (no-eol) (esc) |
|
126 | nested [ ] 0/2\r (no-eol) (esc) | |
127 | nested [======================> ] 1/2\r (no-eol) (esc) |
|
127 | nested [======================> ] 1/2\r (no-eol) (esc) | |
128 | loop [===============> ] 1/3\r (no-eol) (esc) |
|
128 | loop [===============> ] 1/3\r (no-eol) (esc) | |
129 | nested [ ] 0/2\r (no-eol) (esc) |
|
129 | nested [ ] 0/2\r (no-eol) (esc) | |
130 | nested [======================> ] 1/2\r (no-eol) (esc) |
|
130 | nested [======================> ] 1/2\r (no-eol) (esc) | |
131 | loop [===============================> ] 2/3\r (no-eol) (esc) |
|
131 | loop [===============================> ] 2/3\r (no-eol) (esc) | |
132 | nested [ ] 0/2\r (no-eol) (esc) |
|
132 | nested [ ] 0/2\r (no-eol) (esc) | |
133 | nested [======================> ] 1/2\r (no-eol) (esc) |
|
133 | nested [======================> ] 1/2\r (no-eol) (esc) | |
134 | \r (no-eol) (esc) |
|
134 | \r (no-eol) (esc) | |
135 |
|
135 | |||
136 |
|
136 | |||
137 | test two topics being printed in parallel (as when we're doing a local |
|
137 | test two topics being printed in parallel (as when we're doing a local | |
138 | --pull clone, where you get the unbundle and bundle progress at the |
|
138 | --pull clone, where you get the unbundle and bundle progress at the | |
139 | same time): |
|
139 | same time): | |
140 | $ hg loop 3 --parallel |
|
140 | $ hg loop 3 --parallel | |
141 | \r (no-eol) (esc) |
|
141 | \r (no-eol) (esc) | |
142 | loop [ ] 0/3\r (no-eol) (esc) |
|
142 | loop [ ] 0/3\r (no-eol) (esc) | |
143 | loop [===============> ] 1/3\r (no-eol) (esc) |
|
143 | loop [===============> ] 1/3\r (no-eol) (esc) | |
144 | loop [===============================> ] 2/3\r (no-eol) (esc) |
|
144 | loop [===============================> ] 2/3\r (no-eol) (esc) | |
145 | \r (no-eol) (esc) |
|
145 | \r (no-eol) (esc) | |
146 | test refresh is taken in account |
|
146 | test refresh is taken in account | |
147 |
|
147 | |||
148 | $ hg -y --config progress.refresh=100 loop 3 |
|
148 | $ hg -y --config progress.refresh=100 loop 3 | |
149 |
|
149 | |||
150 | test format options 1 |
|
150 | test format options 1 | |
151 |
|
151 | |||
152 | $ hg -y --config 'progress.format=number topic item+2' loop 2 |
|
152 | $ hg -y --config 'progress.format=number topic item+2' loop 2 | |
153 | \r (no-eol) (esc) |
|
153 | \r (no-eol) (esc) | |
154 | 0/2 loop lo\r (no-eol) (esc) |
|
154 | 0/2 loop lo\r (no-eol) (esc) | |
155 | 1/2 loop lo\r (no-eol) (esc) |
|
155 | 1/2 loop lo\r (no-eol) (esc) | |
156 | \r (no-eol) (esc) |
|
156 | \r (no-eol) (esc) | |
157 |
|
157 | |||
158 | test format options 2 |
|
158 | test format options 2 | |
159 |
|
159 | |||
160 | $ hg -y --config 'progress.format=number item-3 bar' loop 2 |
|
160 | $ hg -y --config 'progress.format=number item-3 bar' loop 2 | |
161 | \r (no-eol) (esc) |
|
161 | \r (no-eol) (esc) | |
162 | 0/2 p.0 [ ]\r (no-eol) (esc) |
|
162 | 0/2 p.0 [ ]\r (no-eol) (esc) | |
163 | 1/2 p.1 [=======================> ]\r (no-eol) (esc) |
|
163 | 1/2 p.1 [=======================> ]\r (no-eol) (esc) | |
164 | \r (no-eol) (esc) |
|
164 | \r (no-eol) (esc) | |
165 |
|
165 | |||
166 | test format options and indeterminate progress |
|
166 | test format options and indeterminate progress | |
167 |
|
167 | |||
168 | $ hg -y --config 'progress.format=number item bar' loop -- -2 |
|
168 | $ hg -y --config 'progress.format=number item bar' loop -- -2 | |
169 | \r (no-eol) (esc) |
|
169 | \r (no-eol) (esc) | |
170 | 0 loop.0 [ <=> ]\r (no-eol) (esc) |
|
170 | 0 loop.0 [ <=> ]\r (no-eol) (esc) | |
171 | 1 loop.1 [ <=> ]\r (no-eol) (esc) |
|
171 | 1 loop.1 [ <=> ]\r (no-eol) (esc) | |
172 | \r (no-eol) (esc) |
|
172 | \r (no-eol) (esc) | |
173 |
|
173 | |||
174 | make sure things don't fall over if count > total |
|
174 | make sure things don't fall over if count > total | |
175 |
|
175 | |||
176 | $ hg -y loop --total 4 6 |
|
176 | $ hg -y loop --total 4 6 | |
177 | \r (no-eol) (esc) |
|
177 | \r (no-eol) (esc) | |
178 | loop [ ] 0/4\r (no-eol) (esc) |
|
178 | loop [ ] 0/4\r (no-eol) (esc) | |
179 | loop [===========> ] 1/4\r (no-eol) (esc) |
|
179 | loop [===========> ] 1/4\r (no-eol) (esc) | |
180 | loop [=======================> ] 2/4\r (no-eol) (esc) |
|
180 | loop [=======================> ] 2/4\r (no-eol) (esc) | |
181 | loop [===================================> ] 3/4\r (no-eol) (esc) |
|
181 | loop [===================================> ] 3/4\r (no-eol) (esc) | |
182 | loop [===============================================>] 4/4\r (no-eol) (esc) |
|
182 | loop [===============================================>] 4/4\r (no-eol) (esc) | |
183 | loop [ <=> ] 5/4\r (no-eol) (esc) |
|
183 | loop [ <=> ] 5/4\r (no-eol) (esc) | |
184 | \r (no-eol) (esc) |
|
184 | \r (no-eol) (esc) | |
185 |
|
185 | |||
186 | test interaction with ui.warn |
|
186 | test interaction with ui.warn | |
187 |
|
187 | |||
188 | $ hg loop --warn 6 |
|
188 | $ hg loop --warn 6 | |
189 | \r (no-eol) (esc) |
|
189 | \r (no-eol) (esc) | |
190 | loop [ ] 0/6\r (no-eol) (esc) |
|
190 | loop [ ] 0/6\r (no-eol) (esc) | |
191 | \r (no-eol) (esc) |
|
191 | \r (no-eol) (esc) | |
192 | reached step 0 |
|
192 | reached step 0 | |
193 | \r (no-eol) (esc) |
|
193 | \r (no-eol) (esc) | |
194 | loop [=======> ] 1/6\r (no-eol) (esc) |
|
194 | loop [=======> ] 1/6\r (no-eol) (esc) | |
195 | loop [===============> ] 2/6\r (no-eol) (esc) |
|
195 | loop [===============> ] 2/6\r (no-eol) (esc) | |
196 | loop [=======================> ] 3/6\r (no-eol) (esc) |
|
196 | loop [=======================> ] 3/6\r (no-eol) (esc) | |
197 | \r (no-eol) (esc) |
|
197 | \r (no-eol) (esc) | |
198 | reached step 3 |
|
198 | reached step 3 | |
199 | \r (no-eol) (esc) |
|
199 | \r (no-eol) (esc) | |
200 | loop [===============================> ] 4/6\r (no-eol) (esc) |
|
200 | loop [===============================> ] 4/6\r (no-eol) (esc) | |
201 | loop [=======================================> ] 5/6\r (no-eol) (esc) |
|
201 | loop [=======================================> ] 5/6\r (no-eol) (esc) | |
202 | \r (no-eol) (esc) |
|
202 | \r (no-eol) (esc) | |
203 |
|
203 | |||
204 | test interaction with ui.timestamp-output |
|
204 | test interaction with ui.timestamp-output | |
205 |
|
205 | |||
|
206 | XXX: The timestamp on Windows with py2 hg is in 1970, and py3 hg is now. But | |||
|
207 | the py2/py3 checks here test the test runner, not the binary. The Windows lines | |||
|
208 | can be dropped when switching to py3-only. | |||
|
209 | ||||
206 | $ hg loop --warn --config ui.timestamp-output=true 6 |
|
210 | $ hg loop --warn --config ui.timestamp-output=true 6 | |
207 | \r (no-eol) (esc) |
|
211 | \r (no-eol) (esc) | |
208 | loop [ ] 0/6\r (no-eol) (esc) |
|
212 | loop [ ] 0/6\r (no-eol) (esc) | |
209 | \r (no-eol) (esc) |
|
213 | \r (no-eol) (esc) | |
210 | \[20[2-9][0-9]-[01][0-9]-[0-3][0-9]T[0-5][0-9]:[0-5][0-9]:[0-5][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9]\] reached step 0 (re) |
|
214 | [*T*] reached step 0 (glob) (windows !) | |
|
215 | \[20[2-9][0-9]-[01][0-9]-[0-3][0-9]T[0-5][0-9]:[0-5][0-9]:[0-5][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9]\] reached step 0 (re) (no-windows !) | |||
211 | \r (no-eol) (esc) |
|
216 | \r (no-eol) (esc) | |
212 | loop [=======> ] 1/6\r (no-eol) (esc) |
|
217 | loop [=======> ] 1/6\r (no-eol) (esc) | |
213 | loop [===============> ] 2/6\r (no-eol) (esc) |
|
218 | loop [===============> ] 2/6\r (no-eol) (esc) | |
214 | loop [=======================> ] 3/6\r (no-eol) (esc) |
|
219 | loop [=======================> ] 3/6\r (no-eol) (esc) | |
215 | \r (no-eol) (esc) |
|
220 | \r (no-eol) (esc) | |
216 | \[20[2-9][0-9]-[01][0-9]-[0-3][0-9]T[0-5][0-9]:[0-5][0-9]:[0-5][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9]\] reached step 3 (re) |
|
221 | [*T*] reached step 3 (glob) (windows !) | |
|
222 | \[20[2-9][0-9]-[01][0-9]-[0-3][0-9]T[0-5][0-9]:[0-5][0-9]:[0-5][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9]\] reached step 3 (re) (no-windows !) | |||
217 | \r (no-eol) (esc) |
|
223 | \r (no-eol) (esc) | |
218 | loop [===============================> ] 4/6\r (no-eol) (esc) |
|
224 | loop [===============================> ] 4/6\r (no-eol) (esc) | |
219 | loop [=======================================> ] 5/6\r (no-eol) (esc) |
|
225 | loop [=======================================> ] 5/6\r (no-eol) (esc) | |
220 | \r (no-eol) (esc) |
|
226 | \r (no-eol) (esc) | |
221 |
|
227 | |||
222 | test immediate progress completion |
|
228 | test immediate progress completion | |
223 |
|
229 | |||
224 | $ hg -y loop 0 |
|
230 | $ hg -y loop 0 | |
225 |
|
231 | |||
226 | test delay time estimates |
|
232 | test delay time estimates | |
227 |
|
233 | |||
228 | #if no-chg |
|
234 | #if no-chg | |
229 |
|
235 | |||
230 | $ cp $HGRCPATH.orig $HGRCPATH |
|
236 | $ cp $HGRCPATH.orig $HGRCPATH | |
231 | $ echo "[extensions]" >> $HGRCPATH |
|
237 | $ echo "[extensions]" >> $HGRCPATH | |
232 | $ echo "mocktime=$TESTDIR/mocktime.py" >> $HGRCPATH |
|
238 | $ echo "mocktime=$TESTDIR/mocktime.py" >> $HGRCPATH | |
233 | $ echo "progress=" >> $HGRCPATH |
|
239 | $ echo "progress=" >> $HGRCPATH | |
234 | $ echo "loop=`pwd`/loop.py" >> $HGRCPATH |
|
240 | $ echo "loop=`pwd`/loop.py" >> $HGRCPATH | |
235 | $ echo "[progress]" >> $HGRCPATH |
|
241 | $ echo "[progress]" >> $HGRCPATH | |
236 | $ echo "assume-tty=1" >> $HGRCPATH |
|
242 | $ echo "assume-tty=1" >> $HGRCPATH | |
237 | $ echo "delay=25" >> $HGRCPATH |
|
243 | $ echo "delay=25" >> $HGRCPATH | |
238 | $ echo "width=60" >> $HGRCPATH |
|
244 | $ echo "width=60" >> $HGRCPATH | |
239 |
|
245 | |||
240 | $ MOCKTIME=11 hg -y loop 8 |
|
246 | $ MOCKTIME=11 hg -y loop 8 | |
241 | \r (no-eol) (esc) |
|
247 | \r (no-eol) (esc) | |
242 | loop [=========> ] 2/8 1m07s\r (no-eol) (esc) |
|
248 | loop [=========> ] 2/8 1m07s\r (no-eol) (esc) | |
243 | loop [===============> ] 3/8 56s\r (no-eol) (esc) |
|
249 | loop [===============> ] 3/8 56s\r (no-eol) (esc) | |
244 | loop [=====================> ] 4/8 45s\r (no-eol) (esc) |
|
250 | loop [=====================> ] 4/8 45s\r (no-eol) (esc) | |
245 | loop [==========================> ] 5/8 34s\r (no-eol) (esc) |
|
251 | loop [==========================> ] 5/8 34s\r (no-eol) (esc) | |
246 | loop [================================> ] 6/8 23s\r (no-eol) (esc) |
|
252 | loop [================================> ] 6/8 23s\r (no-eol) (esc) | |
247 | loop [=====================================> ] 7/8 12s\r (no-eol) (esc) |
|
253 | loop [=====================================> ] 7/8 12s\r (no-eol) (esc) | |
248 | \r (no-eol) (esc) |
|
254 | \r (no-eol) (esc) | |
249 |
|
255 | |||
250 | $ MOCKTIME=10000 hg -y loop 4 |
|
256 | $ MOCKTIME=10000 hg -y loop 4 | |
251 | \r (no-eol) (esc) |
|
257 | \r (no-eol) (esc) | |
252 | loop [ ] 0/4\r (no-eol) (esc) |
|
258 | loop [ ] 0/4\r (no-eol) (esc) | |
253 | loop [=========> ] 1/4 8h21m\r (no-eol) (esc) |
|
259 | loop [=========> ] 1/4 8h21m\r (no-eol) (esc) | |
254 | loop [====================> ] 2/4 5h34m\r (no-eol) (esc) |
|
260 | loop [====================> ] 2/4 5h34m\r (no-eol) (esc) | |
255 | loop [==============================> ] 3/4 2h47m\r (no-eol) (esc) |
|
261 | loop [==============================> ] 3/4 2h47m\r (no-eol) (esc) | |
256 | \r (no-eol) (esc) |
|
262 | \r (no-eol) (esc) | |
257 |
|
263 | |||
258 | $ MOCKTIME=1000000 hg -y loop 4 |
|
264 | $ MOCKTIME=1000000 hg -y loop 4 | |
259 | \r (no-eol) (esc) |
|
265 | \r (no-eol) (esc) | |
260 | loop [ ] 0/4\r (no-eol) (esc) |
|
266 | loop [ ] 0/4\r (no-eol) (esc) | |
261 | loop [=========> ] 1/4 5w00d\r (no-eol) (esc) |
|
267 | loop [=========> ] 1/4 5w00d\r (no-eol) (esc) | |
262 | loop [====================> ] 2/4 3w03d\r (no-eol) (esc) |
|
268 | loop [====================> ] 2/4 3w03d\r (no-eol) (esc) | |
263 | loop [=============================> ] 3/4 11d14h\r (no-eol) (esc) |
|
269 | loop [=============================> ] 3/4 11d14h\r (no-eol) (esc) | |
264 | \r (no-eol) (esc) |
|
270 | \r (no-eol) (esc) | |
265 |
|
271 | |||
266 |
|
272 | |||
267 | $ MOCKTIME=14000000 hg -y loop 4 |
|
273 | $ MOCKTIME=14000000 hg -y loop 4 | |
268 | \r (no-eol) (esc) |
|
274 | \r (no-eol) (esc) | |
269 | loop [ ] 0/4\r (no-eol) (esc) |
|
275 | loop [ ] 0/4\r (no-eol) (esc) | |
270 | loop [=========> ] 1/4 1y18w\r (no-eol) (esc) |
|
276 | loop [=========> ] 1/4 1y18w\r (no-eol) (esc) | |
271 | loop [===================> ] 2/4 46w03d\r (no-eol) (esc) |
|
277 | loop [===================> ] 2/4 46w03d\r (no-eol) (esc) | |
272 | loop [=============================> ] 3/4 23w02d\r (no-eol) (esc) |
|
278 | loop [=============================> ] 3/4 23w02d\r (no-eol) (esc) | |
273 | \r (no-eol) (esc) |
|
279 | \r (no-eol) (esc) | |
274 |
|
280 | |||
275 | Non-linear progress: |
|
281 | Non-linear progress: | |
276 |
|
282 | |||
277 | $ MOCKTIME='20 20 20 20 20 20 20 20 20 20 500 500 500 500 500 20 20 20 20 20' hg -y loop 20 |
|
283 | $ MOCKTIME='20 20 20 20 20 20 20 20 20 20 500 500 500 500 500 20 20 20 20 20' hg -y loop 20 | |
278 | \r (no-eol) (esc) |
|
284 | \r (no-eol) (esc) | |
279 | loop [=> ] 1/20 6m21s\r (no-eol) (esc) |
|
285 | loop [=> ] 1/20 6m21s\r (no-eol) (esc) | |
280 | loop [===> ] 2/20 6m01s\r (no-eol) (esc) |
|
286 | loop [===> ] 2/20 6m01s\r (no-eol) (esc) | |
281 | loop [=====> ] 3/20 5m41s\r (no-eol) (esc) |
|
287 | loop [=====> ] 3/20 5m41s\r (no-eol) (esc) | |
282 | loop [=======> ] 4/20 5m21s\r (no-eol) (esc) |
|
288 | loop [=======> ] 4/20 5m21s\r (no-eol) (esc) | |
283 | loop [=========> ] 5/20 5m01s\r (no-eol) (esc) |
|
289 | loop [=========> ] 5/20 5m01s\r (no-eol) (esc) | |
284 | loop [===========> ] 6/20 4m41s\r (no-eol) (esc) |
|
290 | loop [===========> ] 6/20 4m41s\r (no-eol) (esc) | |
285 | loop [=============> ] 7/20 4m21s\r (no-eol) (esc) |
|
291 | loop [=============> ] 7/20 4m21s\r (no-eol) (esc) | |
286 | loop [===============> ] 8/20 4m01s\r (no-eol) (esc) |
|
292 | loop [===============> ] 8/20 4m01s\r (no-eol) (esc) | |
287 | loop [================> ] 9/20 25m40s\r (no-eol) (esc) |
|
293 | loop [================> ] 9/20 25m40s\r (no-eol) (esc) | |
288 | loop [===================> ] 10/20 1h06m\r (no-eol) (esc) |
|
294 | loop [===================> ] 10/20 1h06m\r (no-eol) (esc) | |
289 | loop [=====================> ] 11/20 1h13m\r (no-eol) (esc) |
|
295 | loop [=====================> ] 11/20 1h13m\r (no-eol) (esc) | |
290 | loop [=======================> ] 12/20 1h07m\r (no-eol) (esc) |
|
296 | loop [=======================> ] 12/20 1h07m\r (no-eol) (esc) | |
291 | loop [========================> ] 13/20 58m19s\r (no-eol) (esc) |
|
297 | loop [========================> ] 13/20 58m19s\r (no-eol) (esc) | |
292 | loop [===========================> ] 14/20 7m09s\r (no-eol) (esc) |
|
298 | loop [===========================> ] 14/20 7m09s\r (no-eol) (esc) | |
293 | loop [=============================> ] 15/20 3m38s\r (no-eol) (esc) |
|
299 | loop [=============================> ] 15/20 3m38s\r (no-eol) (esc) | |
294 | loop [===============================> ] 16/20 2m15s\r (no-eol) (esc) |
|
300 | loop [===============================> ] 16/20 2m15s\r (no-eol) (esc) | |
295 | loop [=================================> ] 17/20 1m27s\r (no-eol) (esc) |
|
301 | loop [=================================> ] 17/20 1m27s\r (no-eol) (esc) | |
296 | loop [====================================> ] 18/20 52s\r (no-eol) (esc) |
|
302 | loop [====================================> ] 18/20 52s\r (no-eol) (esc) | |
297 | loop [======================================> ] 19/20 25s\r (no-eol) (esc) |
|
303 | loop [======================================> ] 19/20 25s\r (no-eol) (esc) | |
298 | \r (no-eol) (esc) |
|
304 | \r (no-eol) (esc) | |
299 |
|
305 | |||
300 | Time estimates should not fail when there's no end point: |
|
306 | Time estimates should not fail when there's no end point: | |
301 | $ MOCKTIME=11 hg -y loop -- -4 |
|
307 | $ MOCKTIME=11 hg -y loop -- -4 | |
302 | \r (no-eol) (esc) |
|
308 | \r (no-eol) (esc) | |
303 | loop [ <=> ] 2\r (no-eol) (esc) |
|
309 | loop [ <=> ] 2\r (no-eol) (esc) | |
304 | loop [ <=> ] 3\r (no-eol) (esc) |
|
310 | loop [ <=> ] 3\r (no-eol) (esc) | |
305 | \r (no-eol) (esc) |
|
311 | \r (no-eol) (esc) | |
306 |
|
312 | |||
307 | #endif |
|
313 | #endif | |
308 |
|
314 | |||
309 | test line trimming by '[progress] width', when progress topic contains |
|
315 | test line trimming by '[progress] width', when progress topic contains | |
310 | multi-byte characters, of which length of byte sequence and columns in |
|
316 | multi-byte characters, of which length of byte sequence and columns in | |
311 | display are different from each other. |
|
317 | display are different from each other. | |
312 |
|
318 | |||
313 | $ cp $HGRCPATH.orig $HGRCPATH |
|
319 | $ cp $HGRCPATH.orig $HGRCPATH | |
314 | $ cat >> $HGRCPATH <<EOF |
|
320 | $ cat >> $HGRCPATH <<EOF | |
315 | > [extensions] |
|
321 | > [extensions] | |
316 | > progress= |
|
322 | > progress= | |
317 | > loop=`pwd`/loop.py |
|
323 | > loop=`pwd`/loop.py | |
318 | > [progress] |
|
324 | > [progress] | |
319 | > assume-tty = 1 |
|
325 | > assume-tty = 1 | |
320 | > delay = 0 |
|
326 | > delay = 0 | |
321 | > refresh = 0 |
|
327 | > refresh = 0 | |
322 | > EOF |
|
328 | > EOF | |
323 |
|
329 | |||
324 | $ rm -f loop.pyc |
|
330 | $ rm -f loop.pyc | |
325 | $ cat >> loop.py <<EOF |
|
331 | $ cat >> loop.py <<EOF | |
326 | > # use non-ascii characters as topic label of progress |
|
332 | > # use non-ascii characters as topic label of progress | |
327 | > # 2 x 4 = 8 columns, but 3 x 4 = 12 bytes |
|
333 | > # 2 x 4 = 8 columns, but 3 x 4 = 12 bytes | |
328 | > topiclabel = u'\u3042\u3044\u3046\u3048'.encode('utf-8') |
|
334 | > topiclabel = u'\u3042\u3044\u3046\u3048'.encode('utf-8') | |
329 | > EOF |
|
335 | > EOF | |
330 |
|
336 | |||
331 | $ cat >> $HGRCPATH <<EOF |
|
337 | $ cat >> $HGRCPATH <<EOF | |
332 | > [progress] |
|
338 | > [progress] | |
333 | > format = topic number |
|
339 | > format = topic number | |
334 | > width= 12 |
|
340 | > width= 12 | |
335 | > EOF |
|
341 | > EOF | |
336 |
|
342 | |||
337 | $ hg --encoding utf-8 -y loop --total 3 3 |
|
343 | $ hg --encoding utf-8 -y loop --total 3 3 | |
338 | \r (no-eol) (esc) |
|
344 | \r (no-eol) (esc) | |
339 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 0/3\r (no-eol) (esc) |
|
345 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 0/3\r (no-eol) (esc) | |
340 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 1/3\r (no-eol) (esc) |
|
346 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 1/3\r (no-eol) (esc) | |
341 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 2/3\r (no-eol) (esc) |
|
347 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 2/3\r (no-eol) (esc) | |
342 | \r (no-eol) (esc) |
|
348 | \r (no-eol) (esc) | |
343 |
|
349 | |||
344 | test calculation of bar width, when progress topic contains multi-byte |
|
350 | test calculation of bar width, when progress topic contains multi-byte | |
345 | characters, of which length of byte sequence and columns in display |
|
351 | characters, of which length of byte sequence and columns in display | |
346 | are different from each other. |
|
352 | are different from each other. | |
347 |
|
353 | |||
348 | $ cat >> $HGRCPATH <<EOF |
|
354 | $ cat >> $HGRCPATH <<EOF | |
349 | > [progress] |
|
355 | > [progress] | |
350 | > format = topic bar |
|
356 | > format = topic bar | |
351 | > width= 21 |
|
357 | > width= 21 | |
352 | > # progwidth should be 9 (= 21 - (8+1) - 3) |
|
358 | > # progwidth should be 9 (= 21 - (8+1) - 3) | |
353 | > EOF |
|
359 | > EOF | |
354 |
|
360 | |||
355 | $ hg --encoding utf-8 -y loop --total 3 3 |
|
361 | $ hg --encoding utf-8 -y loop --total 3 3 | |
356 | \r (no-eol) (esc) |
|
362 | \r (no-eol) (esc) | |
357 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 [ ]\r (no-eol) (esc) |
|
363 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 [ ]\r (no-eol) (esc) | |
358 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 [==> ]\r (no-eol) (esc) |
|
364 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 [==> ]\r (no-eol) (esc) | |
359 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 [=====> ]\r (no-eol) (esc) |
|
365 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 [=====> ]\r (no-eol) (esc) | |
360 | \r (no-eol) (esc) |
|
366 | \r (no-eol) (esc) | |
361 |
|
367 | |||
362 | test trimming progress items, when they contain multi-byte characters, |
|
368 | test trimming progress items, when they contain multi-byte characters, | |
363 | of which length of byte sequence and columns in display are different |
|
369 | of which length of byte sequence and columns in display are different | |
364 | from each other. |
|
370 | from each other. | |
365 |
|
371 | |||
366 | $ rm -f loop.pyc |
|
372 | $ rm -f loop.pyc | |
367 | $ rm -Rf __pycache__ |
|
373 | $ rm -Rf __pycache__ | |
368 | $ cat >> loop.py <<EOF |
|
374 | $ cat >> loop.py <<EOF | |
369 | > # use non-ascii characters as loop items of progress |
|
375 | > # use non-ascii characters as loop items of progress | |
370 | > loopitems = [ |
|
376 | > loopitems = [ | |
371 | > u'\u3042\u3044'.encode('utf-8'), # 2 x 2 = 4 columns |
|
377 | > u'\u3042\u3044'.encode('utf-8'), # 2 x 2 = 4 columns | |
372 | > u'\u3042\u3044\u3046'.encode('utf-8'), # 2 x 3 = 6 columns |
|
378 | > u'\u3042\u3044\u3046'.encode('utf-8'), # 2 x 3 = 6 columns | |
373 | > u'\u3042\u3044\u3046\u3048'.encode('utf-8'), # 2 x 4 = 8 columns |
|
379 | > u'\u3042\u3044\u3046\u3048'.encode('utf-8'), # 2 x 4 = 8 columns | |
374 | > ] |
|
380 | > ] | |
375 | > def getloopitem(i): |
|
381 | > def getloopitem(i): | |
376 | > return loopitems[i % len(loopitems)] |
|
382 | > return loopitems[i % len(loopitems)] | |
377 | > EOF |
|
383 | > EOF | |
378 |
|
384 | |||
379 | $ cat >> $HGRCPATH <<EOF |
|
385 | $ cat >> $HGRCPATH <<EOF | |
380 | > [progress] |
|
386 | > [progress] | |
381 | > # trim at tail side |
|
387 | > # trim at tail side | |
382 | > format = item+6 |
|
388 | > format = item+6 | |
383 | > EOF |
|
389 | > EOF | |
384 |
|
390 | |||
385 | $ hg --encoding utf-8 -y loop --total 3 3 |
|
391 | $ hg --encoding utf-8 -y loop --total 3 3 | |
386 | \r (no-eol) (esc) |
|
392 | \r (no-eol) (esc) | |
387 | \xe3\x81\x82\xe3\x81\x84 \r (no-eol) (esc) |
|
393 | \xe3\x81\x82\xe3\x81\x84 \r (no-eol) (esc) | |
388 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\r (no-eol) (esc) |
|
394 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\r (no-eol) (esc) | |
389 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\r (no-eol) (esc) |
|
395 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\r (no-eol) (esc) | |
390 | \r (no-eol) (esc) |
|
396 | \r (no-eol) (esc) | |
391 |
|
397 | |||
392 | $ cat >> $HGRCPATH <<EOF |
|
398 | $ cat >> $HGRCPATH <<EOF | |
393 | > [progress] |
|
399 | > [progress] | |
394 | > # trim at left side |
|
400 | > # trim at left side | |
395 | > format = item-6 |
|
401 | > format = item-6 | |
396 | > EOF |
|
402 | > EOF | |
397 |
|
403 | |||
398 | $ hg --encoding utf-8 -y loop --total 3 3 |
|
404 | $ hg --encoding utf-8 -y loop --total 3 3 | |
399 | \r (no-eol) (esc) |
|
405 | \r (no-eol) (esc) | |
400 | \xe3\x81\x82\xe3\x81\x84 \r (no-eol) (esc) |
|
406 | \xe3\x81\x82\xe3\x81\x84 \r (no-eol) (esc) | |
401 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\r (no-eol) (esc) |
|
407 | \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\r (no-eol) (esc) | |
402 | \xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\r (no-eol) (esc) |
|
408 | \xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\r (no-eol) (esc) | |
403 | \r (no-eol) (esc) |
|
409 | \r (no-eol) (esc) |
General Comments 0
You need to be logged in to leave comments.
Login now