Commits

Yuya Nishihara committed 2fe039d

revert: run commands by using RepoAgent

Now it will show message box instead of command log on error, which seems
suitable for modal dialogs of RepoWidget.

Comments (0)

Files changed (1)

tortoisehg/hgqt/revert.py

 
 from tortoisehg.util import hglib
 from tortoisehg.hgqt.i18n import _
-from tortoisehg.hgqt import cmdui, qtlib
+from tortoisehg.hgqt import cmdcore, cmdui, qtlib
 
 class RevertDialog(QDialog):
     def __init__(self, repoagent, wfiles, rev, parent):
 
         self._repoagent = repoagent
         repo = repoagent.rawRepo()
+        self._cmdsession = cmdcore.nullCmdSession()
         self.setWindowTitle(_('Revert - %s') % repo.displayname)
 
         f = self.windowFlags()
         self.allchk = QCheckBox(_('Revert all files to this revision'))
         self.layout().addWidget(self.allchk)
 
-        self.cmd = cmdui.Runner(True, self)
-        self.cmd.commandFinished.connect(self._onCommandFinished)
-
         BB = QDialogButtonBox
         bbox = QDialogButtonBox(BB.Ok|BB.Cancel)
         bbox.accepted.connect(self.accept)
                        '(use update to checkout another revision)'),
                        parent=self):
                 return
-            cmdline = ['revert', '--repository', self.repo.root, '--all']
+            cmdline = ['revert', '--all']
         else:
-            cmdline = ['revert', '--repository', self.repo.root]
-            cmdline.extend(self.wfiles)
+            cmdline = ['revert']
+            files = map(hglib.tounicode, self.wfiles)
+            cmdline.extend(files)
         rev = self.revcombo.itemData(self.revcombo.currentIndex()).toString()
         cmdline += ['--rev', str(rev)]
         self.bbox.button(QDialogButtonBox.Ok).setEnabled(False)
-        self.cmd.run(cmdline)
+        self._cmdsession = sess = self._repoagent.runCommand(cmdline, self)
+        sess.commandFinished.connect(self._onCommandFinished)
 
     @pyqtSlot(int)
     def _onCommandFinished(self, ret):
         if ret == 0:
             self.reject()
+        else:
+            cmdui.errorMessageBox(self._cmdsession, self)