1. Yuya Nishihara
  2. thg-work

Commits

Yuya Nishihara  committed 2a2988a Obsolete Draft

filectxactions: stub to run Mercurial commands in separate thread or process

  • Participants
  • Parent commits 17ef4b4
  • Successor commits 137c045
  • Branches default

Comments (0)

Files changed (1)

File tortoisehg/hgqt/filectxactions.py

View file
  • Ignore whitespace
 
 from mercurial import commands, util
 
-from tortoisehg.hgqt import qtlib, revert, visdiff
+from tortoisehg.hgqt import cmdcore, cmdui, qtlib, revert, visdiff
 from tortoisehg.hgqt import filedata
 from tortoisehg.hgqt.i18n import _
 from tortoisehg.util import hglib
             raise ValueError('parent must be a QWidget')
 
         self._repoagent = repoagent
+        self._cmdsession = cmdcore.nullCmdSession()
         repo = repoagent.rawRepo()
         self._curfd = filedata.createNullData(repo)
         self._selfds = []
         return self._repoagent.subRepoAgent(rpath)
 
     def _updateActions(self):
+        for a in self._actions.itervalues():
+            a.setEnabled(self._cmdsession.isFinished())
+        if not self._cmdsession.isFinished():
+            return
+
         nosub = not self._curfd.repoRootPath() and not self._curfd.subrepoType()
         real = self._curfd.rev() is not None and self._curfd.rev() >= 0
         wd = self._curfd.rev() is None
     def action(self, name):
         return self._actions[name]
 
+    def _runCommandSequence(self, cmdlines):
+        if not self._cmdsession.isFinished():
+            return
+        sess = self._repoagent.runCommandSequence(cmdlines, self)
+        self._cmdsession = sess
+        sess.commandFinished.connect(self._onCommandFinished)
+        self._updateActions()
+
+    @pyqtSlot(int)
+    def _onCommandFinished(self, ret):
+        if ret == 255:
+            cmdui.errorMessageBox(self._cmdsession, self.parent())
+        self._updateActions()
+
     @actionSlot(_('File &History'), 'hg-log', 'Shift+Return',
                 _('Show the history of the selected file'))
     def navigateFileLog(self):