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