##// END OF EJS Templates
progress: react more reasonably to nested progress topics...
Augie Fackler -
r13130:f139f34b default
parent child Browse files
Show More
@@ -61,6 +61,7 b' class progbar(object):'
61 61
62 62 def resetstate(self):
63 63 self.topics = []
64 self.topicstates = {}
64 65 self.printed = False
65 66 self.lastprint = time.time() + float(self.ui.config(
66 67 'progress', 'delay', default=3))
@@ -161,17 +162,24 b' class progbar(object):'
161 162
162 163 def progress(self, topic, pos, item='', unit='', total=None):
163 164 if pos is None:
164 if self.topics and self.topics[-1] == topic and self.printed:
165 self.topicstates.pop(topic, None)
166 # reset the progress bar if this is the outermost topic
167 if self.topics and self.topics[0] == topic and self.printed:
165 168 self.complete()
166 169 self.resetstate()
170 # truncate the list of topics assuming all topics within
171 # this one are also closed
172 if topic in self.topics:
173 self.topics = self.topics[:self.topics.index(topic)]
167 174 else:
168 175 if topic not in self.topics:
169 176 self.topics.append(topic)
170 177 now = time.time()
171 if (now - self.lastprint >= self.refresh
172 and topic == self.topics[-1]):
178 self.topicstates[topic] = pos, item, unit, total
179 if now - self.lastprint >= self.refresh and self.topics:
173 180 self.lastprint = now
174 self.show(topic, pos, item, unit, total)
181 current = self.topics[-1]
182 self.show(current, *self.topicstates[current])
175 183
176 184 def uisetup(ui):
177 185 class progressui(ui.__class__):
@@ -196,13 +196,11 b" Test convert progress bar'"
196 196
197 197 converting [=======> ] 1/7
198 198 scanning paths [ ] 0/1
199
200 199 getting files [==========================================================>] 1/1
201 200
202 201 converting [================> ] 2/7
203 202 scanning paths [ ] 0/2
204 203 scanning paths [============================> ] 1/2
205
206 204 getting files [=============> ] 1/4
207 205 getting files [============================> ] 2/4
208 206 getting files [===========================================> ] 3/4
@@ -210,19 +208,16 b" Test convert progress bar'"
210 208
211 209 converting [=========================> ] 3/7
212 210 scanning paths [ ] 0/1
213
214 211 getting files [==========================================================>] 1/1
215 212
216 213 converting [==================================> ] 4/7
217 214 scanning paths [ ] 0/1
218
219 215 getting files [==========================================================>] 1/1
220 216
221 217 converting [===========================================> ] 5/7
222 218 scanning paths [ ] 0/3
223 219 scanning paths [==================> ] 1/3
224 220 scanning paths [=====================================> ] 2/3
225
226 221 getting files [======> ] 1/8
227 222 getting files [=============> ] 2/8
228 223 getting files [=====================> ] 3/8
@@ -234,7 +229,6 b" Test convert progress bar'"
234 229
235 230 converting [====================================================> ] 6/7
236 231 scanning paths [ ] 0/1
237
238 232 getting files [======> ] 1/8
239 233 getting files [=============> ] 2/8
240 234 getting files [=====================> ] 3/8
General Comments 0
You need to be logged in to leave comments. Login now