Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0.2, 1.0.3, and 1.0.4

stable recovery: hook up progress bar API

Closes #1158

Changeset fb198eea62e0

Parent 51697d14bf32

by Steve Borho

Changes to one file · Browse files at fb198eea62e0 Showing diff from parent 51697d14bf32 Diff from another changeset...

 
29
30
31
 
 
32
33
34
 
90
91
92
93
94
 
 
 
 
 
 
95
96
97
 
175
176
177
178
179
 
 
 
180
181
182
 
214
215
216
217
 
218
219
220
221
222
223
224
225
226
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
228
 
29
30
31
32
33
34
35
36
 
92
93
94
 
 
95
96
97
98
99
100
101
102
103
 
181
182
183
 
 
184
185
186
187
188
189
 
221
222
223
 
224
225
226
227
 
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
@@ -29,6 +29,8 @@
  self.set_default_size(600, 400)   self.connect('delete-event', self._delete)   self.hgthread = None + self.inprogress = False + self.last_pbar_update = 0     try:   repo = hg.repository(ui.ui(), path=paths.find_root()) @@ -90,8 +92,12 @@
  foreground=gtklib.DRED)   vbox.pack_start(scrolledwindow, True, True)   - self.stbar = statusbar.StatusBar() - vbox.pack_start(self.stbar, False, False, 2) + self.progstat = gtk.Label() + vbox.pack_start(self.progstat, False, False, 0) + self.progstat.set_alignment(0, 0.5) + self.progstat.set_ellipsize(pango.ELLIPSIZE_END) + self.pbar = gtk.ProgressBar() + vbox.pack_start(self.pbar, False, False, 2)     def _delete(self, widget, event):   if not self.should_live(): @@ -175,8 +181,9 @@
  gobject.timeout_add(10, self.process_queue)   self.hgthread = hgthread.HgThread(cmdline, postfunc)   self.hgthread.start() - self.stbar.begin() - self.stbar.set_text('hg ' + ' '.join(cmdline)) + self.pbar.set_text('hg ' + ' '.join(cmdline)) + self.inprogress = True + self.pbar.show()     def _cmd_running(self):   if self.hgthread and self.hgthread.isAlive(): @@ -214,15 +221,63 @@
  self.write_err(msg)   except Queue.Empty:   pass - + self.update_progress()   if self._cmd_running():   return True   else: - self.stbar.end()   self._stop_button.set_sensitive(False)   if self.hgthread.return_code() is None:   self.write_err(_('[command interrupted]'))   return False # Stop polling this function   + def clear_progress(self): + self.pbar.set_fraction(0) + self.pbar.set_text('') + self.progstat.set_text('') + self.inprogress = False + + def update_progress(self): + if not self.hgthread.isAlive(): + self.clear_progress() + return + + data = None + while self.hgthread.getprogqueue().qsize(): + try: + data = self.hgthread.getprogqueue().get_nowait() + except Queue.Empty: + pass + counting = False + if data: + topic, item, pos, total, unit = data + if pos is None: + self.clear_progress() + return + if total is None: + count = '%d' % pos + counting = True + else: + self.pbar.set_fraction(float(pos) / float(total)) + count = '%d / %d' % (pos, total) + if unit: + count += ' ' + unit + self.pbar.set_text(count) + if item: + status = '%s: %s' % (topic, item) + else: + status = _('Status: %s') % topic + self.progstat.set_text(status) + if self.progstat.get_property('visible') is False: + self.progstat.show() + self.inprogress = True + + if not self.inprogress or counting: + # pulse the progress bar every ~100ms + tm = shlib.get_system_times()[4] + if tm - self.last_pbar_update < 0.100: + return + self.last_pbar_update = tm + self.pbar.pulse() +  def run(ui, *pats, **opts):   return RecoveryDialog()