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)
 
137
138
139
140
 
141
142
143
 
234
235
236
237
238
239
240
 
 
241
242
243
 
255
256
257
258
 
259
260
261
 
278
279
280
281
 
282
283
284
 
335
336
337
338
339
340
 
 
 
341
342
343
 
344
345
346
347
348
349
 
350
351
352
 
433
434
435
436
437
 
 
438
439
440
 
454
455
456
457
 
458
459
460
 
503
504
505
506
507
508
 
 
 
509
510
511
 
 
137
138
139
 
140
141
142
143
 
234
235
236
 
 
 
 
237
238
239
240
241
 
253
254
255
 
256
257
258
259
 
276
277
278
 
279
280
281
282
 
333
334
335
 
 
 
336
337
338
339
340
 
341
342
343
344
345
346
 
347
348
349
350
 
431
432
433
 
 
434
435
436
437
438
 
452
453
454
 
455
456
457
458
 
501
502
503
 
 
 
504
505
506
507
508
 
509
@@ -137,7 +137,7 @@
  """     commandStarted = pyqtSignal() - commandFinished = pyqtSignal(thread.DataWrapper) + commandFinished = pyqtSignal(int)   commandCanceling = pyqtSignal()     output = pyqtSignal(thread.DataWrapper) @@ -234,10 +234,8 @@
    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() @@ -255,7 +253,7 @@
    # 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): @@ -278,7 +276,7 @@
  """An embeddable widget for running Mercurial command"""     commandStarted = pyqtSignal() - commandFinished = pyqtSignal(thread.DataWrapper) + commandFinished = pyqtSignal(int)   commandCanceling = pyqtSignal()     output = pyqtSignal(thread.DataWrapper) @@ -335,18 +333,18 @@
    ### 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): @@ -433,8 +431,8 @@
  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() @@ -454,7 +452,7 @@
  """     commandStarted = pyqtSignal() - commandFinished = pyqtSignal(thread.DataWrapper) + commandFinished = pyqtSignal(int)   commandCanceling = pyqtSignal()     output = pyqtSignal(thread.DataWrapper) @@ -503,9 +501,9 @@
    ### 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)