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

hggtk/recovery: do not start command while one still running

Changeset d24c108f6ae0

Parent 216dabd6cba8

by TK Soh

Changes to one file · Browse files at d24c108f6ae0 Showing diff from parent 216dabd6cba8 Diff from another changeset...

Change 1 of 5 Show Entire File hggtk/​recovery.py Stacked
 
34
35
36
 
37
38
39
 
101
102
103
104
105
106
107
 
108
109
110
111
 
 
 
 
 
 
112
113
114
 
167
168
169
 
 
 
 
 
170
171
172
 
183
184
185
 
 
 
 
 
 
186
187
188
 
202
203
204
205
 
 
 
206
207
208
209
210
211
212
213
214
215
 
34
35
36
37
38
39
40
 
102
103
104
 
 
 
 
105
106
107
 
 
108
109
110
111
112
113
114
115
116
 
169
170
171
172
173
174
175
176
177
178
179
 
190
191
192
193
194
195
196
197
198
199
200
201
 
215
216
217
 
218
219
220
221
222
223
224
225
 
 
226
227
228
@@ -34,6 +34,7 @@
  self.root = root   self.cwd = cwd   self.selected_path = None + self.hgthread = None   self.connect('delete-event', self._delete)     self.set_default_size(600, 400) @@ -101,14 +102,15 @@
  vbox.pack_start(self.stbar, False, False, 2)     def _close_clicked(self, *args): - if threading.activeCount() != 1: - error_dialog(self, "Can't close now", "command is running") - else: - gtk.main_quit() + self._do_close()     def _delete(self, widget, event): - if threading.activeCount() != 1: - return True + self._do_close() + return True + + def _do_close(self): + if self._cmd_running(): + error_dialog(self, "Can't close now", "command is running")   else:   gtk.main_quit()   @@ -167,6 +169,11 @@
  self._stop_button.set_sensitive(False)     def _exec_cmd(self, cmd, postfunc=None): + if self._cmd_running(): + error_dialog(self, "Can't run now", + "Pleas try again after the previous command is completed") + return +   self._stop_button.set_sensitive(True)   cmdline = cmd   cmdline.append('--verbose') @@ -183,6 +190,12 @@
  self.stbar.begin()   self.stbar.set_status_text('hg ' + ' '.join(cmdline))   + def _cmd_running(self): + if self.hgthread and self.hgthread.isAlive(): + return True + else: + return False +   def write(self, msg, append=True):   msg = toutf(msg)   if append: @@ -202,14 +215,14 @@
  self.write(msg)   except Queue.Empty:   pass - if threading.activeCount() == 1: + 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("[command interrupted]")   return False # Stop polling this function - else: - return True    def run(cwd='', root='', **opts):   dialog = RecoveryDialog(cwd, root)