Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

hgqt: CmdThread commandFinished is now a simple int

-1 implies an interruption or exception
0 implies success
>0 implies normal Mercurial failure codes

Changeset fe38c01bfcf8

Parent 62323d56b25a

by Steve Borho

Changes to 14 files · Browse files at fe38c01bfcf8 Showing diff from parent 62323d56b25a Diff from another changeset...

 
349
350
351
352
353
 
 
354
355
356
 
349
350
351
 
 
352
353
354
355
356
@@ -349,8 +349,8 @@
  self.cancel_btn.setShown(True)   self.detail_btn.setShown(True)   - def command_finished(self, wrapper): - if wrapper.data is not 0 or self.cmd.is_show_output()\ + def command_finished(self, ret): + if ret is not 0 or self.cmd.is_show_output()\   or self.keep_open_chk.isChecked():   if not self.cmd.is_show_output():   self.detail_btn.click()
 
160
161
162
163
 
164
165
 
166
167
168
 
160
161
162
 
163
164
 
165
166
167
168
@@ -160,9 +160,9 @@
  self.cancel_btn.setShown(True)   self.detail_btn.setShown(True)   - def command_finished(self, wrapper): + def command_finished(self, ret):   self.repo.decrementBusyCount() - if wrapper.data is not 0 or self.cmd.is_show_output(): + if ret is not 0 or self.cmd.is_show_output():   self.detail_btn.setChecked(True)   self.close_btn.setShown(True)   self.close_btn.setAutoDefault(True)
 
20
21
22
23
24
25
 
26
27
28
 
113
114
115
 
116
117
118
 
275
276
277
278
279
280
281
282
283
284
 
 
285
286
287
 
20
21
22
 
 
 
23
24
25
26
 
111
112
113
114
115
116
117
 
274
275
276
 
 
 
 
 
 
 
