Show More
@@ -27,6 +27,9 b' The following settings are available::' | |||||
27 |
|
27 | |||
28 | [progress] |
|
28 | [progress] | |
29 | delay = 3 # number of seconds (float) before showing the progress bar |
|
29 | delay = 3 # number of seconds (float) before showing the progress bar | |
|
30 | changedelay = 1 # changedelay: minimum delay before showing a new topic. | |||
|
31 | # If set to less than 3 * refresh, that value will | |||
|
32 | # be used instead. | |||
30 | refresh = 0.1 # time in seconds between refreshes of the progress bar |
|
33 | refresh = 0.1 # time in seconds between refreshes of the progress bar | |
31 | format = topic bar number estimate # format of the progress bar |
|
34 | format = topic bar number estimate # format of the progress bar | |
32 | width = <none> # if set, the maximum width of the progress information |
|
35 | width = <none> # if set, the maximum width of the progress information | |
@@ -105,9 +108,13 b' class progbar(object):' | |||||
105 | self.printed = False |
|
108 | self.printed = False | |
106 | self.lastprint = time.time() + float(self.ui.config( |
|
109 | self.lastprint = time.time() + float(self.ui.config( | |
107 | 'progress', 'delay', default=3)) |
|
110 | 'progress', 'delay', default=3)) | |
|
111 | self.lasttopic = None | |||
108 | self.indetcount = 0 |
|
112 | self.indetcount = 0 | |
109 | self.refresh = float(self.ui.config( |
|
113 | self.refresh = float(self.ui.config( | |
110 | 'progress', 'refresh', default=0.1)) |
|
114 | 'progress', 'refresh', default=0.1)) | |
|
115 | self.changedelay = max(3 * self.refresh, | |||
|
116 | float(self.ui.config( | |||
|
117 | 'progress', 'changedelay', default=1))) | |||
111 | self.order = self.ui.configlist( |
|
118 | self.order = self.ui.configlist( | |
112 | 'progress', 'format', |
|
119 | 'progress', 'format', | |
113 | default=['topic', 'bar', 'number', 'estimate']) |
|
120 | default=['topic', 'bar', 'number', 'estimate']) | |
@@ -184,6 +191,7 b' class progbar(object):' | |||||
184 | else: |
|
191 | else: | |
185 | out = spacejoin(head, tail) |
|
192 | out = spacejoin(head, tail) | |
186 | sys.stderr.write('\r' + out[:termwidth]) |
|
193 | sys.stderr.write('\r' + out[:termwidth]) | |
|
194 | self.lasttopic = topic | |||
187 | sys.stderr.flush() |
|
195 | sys.stderr.flush() | |
188 |
|
196 | |||
189 | def clear(self): |
|
197 | def clear(self): | |
@@ -248,8 +256,13 b' class progbar(object):' | |||||
248 | self.topics.append(topic) |
|
256 | self.topics.append(topic) | |
249 | self.topicstates[topic] = pos, item, unit, total |
|
257 | self.topicstates[topic] = pos, item, unit, total | |
250 | if now - self.lastprint >= self.refresh and self.topics: |
|
258 | if now - self.lastprint >= self.refresh and self.topics: | |
251 | self.lastprint = now |
|
259 | if (self.lasttopic is None # first time we printed | |
252 | self.show(now, topic, *self.topicstates[topic]) |
|
260 | # not a topic change | |
|
261 | or topic == self.lasttopic | |||
|
262 | # it's been long enough we should print anyway | |||
|
263 | or now - self.lastprint >= self.changedelay): | |||
|
264 | self.lastprint = now | |||
|
265 | self.show(now, topic, *self.topicstates[topic]) | |||
253 |
|
266 | |||
254 | _singleton = None |
|
267 | _singleton = None | |
255 |
|
268 |
@@ -167,6 +167,7 b" Test convert progress bar'" | |||||
167 | > [progress] |
|
167 | > [progress] | |
168 | > assume-tty = 1 |
|
168 | > assume-tty = 1 | |
169 | > delay = 0 |
|
169 | > delay = 0 | |
|
170 | > changedelay = 0 | |||
170 | > format = topic bar number |
|
171 | > format = topic bar number | |
171 | > refresh = 0 |
|
172 | > refresh = 0 | |
172 | > width = 60 |
|
173 | > width = 60 |
@@ -9,16 +9,28 b'' | |||||
9 | > total = loops |
|
9 | > total = loops | |
10 | > if opts.get('total', None): |
|
10 | > if opts.get('total', None): | |
11 | > total = int(opts.get('total')) |
|
11 | > total = int(opts.get('total')) | |
|
12 | > nested = False | |||
|
13 | > if opts.get('nested', None): | |||
|
14 | > nested = True | |||
12 | > loops = abs(loops) |
|
15 | > loops = abs(loops) | |
13 | > |
|
16 | > | |
14 | > for i in range(loops): |
|
17 | > for i in range(loops): | |
15 | > ui.progress('loop', i, 'loop.%d' % i, 'loopnum', total) |
|
18 | > ui.progress('loop', i, 'loop.%d' % i, 'loopnum', total) | |
|
19 | > if opts.get('parallel'): | |||
|
20 | > ui.progress('other', i, 'other.%d' % i, 'othernum', total) | |||
|
21 | > if nested: | |||
|
22 | > for j in range(2): | |||
|
23 | > ui.progress('nested', j, 'nested.%d' % j, 'nestnum', 2) | |||
|
24 | > ui.progress('nested', None, 'nested.done', 'nestnum', 2) | |||
16 | > ui.progress('loop', None, 'loop.done', 'loopnum', total) |
|
25 | > ui.progress('loop', None, 'loop.done', 'loopnum', total) | |
17 | > |
|
26 | > | |
18 | > commands.norepo += " loop" |
|
27 | > commands.norepo += " loop" | |
19 | > |
|
28 | > | |
20 | > cmdtable = { |
|
29 | > cmdtable = { | |
21 |
> "loop": (loop, [('', 'total', '', 'override for total') |
|
30 | > "loop": (loop, [('', 'total', '', 'override for total'), | |
|
31 | > ('', 'nested', False, 'show nested results'), | |||
|
32 | > ('', 'parallel', False, 'show parallel sets of results'), | |||
|
33 | > ], | |||
22 | > 'hg loop LOOPS'), |
|
34 | > 'hg loop LOOPS'), | |
23 | > } |
|
35 | > } | |
24 | > EOF |
|
36 | > EOF | |
@@ -47,6 +59,42 b' test with delay=0, refresh=0' | |||||
47 | loop [===============================> ] 2/3 |
|
59 | loop [===============================> ] 2/3 | |
48 | \r (esc) |
|
60 | \r (esc) | |
49 |
|
61 | |||
|
62 | ||||
|
63 | test nested short-lived topics (which shouldn't display with nestdelay): | |||
|
64 | ||||
|
65 | $ hg -y loop 3 --nested 2>&1 | \ | |||
|
66 | > python $TESTDIR/filtercr.py | |||
|
67 | ||||
|
68 | loop [ ] 0/3 | |||
|
69 | loop [===============> ] 1/3 | |||
|
70 | loop [===============================> ] 2/3 | |||
|
71 | \r (esc) | |||
|
72 | ||||
|
73 | ||||
|
74 | $ hg --config progress.changedelay=0 -y loop 3 --nested 2>&1 | \ | |||
|
75 | > python $TESTDIR/filtercr.py | |||
|
76 | ||||
|
77 | loop [ ] 0/3 | |||
|
78 | nested [ ] 0/2 | |||
|
79 | nested [======================> ] 1/2 | |||
|
80 | loop [===============> ] 1/3 | |||
|
81 | nested [ ] 0/2 | |||
|
82 | nested [======================> ] 1/2 | |||
|
83 | loop [===============================> ] 2/3 | |||
|
84 | nested [ ] 0/2 | |||
|
85 | nested [======================> ] 1/2 | |||
|
86 | \r (esc) | |||
|
87 | ||||
|
88 | ||||
|
89 | test two topics being printed in parallel (as when we're doing a local | |||
|
90 | --pull clone, where you get the unbundle and bundle progress at the | |||
|
91 | same time): | |||
|
92 | $ hg loop 3 --parallel 2>&1 | python $TESTDIR/filtercr.py | |||
|
93 | ||||
|
94 | loop [ ] 0/3 | |||
|
95 | loop [===============> ] 1/3 | |||
|
96 | loop [===============================> ] 2/3 | |||
|
97 | \r (esc) | |||
50 | test refresh is taken in account |
|
98 | test refresh is taken in account | |
51 |
|
99 | |||
52 | $ hg -y --config progress.refresh=100 loop 3 2>&1 | $TESTDIR/filtercr.py |
|
100 | $ hg -y --config progress.refresh=100 loop 3 2>&1 | $TESTDIR/filtercr.py |
General Comments 0
You need to be logged in to leave comments.
Login now