Changeset f4799554efd4…
Parent 604dc351ce76…
by
Changes to 3 files · Browse files at f4799554efd4 Showing diff from parent 604dc351ce76 Diff from another changeset...
@@ -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
|
@@ -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
|
@@ -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
|
Loading...