277
278
279
280
281
@@ -20,9 +20,7 @@
   class CloneDialog(QDialog):   - cmdfinished = pyqtSignal( - int # status (0: succeeded, -1: failed) - ) + cmdfinished = pyqtSignal(int)     def __init__(self, args=None, opts={}, parent=None):   super(CloneDialog, self).__init__(parent) @@ -113,6 +111,7 @@
  self.cmd = cmdui.Widget()   self.cmd.commandStarted.connect(self.command_started)   self.cmd.commandFinished.connect(self.command_finished) + self.cmd.commandFinished.connect(self.cmdfinished)   self.cmd.commandCanceling.connect(self.command_canceling)   box.addWidget(self.cmd)   @@ -275,13 +274,8 @@
  self.cancel_btn.setShown(True)   self.detail_btn.setShown(True)   - def command_finished(self, wrapper): - if wrapper.data is 0: - res = 0 - else: - res = -1 - self.cmdfinished.emit(res) - if wrapper.data is not 0 or self.cmd.is_show_output(): + def command_finished(self, ret): + if ret is not 0 or self.cmd.is_show_output():   self.detail_btn.setChecked(True)   self.close_btn.setShown(True)   self.close_btn.setAutoDefault(True)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
 
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
 
 
 
341
342
343
 
344
345
346
347
348
349
 
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
 
 
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
 
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
 
 
 
509
510
511
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
 
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
 
 
 
336
337
338
339
340
 
341
342
343
344
345
346
 
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
 
 
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
 
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
 
 
 
504
505
506
507
508
 
509
 # cmdui.py - A widget to execute Mercurial command for TortoiseHg  #  # Copyright 2010 Yuki KODAMA <endflow.net@gmail.com>  #  # This software may be used and distributed according to the terms of the  # GNU General Public License version 2, incorporated herein by reference.    from PyQt4.QtCore import *  from PyQt4.QtGui import *    from tortoisehg.util import hglib  from tortoisehg.hgqt.i18n import _, localgettext  from tortoisehg.hgqt import qtlib, thread    local = localgettext()    def startProgress(topic, status):   topic, item, pos, total, unit = topic, '...', status, None, None   return thread.DataWrapper((topic, item, pos, total, unit))    def stopProgress(topic):   topic, item, pos, total, unit = topic, None, None, None, None   return thread.DataWrapper((topic, item, pos, total, unit))    class ProgressMonitor(QWidget):   'Progress bar for use in workbench status bar'   def __init__(self, topic, parent):   super(ProgressMonitor, self).__init__(parent=parent)     hbox = QHBoxLayout()   hbox.setContentsMargins(*(0,)*4)   self.setLayout(hbox)   self.idle = False     self.pbar = QProgressBar()   self.pbar.setTextVisible(False)   self.pbar.setMinimum(0)   hbox.addWidget(self.pbar)     self.topic = QLabel(topic)   hbox.addWidget(self.topic, 0)     self.status = QLabel()   hbox.addWidget(self.status, 1)     self.pbar.setMaximum(100)   self.pbar.reset()   self.status.setText('')     def clear(self):   self.pbar.setMinimum(0)   self.pbar.setMaximum(100)   self.pbar.setValue(100)   self.status.setText('')   self.idle = True     def setcounts(self, cur, max):   self.pbar.setMaximum(max)   self.pbar.setValue(cur)     def unknown(self):   self.pbar.setMinimum(0)   self.pbar.setMaximum(0)      class ThgStatusBar(QStatusBar):   def __init__(self, parent=None):   QStatusBar.__init__(self, parent=parent)   self.topics = {}   self.lbl = QLabel()   self.addWidget(self.lbl)     @pyqtSlot(unicode)   def showMessage(self, ustr):   self.lbl.setText(ustr)     def clear(self):   keys = self.topics.keys()   for key in keys:   pm = self.topics[key]   self.removeWidget(pm)   del self.topics[key]     @pyqtSlot(thread.DataWrapper)   def progress(self, wrapper, root=None):   'Progress signal received from repowidget'   topic, item, pos, total, unit = wrapper.data   # topic is current operation   # pos is the current numeric position (revision, bytes)   # item is a non-numeric marker of current position (current file)   # unit is a string label   # total is the highest expected pos   # All topics should be marked closed by setting pos to None     if topic is None:   # special progress report, close all pbars for repo   for key in self.topics:   if root is None or key[0] == root:   pm = self.topics[key]   self.removeWidget(pm)   del self.topics[key]   return     if root:   key = (root, topic)   else:   key = topic   if pos is None or (not pos and not total):   if key in self.topics:   pm = self.topics[key]   self.removeWidget(pm)   del self.topics[key]   return   if key not in self.topics:   pm = ProgressMonitor(topic, self)   pm.setMaximumHeight(self.lbl.sizeHint().height())   self.addWidget(pm)   self.topics[key] = pm   else:   pm = self.topics[key]   if total:   fmt = '%s / %s ' % (str(pos), str(total))   if unit:   fmt += unit   pm.status.setText(fmt)   pm.setcounts(pos, total)   else:   if item:   item = hglib.tounicode(item)[-30:]   pm.status.setText('%s %s' % (str(pos), item))   pm.unknown()      class Core(QObject):   """Core functionality for running Mercurial command.   Do not attempt to instantiate and use this directly.   """     commandStarted = pyqtSignal() - commandFinished = pyqtSignal(thread.DataWrapper) + commandFinished = pyqtSignal(int)   commandCanceling = pyqtSignal()     output = pyqtSignal(thread.DataWrapper)   progress = pyqtSignal(thread.DataWrapper)     def __init__(self, useInternal, parent):   super(Core, self).__init__()     self.thread = None   self.stbar = None   self.queue = []   self.display = None   self.internallog = useInternal   self.parent = parent   if useInternal:   self.output_text = QPlainTextEdit()   self.output_text.setReadOnly(True)   self.output_text.setMaximumBlockCount(1024)   self.output_text.setWordWrapMode(QTextOption.NoWrap)     ### Public Methods ###     def run(self, cmdline, *cmdlines, **opts):   '''Execute or queue Mercurial command'''   self.display = opts.get('display')   self.queue.append(cmdline)   if len(cmdlines):   self.queue.extend(cmdlines)   if not self.is_running():   self.run_next()     def cancel(self):   '''Cancel running Mercurial command'''   if self.is_running():   self.thread.abort()   self.commandCanceling.emit()     def set_stbar(self, stbar):   self.stbar = stbar     def is_running(self):   return bool(self.thread and self.thread.isRunning())     def get_rawoutput(self):   if self.thread:   return ''.join(self.thread.rawoutput)   else:   return ''     ### Private Method ###     def run_next(self):   try:   cmdline = self.queue.pop(0)   self.thread = thread.CmdThread(cmdline, self.display, self.parent)   except IndexError:   return False     self.thread.started.connect(self.command_started)   self.thread.commandFinished.connect(self.command_finished)     self.thread.outputReceived.connect(self.output)   self.thread.errorReceived.connect(self.output)   self.thread.progressReceived.connect(self.progress)     if self.internallog:   self.thread.outputReceived.connect(self.output_received)   self.thread.errorReceived.connect(self.output_received)     if self.stbar:   self.thread.progressReceived.connect(self.stbar.progress)     self.thread.start()   return True     def append_output(self, msg, style=''):   msg = msg.replace('\n', '<br />')   cursor = self.output_text.textCursor()   cursor.movePosition(QTextCursor.End)   cursor.insertHtml('<font style="%s">%s</font>' % (style, msg))   max = self.output_text.verticalScrollBar().maximum()   self.output_text.verticalScrollBar().setSliderPosition(max)     def clear_output(self):   if self.internallog:   self.output_text.clear()     ### Signal Handlers ###     @pyqtSlot()   def command_started(self):   if self.stbar:   self.stbar.showMessage(_('Running...'))     self.commandStarted.emit()   - @pyqtSlot(thread.DataWrapper) - def command_finished(self, wrapper): - ret = wrapper.data - + @pyqtSlot(int) + def command_finished(self, ret):   if self.stbar:   if ret is None:   self.stbar.clear()   if self.thread.abortbyuser:   status = _('Terminated by user')   else:   status = _('Terminated')   else:   status = _('Finished')   self.stbar.showMessage(status)     self.display = None   if ret == 0 and self.run_next():   return # run next command     # Emit 'close all progress bars' signal   self.progress.emit(thread.DataWrapper((None,)*5)) - self.commandFinished.emit(wrapper) + self.commandFinished.emit(ret)     @pyqtSlot()   def command_canceling(self):   if self.stbar:   self.stbar.showMessage(_('Canceling...'))   self.stbar.clear()     self.commandCanceling.emit()     @pyqtSlot(thread.DataWrapper)   def output_received(self, wrapper):   msg, label = wrapper.data   msg = hglib.tounicode(msg)   msg = Qt.escape(msg)   style = qtlib.geteffect(label)   self.append_output(msg, style)      class Widget(QWidget):   """An embeddable widget for running Mercurial command"""     commandStarted = pyqtSignal() - commandFinished = pyqtSignal(thread.DataWrapper) + commandFinished = pyqtSignal(int)   commandCanceling = pyqtSignal()     output = pyqtSignal(thread.DataWrapper)   progress = pyqtSignal(thread.DataWrapper)   makeLogVisible = pyqtSignal(bool)     def __init__(self, useInternal=True, parent=None):   super(Widget, self).__init__()     self.internallog = useInternal   self.core = Core(useInternal, parent)   self.core.commandStarted.connect(self.commandStarted)   self.core.commandFinished.connect(self.command_finished)   self.core.commandCanceling.connect(self.commandCanceling)   self.core.output.connect(self.output)   self.core.progress.connect(self.progress)   if not useInternal:   return     vbox = QVBoxLayout()   vbox.setSpacing(4)   vbox.setContentsMargins(*(1,)*4)     # command output area   self.core.output_text.setHidden(True)   vbox.addWidget(self.core.output_text, 1)     ## status and progress labels   self.stbar = ThgStatusBar()   self.stbar.setSizeGripEnabled(False)   self.core.set_stbar(self.stbar)   vbox.addWidget(self.stbar)     # widget setting   self.setLayout(vbox)     ### Public Methods ###     def run(self, cmdline, *args, **opts):   self.core.run(cmdline, *args, **opts)     def cancel(self):   self.core.cancel()     def show_output(self, visible):   if self.internallog:   self.core.output_text.setShown(visible)     def is_show_output(self):   if self.internallog:   return self.core.output_text.isVisible()   else:   return False     ### Signal Handler ###   - @pyqtSlot(thread.DataWrapper) - def command_finished(self, wrapper): - if wrapper.data is None: + @pyqtSlot(int) + def command_finished(self, ret): + if ret == -1:   self.makeLogVisible.emit(True)   self.show_output(True) - self.commandFinished.emit(wrapper) + self.commandFinished.emit(ret)    class Dialog(QDialog):   """A dialog for running random Mercurial command"""     commandStarted = pyqtSignal() - commandFinished = pyqtSignal(thread.DataWrapper) + commandFinished = pyqtSignal(int)   commandCanceling = pyqtSignal()     def __init__(self, cmdline, parent=None, finishfunc=None):   super(Dialog, self).__init__(parent)   self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)     self.finishfunc = finishfunc     self.core = Core(True, self)   self.core.commandStarted.connect(self.commandStarted)   self.core.commandFinished.connect(self.command_finished)   self.core.commandCanceling.connect(self.commandCanceling)     vbox = QVBoxLayout()   vbox.setSpacing(4)   vbox.setContentsMargins(*(1,)*4)     # command output area   vbox.addWidget(self.core.output_text, 1)     ## status and progress labels   self.stbar = ThgStatusBar()   self.stbar.setSizeGripEnabled(False)   self.core.set_stbar(self.stbar)   vbox.addWidget(self.stbar)     # bottom buttons   buttons = QDialogButtonBox()   self.cancel_btn = buttons.addButton(QDialogButtonBox.Cancel)   self.cancel_btn.clicked.connect(self.cancel_clicked)   self.close_btn = buttons.addButton(QDialogButtonBox.Close)   self.close_btn.clicked.connect(self.reject)   self.detail_btn = buttons.addButton(_('Detail'),   QDialogButtonBox.ResetRole)   self.detail_btn.setAutoDefault(False)   self.detail_btn.setCheckable(True)   self.detail_btn.setChecked(True)   self.detail_btn.toggled.connect(self.show_output)   vbox.addWidget(buttons)     self.setLayout(vbox)   self.setWindowTitle(_('TortoiseHg Command Dialog'))   self.resize(540, 420)     # prepare to show   self.close_btn.setHidden(True)     # start command   self.core.run(cmdline)     def show_output(self, visible):   """show/hide command output"""   self.core.output_text.setVisible(visible)   self.detail_btn.setChecked(visible)     # workaround to adjust only window height   self.setMinimumWidth(self.width())   self.adjustSize()   self.setMinimumWidth(0)     ### Private Method ###     def reject(self):   if self.core.is_running():   ret = QMessageBox.question(self, _('Confirm Exit'), _('Mercurial'   ' command is still running.\nAre you sure you want'   ' to terminate?'), QMessageBox.Yes | QMessageBox.No,   QMessageBox.No)   if ret == QMessageBox.Yes:   self.cancel_clicked()     # don't close dialog   return     # close dialog   if self.core.thread.ret == 0:   self.accept() # means command successfully finished   else:   super(Dialog, self).reject()     ### Signal Handlers ###     @pyqtSlot()   def cancel_clicked(self):   self.core.cancel()   - @pyqtSlot(thread.DataWrapper) - def command_finished(self, wrapper): + @pyqtSlot(int) + def command_finished(self, ret):   self.cancel_btn.setHidden(True)   self.close_btn.setShown(True)   self.close_btn.setFocus()   if self.finishfunc:   self.finishfunc()     @pyqtSlot()   def command_canceling(self):   self.cancel_btn.setDisabled(True)    class Runner(QObject):   """A component for running Mercurial command without UI     This command runner doesn't show any UI element unless it gets a warning   or an error while the command is running. Once an error or a warning is   received, it pops-up a small dialog which contains the command log.   """     commandStarted = pyqtSignal() - commandFinished = pyqtSignal(thread.DataWrapper) + commandFinished = pyqtSignal(int)   commandCanceling = pyqtSignal()     output = pyqtSignal(thread.DataWrapper)   progress = pyqtSignal(thread.DataWrapper)   makeLogVisible = pyqtSignal(bool)     def __init__(self, title=_('TortoiseHg'), useInternal=True, parent=None):   super(Runner, self).__init__()     self.internallog = useInternal   self.title = title   self.parent = parent     self.core = Core(useInternal, parent)   self.core.commandStarted.connect(self.commandStarted)   self.core.commandFinished.connect(self.command_finished)   self.core.commandCanceling.connect(self.commandCanceling)     self.core.output.connect(self.output)   self.core.progress.connect(self.progress)     if useInternal:   self.core.output_text.setMinimumSize(460, 320)     ### Public Methods ###     def run(self, cmdline, *args, **opts):   self.core.run(cmdline, *args, **opts)     def cancel(self):   self.core.cancel()     def show_output(self, visible=True):   if not self.internallog:   return   if not hasattr(self, 'dlg'):   self.dlg = QDialog(self.parent)   self.dlg.setWindowTitle(self.title)   flags = self.dlg.windowFlags() & ~Qt.WindowContextHelpButtonHint   self.dlg.setWindowFlags(flags)   box = QVBoxLayout()   box.setContentsMargins(*(0,)*4)   box.addWidget(self.core.output_text)   self.dlg.setLayout(box)   self.dlg.setVisible(visible)     ### Signal Handler ###   - @pyqtSlot(thread.DataWrapper) - def command_finished(self, wrapper): - if wrapper.data != 0: + @pyqtSlot(int) + def command_finished(self, ret): + if ret != 0:   self.makeLogVisible.emit(True)   self.show_output() - self.commandFinished.emit(wrapper) + self.commandFinished.emit(ret)
 
581
582
583
584
 
585
586
 
587
588
589
 
581
582
583
 
584
585
 
586
587
588
589
@@ -581,9 +581,9 @@
  repo.incrementBusyCount()   self.runner.run(*commandlines)   - def commandFinished(self, wrapper): + def commandFinished(self, ret):   self.repo.decrementBusyCount() - if not wrapper.data: + if ret == 0:   self.addMessageToHistory()   if not self.qref:   self.msgte.clear()
 
175
176
177
178
 
179
180
181
 
369
370
371
372
373
 
 
374
375
376
 
390
391
392
393
 
394
395
 
396
397
398
 
415
416
417
418
 
419
420
 
421
422
423
 
432
433
434
435
 
436
437
 
438
439
440
 
612
613
614
615
616
 
 
617
618
619
 
175
176
177
 
178
179
180
181
 
369
370
371
 
 
372
373
374
375
376
 
390
391
392
 
393
394
 
395
396
397
398
 
415
416
417
 
418
419
 
420
421
422
423
 
432
433
434
 
435
436
 
437
438
439
440
 
612
613
614
 
 
615
616
617
618
619
@@ -175,7 +175,7 @@
  def cancel_clicked(self):   self.cancel()   - def command_finished(self, wrapper): + def command_finished(self, ret):   pass     def command_canceling(self): @@ -369,8 +369,8 @@
    ### Signal Handlers ###   - def command_finished(self, wrapper): - if wrapper.data == 0: + def command_finished(self, ret): + if ret == 0:   self.wizard().repo.incrementBusyCount()   self.wizard().repo.decrementBusyCount()   self.done = True @@ -390,9 +390,9 @@
  elif cmd == 'mq':   # TODO: need to check existing patches   patch = 'patch1' - def finished(wrapper): + def finished(ret):   self.wizard().repo.decrementBusyCount() - if wrapper.data == 0: + if ret == 0:   self.wizard().repo.incrementBusyCount()   self.wizard().repo.decrementBusyCount()   def callback(): @@ -415,9 +415,9 @@
  ' outstanding changes in working directory?'),   labels=labels, parent=self):   return - def finished(wrapper): + def finished(ret):   self.wizard().repo.decrementBusyCount() - if wrapper.data == 0: + if ret == 0:   self.check_status()   cmdline = ['update', '--clean', '--rev', self.wizard().local]   self.runner = cmdui.Runner(_('Discard - TortoiseHg'), True, self) @@ -432,9 +432,9 @@
  return   oldpatch = hglib.fromunicode(patch)   newpatch = hglib.fromunicode(name) - def finished(wrapper): + def finished(ret):   self.wizard().repo.decrementBusyCount() - if wrapper.data == 0: + if ret == 0:   text = _('The patch <b>%(old)s</b> is renamed to <b>'   '%(new)s</b>. <a href="rename:%(new)s"><b>'   'Rename</b></a> again?') @@ -612,8 +612,8 @@
    ### Signal Handlers ###   - def command_finished(self, wrapper): - if wrapper.data == 0: + def command_finished(self, ret): + if ret == 0:   self.wizard().repo.incrementBusyCount()   self.wizard().repo.decrementBusyCount()   self.done = True
 
