##// END OF EJS Templates
progress: add a changedelay to prevent parallel topics from flapping (issue2698)...
Augie Fackler -
r14838:5d261fd0 default
parent child Browse files
Show More
@@ -27,6 +27,9 b' The following settings are available::'
27 27
28 28 [progress]
29 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 33 refresh = 0.1 # time in seconds between refreshes of the progress bar
31 34 format = topic bar number estimate # format of the progress bar
32 35 width = <none> # if set, the maximum width of the progress information
@@ -105,9 +108,13 b' class progbar(object):'
105 108 self.printed = False
106 109 self.lastprint = time.time() + float(self.ui.config(
107 110 'progress', 'delay', default=3))
111 self.lasttopic = None
108 112 self.indetcount = 0
109 113 self.refresh = float(self.ui.config(
110 114 'progress', 'refresh', default=0.1))
115 self.changedelay = max(3 * self.refresh,
116 float(self.ui.config(
117 'progress', 'changedelay', default=1)))
111 118 self.order = self.ui.configlist(
112 119 'progress', 'format',
113 120 default=['topic', 'bar', 'number', 'estimate'])
@@ -184,6 +191,7 b' class progbar(object):'
184 191 else:
185 192 out = spacejoin(head, tail)
186 193 sys.stderr.write('\r' + out[:termwidth])
194 self.lasttopic = topic
187 195 sys.stderr.flush()
188 196
189 197 def clear(self):
@@ -248,6 +256,11 b' class progbar(object):'
248 256 self.topics.append(topic)
249 257 self.topicstates[topic] = pos, item, unit, total
250 258 if now - self.lastprint >= self.refresh and self.topics:
259 if (self.lasttopic is None # first time we printed
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):
251 264 self.lastprint = now
252 265 self.show(now, topic, *self.topicstates[topic])
253 266
@@ -167,6 +167,7 b" Test convert progress bar'"
167 167 > [progress]
168 168 > assume-tty = 1
169 169 > delay = 0
170 > changedelay = 0
170 171 > format = topic bar number
171 172 > refresh = 0
172 173 > width = 60
@@ -9,16 +9,28 b''
9 9 > total = loops
10 10 > if opts.get('total', None):
11 11 > total = int(opts.get('total'))
12 > nested = False
13 > if opts.get('nested', None):
14 > nested = True
12 15 > loops = abs(loops)
13 16 >
14 17 > for i in range(loops):
15 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 25 > ui.progress('loop', None, 'loop.done', 'loopnum', total)
17 26 >
18 27 > commands.norepo += " loop"
19 28 >
20 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 34 > 'hg loop LOOPS'),
23 35 > }
24 36 > EOF
@@ -47,6 +59,42 b' test with delay=0, refresh=0'
47 59 loop [===============================> ] 2/3
48 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 98 test refresh is taken in account
51 99
52 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