Commits

Yuya Nishihara committed 963268a

graft: split handler of abort command finished

"aborted" flag is no longer needed.

Comments (0)

Files changed (1)

tortoisehg/hgqt/graft.py

         self._repoagent = repoagent
         self._cmdsession = cmdcore.nullCmdSession()
         self._graftstatefile = self.repo.join('graftstate')
-        self.aborted = False
         self.valid = True
 
         def cleanrevlist(revlist):
             cmdline += ['--continue']
         else:
             cmdline.extend(hglib.tounicode(str(s)) for s in self.sourcelist)
-        self._runCommand(cmdline)
+        sess = self._runCommand(cmdline)
+        sess.commandFinished.connect(self._graftFinished)
 
     def abort(self):
         self.abortbtn.setDisabled(True)
             # Remove the existing graftstate file!
             os.remove(self._graftstatefile)
         cmdline = ['update', '--clean', '--rev', 'p1()']
-        self.aborted = True
-        self._runCommand(cmdline)
+        sess = self._runCommand(cmdline)
+        sess.commandFinished.connect(self._abortFinished)
 
     def graftstate(self):
         graftstatefile = self.repo.join('graftstate')
     def _runCommand(self, cmdline):
         assert self._cmdsession.isFinished()
         self._cmdsession = sess = self._repoagent.runCommand(cmdline, self)
-        sess.commandFinished.connect(self.commandFinished)
         sess.outputReceived.connect(self._cmdlog.appendLog)
         sess.progressReceived.connect(self._stbar.progress)
         cmdui.updateStatusMessage(self._stbar, sess)
+        return sess
 
-    def commandFinished(self, ret):
-        if  self.aborted or self.checkResolve() is False:
+    @pyqtSlot(int)
+    def _graftFinished(self, ret):
+        if self.checkResolve() is False:
             msg = _('Graft is complete')
-            if self.aborted:
-                msg = _('Graft aborted')
-            elif ret == 255:
+            if ret == 255:
                 msg = _('Graft failed')
                 self._cmdlog.show()  # contains hint
             else:
             self._stbar.showMessage(msg)
             self._makeCloseButton()
 
+    @pyqtSlot()
+    def _abortFinished(self):
+        if self.checkResolve() is False:
+            self._stbar.showMessage(_('Graft aborted'))
+            self._makeCloseButton()
+
     def _makeCloseButton(self):
         self.graftbtn.setEnabled(True)
         self.graftbtn.setText(_('Close'))