98
99
100
101
 
102
103
104
105
 
106
107
108
 
98
99
100
 
101
102
103
104
 
105
106
107
108
@@ -98,11 +98,11 @@
  self.bb.button(QDialogButtonBox.Discard).setEnabled(False)   self.cmd.run(cmdline)   - def commandFinished(self, wrapper): + def commandFinished(self, ret):   self.repo.decrementBusyCount()   self.bb.button(QDialogButtonBox.Ok).setEnabled(True)   self.bb.button(QDialogButtonBox.Discard).setEnabled(True) - if wrapper.data == 0: + if ret == 0:   self.reject()     def keyPressEvent(self, event):
 
125
126
127
128
 
129
130
 
131
132
133
 
125
126
127
 
128
129
 
130
131
132
133
@@ -125,9 +125,9 @@
  self.cmd.setShown(True)   self.bb.button(QDialogButtonBox.Ok).setEnabled(False)   - def commandFinished(self, wrapper): + def commandFinished(self, ret):   self.bb.button(QDialogButtonBox.Ok).setEnabled(True) - if wrapper.data is not 0: + if ret is not 0:   self.cmd.show_output(True)   else:   self.reject()
 
322
323
324
325
326
 
 
327
328
329
 
322
323
324
 
 
325
326
327
328
329
@@ -322,8 +322,8 @@
  self.cancel_btn.setShown(True)   self.detail_btn.setShown(True)   - def command_finished(self, wrapper): - if (wrapper.data is not 0 or self.cmd.is_show_output() + def command_finished(self, ret): + if (ret is not 0 or self.cmd.is_show_output()   or self.keep_open_chk.isChecked()):   if not self.cmd.is_show_output():   self.detail_btn.click()
 
400
401
402
403
 
404
405
406
407
408
409
410
411
412
413
 
414
415
416
 
400
401
402
 
403
404
405
406
407
408
 
 
 
 
 
409
410
411
412
@@ -400,17 +400,13 @@
  self.cmd.show_output(True)   self.cmd.setVisible(True)   - def commandFinished(self, wrapper): + def commandFinished(self, ret):   self.repo.decrementBusyCount()   for b in self.opbuttons:   if b: b.setEnabled(True)   if self.finishfunc:   output = self.cmd.core.get_rawoutput() - if wrapper.data is None: - # An exception ocurred, command did not finish - self.finishfunc(-1, output) - else: - self.finishfunc(wrapper.data, output) + self.finishfunc(ret, output)     def commandCanceled(self):   for b in self.opbuttons:
 
258
259
260
261
262
 
 
263
264
265
 
258
259
260
 
 
261
262
263
264
265
@@ -258,8 +258,8 @@
  self.cancel_btn.setShown(True)   self.detail_btn.setShown(True)   - def command_finished(self, wrapper): - if wrapper.data is not 0 or self.cmd.is_show_output(): + def command_finished(self, ret): + if ret is not 0 or self.cmd.is_show_output():   self.detail_btn.setChecked(True)   self.close_btn.setShown(True)   self.close_btn.setAutoDefault(True)
 
235
236
237
238
 
239
240
 
241
242
243
 
235
236
237
 
238
239
 
240
241
242
243
@@ -235,9 +235,9 @@
  self.cancel_btn.setShown(True)   self.detail_btn.setShown(True)   - def command_finished(self, wrapper): + def command_finished(self, ret):   self.repo.decrementBusyCount() - if wrapper.data is not 0 or self.cmd.is_show_output(): + if ret is not 0 or self.cmd.is_show_output():   self.detail_btn.setChecked(True)   self.close_btn.setShown(True)   self.close_btn.setAutoDefault(True)
 
144
145
146
147
148
149
150
151
 
 
 
 
152
153
154
 
156
157
158
159
 
160
161
162
 
169
170
171
172
 
173
174
175
 
144
145
146
 
 
 
 
 
147
148
149
150
151
152
153
 
155
156
157
 
158
159
160
161
 
168
169
170
 
171
172
173
174
@@ -144,11 +144,10 @@
  # (topic=str, item=str, pos=int, total=int, unit=str) [wrapped]   progressReceived = pyqtSignal(DataWrapper)   - # result=int or None [wrapped] - # result: None - command is incomplete, possibly exited with exception - # 0 - command is finished successfully - # others - return code of command - commandFinished = pyqtSignal(DataWrapper) + # result: -1 - command is incomplete, possibly exited with exception + # 0 - command is finished successfully + # others - return code of command + commandFinished = pyqtSignal(int)     def __init__(self, cmdline, display, parent=None):   super(CmdThread, self).__init__() @@ -156,7 +155,7 @@
  self.cmdline = cmdline   self.display = display   self.parent = parent - self.ret = None + self.ret = -1   self.abortbyuser = False   self.responseq = Queue.Queue()   self.rawoutput = [] @@ -169,7 +168,7 @@
  thread2._async_raise(self.thread_id, KeyboardInterrupt)     def thread_finished(self): - self.commandFinished.emit(DataWrapper(self.ret)) + self.commandFinished.emit(self.ret)     def output_handler(self, wrapper):   self.rawoutput.append(wrapper.data[0])
 
279
280
281
282
 
283
284
285
286
287
288
 
289
290
291
 
279
280
281
 
282
283
 
 
 
 
 
284
285
286
287
@@ -279,13 +279,9 @@
  self.cancel_btn.setShown(True)   self.detail_btn.setShown(True)   - def command_finished(self, wrapper): + def command_finished(self, ret):   self.repo.decrementBusyCount() - if wrapper.data is 0: - res = 0 - else: - res = -1 - if wrapper.data is not 0 or self.cmd.is_show_output(): + if ret is not 0 or self.cmd.is_show_output():   self.detail_btn.setChecked(True)   self.close_btn.setShown(True)   self.close_btn.setAutoDefault(True)