Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.4rc2, 0.4rc3, and 0.4rc4

hggtk: add support for stopping various hg commands

Changeset f4799554efd4

Parent 604dc351ce76

by TK Soh

Changes to 3 files · Browse files at f4799554efd4 Showing diff from parent 604dc351ce76 Diff from another changeset...

Change 1 of 4 Show Entire File hggtk/​hgcmd.py Stacked
 
31
32
33
 
 
 
 
34
35
36
37
38
 
 
39
40
41
 
82
83
84
 
 
 
85
86
87
 
93
94
95
 
96
97
98
 
120
121
122
 
123
 
 
124
125
126
 
31
32
33
34
35
36
37
38
39
40
 
 
41
42
43
44
45
 
86
87
88
89
90
91
92
93
94
 
100
101
102
103
104
105
106
 
128
129
130
131
132
133
134
135
136
137
@@ -31,11 +31,15 @@
    # construct dialog   self.set_default_size(width, height) + + self._button_stop = gtk.Button("Stop") + self._button_stop.connect('clicked', self._on_stop_clicked) + self.action_area.pack_start(self._button_stop)     self._button_ok = gtk.Button("Close")   self._button_ok.connect('clicked', self._on_ok_clicked) - self.action_area.pack_end(self._button_ok) - + self.action_area.pack_start(self._button_ok) +   self.connect('delete-event', self._delete)   self.connect('response', self._response)   @@ -82,6 +86,9 @@
  """ Ok button clicked handler. """   self.response(gtk.RESPONSE_ACCEPT)   + def _on_stop_clicked(self, button): + self.hgthread.terminate() +   def _delete(self, widget, event):   return True   @@ -93,6 +100,7 @@
  self.hgthread = HgThread(self.cmdline[1:])   self.hgthread.start()   self._button_ok.set_sensitive(False) + self._button_stop.set_sensitive(True)   gobject.timeout_add(10, self.process_queue)     def write(self, msg, append=True): @@ -120,7 +128,10 @@
  self.update_progress()   if not self.hgthread.isAlive():   self._button_ok.set_sensitive(True) + self._button_stop.set_sensitive(False)   self.returncode = self.hgthread.return_code() + if self.returncode is None: + self.write("[command interrupted]")   return False # Stop polling this function   else:   return True
Change 1 of 3 Show Entire File hggtk/​hglib.py Stacked
 
2
3
4
5
 
6
7
8
 
110
111
112
113
 
114
115
116
 
126
127
128
129
 
130
131
132
 
2
3
4
 
5
6
7
8
 
110
111
112
 
113
114
115
116
 
126
127
128
 
129
130
131
132
@@ -2,7 +2,7 @@
 import os.path  import sys  import traceback -import threading +import threading, thread2  import Queue  from mercurial import hg, ui, util, extensions, commands, hook  from mercurial.repo import RepoError @@ -110,7 +110,7 @@
  traceback.print_exc()   return True   -class HgThread(threading.Thread): +class HgThread(thread2.Thread):   '''   Run an hg command in a background thread, implies output is being   sent to a rendered text buffer interactively and requests for @@ -126,7 +126,7 @@
  self.ret = None   self.postfunc = postfunc   self.parent = parent - threading.Thread.__init__(self) + thread2.Thread.__init__(self)     def getqueue(self):   return self.outputq
Change 1 of 4 Show Entire File hggtk/​synch.py Stacked
 
54
55
56
 
 
 
57
58
59
 
83
84
85
 
 
86
87
88
 
407
408
409
 
 
 
 
 
410
 
 
411
412
413
 
472
473
474
 
 
 
475
476
477
 
54
55
56
57
58
59
60
61
62
 
86
87
88
89
90
91
92
93
 
412
413
414
415
416
417
418
419
420
421
422
423
424
425
 
484
485
486
487
488
489
490
491
492
@@ -54,6 +54,9 @@
  # toolbar   self.tbar = gtk.Toolbar()   self.tips = gtk.Tooltips() + self._stop_button = self._toolbutton(gtk.STOCK_STOP, + 'Stop', self._stop_clicked, tip='Stop the hg operation') + self._stop_button.set_sensitive(False)   tbuttons = [   self._toolbutton(gtk.STOCK_GO_DOWN,   'Incoming', @@ -83,6 +86,8 @@
  tip='Email local outgoing changes to'   ' one or more recipients'),   gtk.SeparatorToolItem(), + self._stop_button, + gtk.SeparatorToolItem(),   self._toolbutton(gtk.STOCK_PREFERENCES,   'Configure',   self._conf_clicked, @@ -407,7 +412,14 @@
  cmd.append('--newest-first')   self._exec_cmd(cmd)   + def _stop_clicked(self, toolbutton, data=None): + if self.hgthread and self.hgthread.isAlive(): + self.hgthread.terminate() + self._stop_button.set_sensitive(False) +   def _exec_cmd(self, cmd): + self._stop_button.set_sensitive(True) +   proxy_host = ui.ui().config('http_proxy', 'host', '')   use_proxy = self._use_proxy.get_active()   text_entry = self._pathbox.get_child() @@ -472,6 +484,9 @@
  # Update button states   self.update_buttons()   self.stbar.end() + self._stop_button.set_sensitive(False) + if self.hgthread.return_code() is None: + self.write("[command interrupted]")   return False # Stop polling this function   else:   return True