Continued implementing an interface to the Mercurial command server.

Tue, 30 Aug 2011 19:39:52 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 30 Aug 2011 19:39:52 +0200
changeset 1254
c077fa008aae
parent 1253
4a994190cf8b
child 1255
e1d8a8a4d40c

Continued implementing an interface to the Mercurial command server.
Modified part 1 of the queues extension.

Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesDefineGuardsDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesHeaderDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesListAllGuardsDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/QueuesExtension/queues.py file | annotate | diff | comparison | revisions
--- a/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesDefineGuardsDialog.py	Tue Aug 30 19:13:13 2011 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesDefineGuardsDialog.py	Tue Aug 30 19:39:52 2011 +0200
@@ -36,9 +36,10 @@
         super().__init__(parent)
         self.setupUi(self)
         
-        self.process = QProcess()
+        self.process = None
         self.vcs = vcs
         self.extension = extension
+        self.__hgClient = vcs.getClient()
         
         self.__patches = patchesList[:]
         self.patchSelector.addItems([""] + self.__patches)
@@ -124,38 +125,43 @@
         self.guardCombo.addItems(guardsList)
         self.guardCombo.setEditText("")
         
-        ioEncoding = Preferences.getSystem("IOEncoding")
-        process = QProcess()
         args = []
         args.append("qguard")
         if patch:
             args.append(patch)
         
-        process.setWorkingDirectory(self.__repodir)
-        process.start('hg', args)
-        procStarted = process.waitForStarted()
-        if procStarted:
-            finished = process.waitForFinished(30000)
-            if finished and process.exitCode() == 0:
-                output = \
-                    str(process.readAllStandardOutput(), ioEncoding, 'replace').strip()
-                if output:
-                    patchName, guards = output.split(":", 1)
-                    self.patchNameLabel.setText(patchName)
-                    guardsList = guards.strip().split()
-                    for guard in guardsList:
-                        if guard.startswith("+"):
-                            icon = UI.PixmapCache.getIcon("plus.png")
-                            guard = guard[1:]
-                            sign = "+"
-                        elif guard.startswith("-"):
-                            icon = UI.PixmapCache.getIcon("minus.png")
-                            guard = guard[1:]
-                            sign = "-"
-                        else:
-                            continue
-                        itm = QListWidgetItem(icon, guard, self.guardsList)
-                        itm.setData(Qt.UserRole, sign)
+        output = ""
+        if self.__hgClient:
+            output = self.__hgClient.runcommand(args)[0]
+        else:
+            ioEncoding = Preferences.getSystem("IOEncoding")
+            process = QProcess()
+            process.setWorkingDirectory(self.__repodir)
+            process.start('hg', args)
+            procStarted = process.waitForStarted()
+            if procStarted:
+                finished = process.waitForFinished(30000)
+                if finished and process.exitCode() == 0:
+                    output = \
+                        str(process.readAllStandardOutput(), ioEncoding, 'replace').strip()
+        
+        if output:
+            patchName, guards = output.split(":", 1)
+            self.patchNameLabel.setText(patchName)
+            guardsList = guards.strip().split()
+            for guard in guardsList:
+                if guard.startswith("+"):
+                    icon = UI.PixmapCache.getIcon("plus.png")
+                    guard = guard[1:]
+                    sign = "+"
+                elif guard.startswith("-"):
+                    icon = UI.PixmapCache.getIcon("minus.png")
+                    guard = guard[1:]
+                    sign = "-"
+                else:
+                    continue
+                itm = QListWidgetItem(icon, guard, self.guardsList)
+                itm.setData(Qt.UserRole, sign)
         
         self.on_guardsList_itemSelectionChanged()
     
@@ -255,8 +261,6 @@
                 guard = itm.data(Qt.UserRole) + itm.text()
                 guardsList.append(guard)
             
-            ioEncoding = Preferences.getSystem("IOEncoding")
-            process = QProcess()
             args = []
             args.append("qguard")
             args.append(self.patchNameLabel.text())
@@ -266,24 +270,33 @@
             else:
                 args.append("--none")
             
-            process.setWorkingDirectory(self.__repodir)
-            process.start('hg', args)
-            procStarted = process.waitForStarted()
-            if procStarted:
-                finished = process.waitForFinished(30000)
-                if finished:
-                    if process.exitCode() == 0:
-                        self.__dirtyList = False
-                        self.on_patchSelector_activated(self.patchNameLabel.text())
+            error = ""
+            if self.__hgClient:
+                error = self.__hgClient.runcommand(args)[1]
+            else:
+                ioEncoding = Preferences.getSystem("IOEncoding")
+                process = QProcess()
+                process.setWorkingDirectory(self.__repodir)
+                process.start('hg', args)
+                procStarted = process.waitForStarted()
+                if procStarted:
+                    finished = process.waitForFinished(30000)
+                    if finished:
+                        if process.exitCode() != 0:
+                            error = \
+                                str(process.readAllStandardError(), ioEncoding, 'replace')
                     else:
-                        error = \
-                            str(process.readAllStandardError(), ioEncoding, 'replace')
                         E5MessageBox.warning(self,
                             self.trUtf8("Apply Guard Definitions"),
-                            self.trUtf8("""<p>The defined guards could not be"""
-                                        """ applied.</p><p>Reason: {0}</p>""")\
-                                .format(error))
-                else:
-                    E5MessageBox.warning(self,
-                        self.trUtf8("Apply Guard Definitions"),
-                        self.trUtf8("""The Mercurial process did not finish in time."""))
+                            self.trUtf8("""The Mercurial process did not finish"""
+                                        """ in time."""))
+            
+            if error:
+                E5MessageBox.warning(self,
+                    self.trUtf8("Apply Guard Definitions"),
+                    self.trUtf8("""<p>The defined guards could not be"""
+                                """ applied.</p><p>Reason: {0}</p>""")\
+                        .format(error))
+            else:
+                            self.__dirtyList = False
+                            self.on_patchSelector_activated(self.patchNameLabel.text())
--- a/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesHeaderDialog.py	Tue Aug 30 19:13:13 2011 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesHeaderDialog.py	Tue Aug 30 19:39:52 2011 +0200
@@ -38,6 +38,7 @@
         
         self.process = QProcess()
         self.vcs = vcs
+        self.__hgClient = vcs.getClient()
         
         self.process.finished.connect(self.__procFinished)
         self.process.readyReadStandardOutput.connect(self.__readStdout)
@@ -77,18 +78,29 @@
         args = []
         args.append('qheader')
         
-        self.process.kill()
-        self.process.setWorkingDirectory(repodir)
-        
-        self.process.start('hg', args)
-        procStarted = self.process.waitForStarted()
-        if not procStarted:
-            E5MessageBox.critical(self,
-                self.trUtf8('Process Generation Error'),
-                self.trUtf8(
-                    'The process {0} could not be started. '
-                    'Ensure, that it is in the search path.'
-                ).format('hg'))
+        if self.__hgClient:
+            self.inputGroup.setEnabled(False)
+            self.inputGroup.hide()
+            
+            out, err = self.__hgClient.runcommand(args)
+            if err:
+                self.__showError(err)
+            if out:
+                self.__showOutPut(out)
+            self.__finish()
+        else:
+            self.process.kill()
+            self.process.setWorkingDirectory(repodir)
+            
+            self.process.start('hg', args)
+            procStarted = self.process.waitForStarted()
+            if not procStarted:
+                E5MessageBox.critical(self,
+                    self.trUtf8('Process Generation Error'),
+                    self.trUtf8(
+                        'The process {0} could not be started. '
+                        'Ensure, that it is in the search path.'
+                    ).format('hg'))
     
     def __finish(self):
         """
@@ -116,7 +128,10 @@
         if button == self.buttonBox.button(QDialogButtonBox.Close):
             self.close()
         elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
-            self.__finish()
+            if self.__hgClient:
+                self.__hgClient.cancel()
+            else:
+                self.__finish()
     
     def __procFinished(self, exitCode, exitStatus):
         """
@@ -138,7 +153,15 @@
             s = str(self.process.readAllStandardOutput(),
                     Preferences.getSystem("IOEncoding"),
                     'replace')
-            self.messageEdit.appendPlainText(s)
+            self.__showOutput(s)
+    
+    def __showOutput(self, out):
+        """
+        Private slot to show some output.
+        
+        @param out output to be shown (string)
+        """
+        self.messageEdit.appendPlainText(out)
     
     def __readStderr(self):
         """
@@ -151,5 +174,13 @@
             s = str(self.process.readAllStandardError(),
                     Preferences.getSystem("IOEncoding"),
                     'replace')
-            self.messageEdit.appendPlainText(self.trUtf8("Error: "))
-            self.messageEdit.appendPlainText(s)
+            self.__showError(s)
+    
+    def __showError(self, out):
+        """
+        Private slot to show some error.
+        
+        @param out error to be shown (string)
+        """
+        self.messageEdit.appendPlainText(self.trUtf8("Error: "))
+        self.messageEdit.appendPlainText(out)
--- a/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesListAllGuardsDialog.py	Tue Aug 30 19:13:13 2011 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesListAllGuardsDialog.py	Tue Aug 30 19:39:52 2011 +0200
@@ -9,7 +9,7 @@
 
 import os
 
-from PyQt4.QtCore import QProcess, QTimer
+from PyQt4.QtCore import QProcess
 from PyQt4.QtGui import QDialog, QTreeWidgetItem
 
 from .Ui_HgQueuesListAllGuardsDialog import Ui_HgQueuesListAllGuardsDialog
@@ -31,22 +31,8 @@
         super().__init__(parent)
         self.setupUi(self)
         
-        self.process = QProcess()
         self.vcs = vcs
-    
-    def closeEvent(self, e):
-        """
-        Private slot implementing a close event handler.
-        
-        @param e close event (QCloseEvent)
-        """
-        if self.process is not None and \
-           self.process.state() != QProcess.NotRunning:
-            self.process.terminate()
-            QTimer.singleShot(2000, self.process.kill)
-            self.process.waitForFinished(3000)
-        
-        e.accept()
+        self.__hgClient = vcs.getClient()
     
     def start(self, path):
         """
@@ -63,41 +49,46 @@
             if repodir == os.sep:
                 return
         
-        ioEncoding = Preferences.getSystem("IOEncoding")
-        process = QProcess()
         args = []
         args.append("qguard")
         args.append("--list")
         
-        process.setWorkingDirectory(repodir)
-        process.start('hg', args)
-        procStarted = process.waitForStarted()
-        if procStarted:
-            finished = process.waitForFinished(30000)
-            if finished and process.exitCode() == 0:
-                output = \
-                    str(process.readAllStandardOutput(), ioEncoding, 'replace')
-                if output:
-                    guardsDict = {}
-                    for line in output.splitlines():
-                        if line:
-                            patchName, guards = line.strip().split(":", 1)
-                            guardsDict[patchName] = guards.strip().split()
-                    for patchName in sorted(guardsDict.keys()):
-                        patchItm = QTreeWidgetItem(self.guardsTree, [patchName])
-                        patchItm.setExpanded(True)
-                        for guard in guardsDict[patchName]:
-                            if guard.startswith("+"):
-                                icon = UI.PixmapCache.getIcon("plus.png")
-                                guard = guard[1:]
-                            elif guard.startswith("-"):
-                                icon = UI.PixmapCache.getIcon("minus.png")
-                                guard = guard[1:]
-                            else:
-                                icon = None
-                                guard = self.trUtf8("Unguarded")
-                            itm = QTreeWidgetItem(patchItm, [guard])
-                            if icon:
-                                itm.setIcon(0, icon)
-                else:
-                    QTreeWidgetItem(self.guardsTree, [self.trUtf8("no patches found")])
+        output = ""
+        if self.__hgClient:
+            output = self.__hgClient.runcommand(args)[0]
+        else:
+            ioEncoding = Preferences.getSystem("IOEncoding")
+            process = QProcess()
+            process.setWorkingDirectory(repodir)
+            process.start('hg', args)
+            procStarted = process.waitForStarted()
+            if procStarted:
+                finished = process.waitForFinished(30000)
+                if finished and process.exitCode() == 0:
+                    output = \
+                        str(process.readAllStandardOutput(), ioEncoding, 'replace')
+        
+        if output:
+            guardsDict = {}
+            for line in output.splitlines():
+                if line:
+                    patchName, guards = line.strip().split(":", 1)
+                    guardsDict[patchName] = guards.strip().split()
+            for patchName in sorted(guardsDict.keys()):
+                patchItm = QTreeWidgetItem(self.guardsTree, [patchName])
+                patchItm.setExpanded(True)
+                for guard in guardsDict[patchName]:
+                    if guard.startswith("+"):
+                        icon = UI.PixmapCache.getIcon("plus.png")
+                        guard = guard[1:]
+                    elif guard.startswith("-"):
+                        icon = UI.PixmapCache.getIcon("minus.png")
+                        guard = guard[1:]
+                    else:
+                        icon = None
+                        guard = self.trUtf8("Unguarded")
+                    itm = QTreeWidgetItem(patchItm, [guard])
+                    if icon:
+                        itm.setIcon(0, icon)
+        else:
+            QTreeWidgetItem(self.guardsTree, [self.trUtf8("no patches found")])
--- a/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/queues.py	Tue Aug 30 19:13:13 2011 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/queues.py	Tue Aug 30 19:39:52 2011 +0200
@@ -95,8 +95,6 @@
         """
         patchesList = []
         
-        ioEncoding = Preferences.getSystem("IOEncoding")
-        process = QProcess()
         args = []
         if listType == Queues.APPLIED_LIST:
             args.append("qapplied")
@@ -109,24 +107,32 @@
         if withSummary:
             args.append("--summary")
         
-        process.setWorkingDirectory(repodir)
-        process.start('hg', args)
-        procStarted = process.waitForStarted()
-        if procStarted:
-            finished = process.waitForFinished(30000)
-            if finished and process.exitCode() == 0:
-                output = \
-                    str(process.readAllStandardOutput(), ioEncoding, 'replace')
-                for line in output.splitlines():
-                    if withSummary:
-                        l = line.strip().split(": ")
-                        if len(l) == 1:
-                            patch, summary = l[0][:-1], ""
-                        else:
-                            patch, summary = l[0], l[1]
-                        patchesList.append("{0}@@{1}".format(patch, summary))
-                    else:
-                        patchesList.append(line.strip())
+        client = self.vcs.getClient()
+        output = ""
+        if client:
+            output = client.runcommand(args)[0]
+        else:
+            ioEncoding = Preferences.getSystem("IOEncoding")
+            process = QProcess()
+            process.setWorkingDirectory(repodir)
+            process.start('hg', args)
+            procStarted = process.waitForStarted()
+            if procStarted:
+                finished = process.waitForFinished(30000)
+                if finished and process.exitCode() == 0:
+                    output = \
+                        str(process.readAllStandardOutput(), ioEncoding, 'replace')
+        
+        for line in output.splitlines():
+            if withSummary:
+                l = line.strip().split(": ")
+                if len(l) == 1:
+                    patch, summary = l[0][:-1], ""
+                else:
+                    patch, summary = l[0], l[1]
+                patchesList.append("{0}@@{1}".format(patch, summary))
+            else:
+                patchesList.append(line.strip())
         
         return patchesList
     
@@ -139,20 +145,24 @@
         """
         currentPatch = ""
         
-        ioEncoding = Preferences.getSystem("IOEncoding")
-        process = QProcess()
         args = []
         args.append("qtop")
         
-        process.setWorkingDirectory(repodir)
-        process.start('hg', args)
-        procStarted = process.waitForStarted()
-        if procStarted:
-            finished = process.waitForFinished(30000)
-            if finished and process.exitCode() == 0:
-                currentPatch = str(
-                    process.readAllStandardOutput(),
-                    ioEncoding, 'replace').strip()
+        client = self.vcs.getClient()
+        if client:
+            currentPatch = client.runcommand(args)[0].strip()
+        else:
+            ioEncoding = Preferences.getSystem("IOEncoding")
+            process = QProcess()
+            process.setWorkingDirectory(repodir)
+            process.start('hg', args)
+            procStarted = process.waitForStarted()
+            if procStarted:
+                finished = process.waitForFinished(30000)
+                if finished and process.exitCode() == 0:
+                    currentPatch = str(
+                        process.readAllStandardOutput(),
+                        ioEncoding, 'replace').strip()
         
         return currentPatch
     
@@ -165,20 +175,24 @@
         """
         message = ""
         
-        ioEncoding = Preferences.getSystem("IOEncoding")
-        process = QProcess()
         args = []
         args.append("qheader")
         
-        process.setWorkingDirectory(repodir)
-        process.start('hg', args)
-        procStarted = process.waitForStarted()
-        if procStarted:
-            finished = process.waitForFinished(30000)
-            if finished and process.exitCode() == 0:
-                message = str(
-                    process.readAllStandardOutput(),
-                    ioEncoding, 'replace')
+        client = self.vcs.getClient()
+        if client:
+            message = client.runcommand(args)[0]
+        else:
+            ioEncoding = Preferences.getSystem("IOEncoding")
+            process = QProcess()
+            process.setWorkingDirectory(repodir)
+            process.start('hg', args)
+            procStarted = process.waitForStarted()
+            if procStarted:
+                finished = process.waitForFinished(30000)
+                if finished and process.exitCode() == 0:
+                    message = str(
+                        process.readAllStandardOutput(),
+                        ioEncoding, 'replace')
         
         return message
     
@@ -192,27 +206,33 @@
         """
         guardsList = []
         
-        ioEncoding = Preferences.getSystem("IOEncoding")
-        process = QProcess()
         args = []
         args.append("qselect")
         if all:
             args.append("--series")
         
-        process.setWorkingDirectory(repodir)
-        process.start('hg', args)
-        procStarted = process.waitForStarted()
-        if procStarted:
-            finished = process.waitForFinished(30000)
-            if finished and process.exitCode() == 0:
-                output = \
-                    str(process.readAllStandardOutput(), ioEncoding, 'replace')
-                for guard in output.splitlines():
-                    guard = guard.strip()
-                    if all:
-                        guard = guard[1:]
-                    if guard not in guardsList:
-                        guardsList.append(guard)
+        client = self.vcs.getClient()
+        output = ""
+        if client:
+            output = client.runcommand(args)[0]
+        else:
+            ioEncoding = Preferences.getSystem("IOEncoding")
+            process = QProcess()
+            process.setWorkingDirectory(repodir)
+            process.start('hg', args)
+            procStarted = process.waitForStarted()
+            if procStarted:
+                finished = process.waitForFinished(30000)
+                if finished and process.exitCode() == 0:
+                    output = \
+                        str(process.readAllStandardOutput(), ioEncoding, 'replace')
+        
+        for guard in output.splitlines():
+            guard = guard.strip()
+            if all:
+                guard = guard[1:]
+            if guard not in guardsList:
+                guardsList.append(guard)
         
         return sorted(guardsList)
     
@@ -253,7 +273,7 @@
                     args.append(dateStr)
             args.append(name)
             
-            dia = HgDialog(self.trUtf8('New Patch'))
+            dia = HgDialog(self.trUtf8('New Patch'), self.vcs)
             res = dia.startProcess(args, repodir)
             if res:
                 dia.exec_()
@@ -302,7 +322,7 @@
             else:
                 return
         
-        dia = HgDialog(self.trUtf8('Update Current Patch'))
+        dia = HgDialog(self.trUtf8('Update Current Patch'), self.vcs)
         res = dia.startProcess(args, repodir)
         if res:
             dia.exec_()
@@ -389,7 +409,7 @@
                     self.trUtf8("""No patches to select from."""))
                 return False
         
-        dia = HgDialog(title)
+        dia = HgDialog(title, self.vcs)
         res = dia.startProcess(args, repodir)
         if res:
             dia.exec_()
@@ -424,7 +444,7 @@
         args.append("qfinish")
         args.append("--applied")
         
-        dia = HgDialog(self.trUtf8('Finish Applied Patches'))
+        dia = HgDialog(self.trUtf8('Finish Applied Patches'), self.vcs)
         res = dia.startProcess(args, repodir)
         if res:
             dia.exec_()
@@ -456,7 +476,7 @@
                         args.append(selectedPatch)
                     args.append(newName)
                     
-                    dia = HgDialog(self.trUtf8("Rename Patch"))
+                    dia = HgDialog(self.trUtf8("Rename Patch"), self.vcs)
                     res = dia.startProcess(args, repodir)
                     if res:
                         dia.exec_()
@@ -487,7 +507,7 @@
             if ok and patch:
                 args.append(patch)
                 
-                dia = HgDialog(self.trUtf8("Delete Patch"))
+                dia = HgDialog(self.trUtf8("Delete Patch"), self.vcs)
                 res = dia.startProcess(args, repodir)
                 if res:
                     dia.exec_()
@@ -523,7 +543,7 @@
                 if patchesList:
                     args.extend(patchesList)
                     
-                    dia = HgDialog(self.trUtf8("Fold Patches"))
+                    dia = HgDialog(self.trUtf8("Fold Patches"), self.vcs)
                     res = dia.startProcess(args, repodir)
                     if res:
                         dia.exec_()
@@ -619,18 +639,22 @@
                 [""] + patchnames,
                 0, False)
             if ok:
-                process = QProcess()
                 args = []
                 args.append("qguard")
                 if patch:
                     args.append(patch)
                 args.append("--none")
                 
-                process.setWorkingDirectory(repodir)
-                process.start('hg', args)
-                procStarted = process.waitForStarted()
-                if procStarted:
-                    process.waitForFinished(30000)
+                client = self.vcs.getClient()
+                if client:
+                    client.runcommand(args)
+                else:
+                    process = QProcess()
+                    process.setWorkingDirectory(repodir)
+                    process.start('hg', args)
+                    procStarted = process.waitForStarted()
+                    if procStarted:
+                        process.waitForFinished(30000)
         else:
             E5MessageBox.information(None,
                 self.trUtf8("Drop All Guards"),
@@ -661,7 +685,7 @@
                     args.append("qselect")
                     args.extend(guards)
                     
-                    dia = HgDialog(self.trUtf8('Set Active Guards'))
+                    dia = HgDialog(self.trUtf8('Set Active Guards'), self.vcs)
                     res = dia.startProcess(args, repodir)
                     if res:
                         dia.exec_()
@@ -688,7 +712,7 @@
         args.append("qselect")
         args.append("--none")
         
-        dia = HgDialog(self.trUtf8('Deactivate Guards'))
+        dia = HgDialog(self.trUtf8('Deactivate Guards'), self.vcs)
         res = dia.startProcess(args, repodir)
         if res:
             dia.exec_()
@@ -734,8 +758,6 @@
         if dlg.exec_() == QDialog.Accepted:
             queueName = dlg.getData()
             if queueName:
-                ioEncoding = Preferences.getSystem("IOEncoding")
-                process = QProcess()
                 args = []
                 args.append("qqueue")
                 if isCreate:
@@ -744,28 +766,38 @@
                     args.append("--rename")
                 args.append(queueName)
                 
-                process.setWorkingDirectory(repodir)
-                process.start('hg', args)
-                procStarted = process.waitForStarted()
-                if procStarted:
-                    finished = process.waitForFinished(30000)
-                    if finished:
-                        if process.exitCode() != 0:
-                            error = \
-                                str(process.readAllStandardError(), ioEncoding, 'replace')
-                            if isCreate:
-                                errMsg = self.trUtf8(
-                                    "Error while creating a new queue.")
-                            else:
-                                errMsg = self.trUtf8(
-                                    "Error while renaming the active queue.")
-                            E5MessageBox.warning(None,
-                                title,
-                                """<p>{0}</p><p>{1}</p>""".format(errMsg, error))
-                        else:
-                            if self.queuesListQueuesDialog is not None and \
-                               self.queuesListQueuesDialog.isVisible():
-                                self.queuesListQueuesDialog.refresh()
+                client = self.vcs.getClient()
+                error = ""
+                if client:
+                    error = client.runcommand(args)[1]
+                else:
+                    ioEncoding = Preferences.getSystem("IOEncoding")
+                    process = QProcess()
+                    process.setWorkingDirectory(repodir)
+                    process.start('hg', args)
+                    procStarted = process.waitForStarted()
+                    if procStarted:
+                        finished = process.waitForFinished(30000)
+                        if finished:
+                            if process.exitCode() != 0:
+                                error = \
+                                    str(process.readAllStandardError(),
+                                        ioEncoding, 'replace')
+                
+                if error:
+                    if isCreate:
+                        errMsg = self.trUtf8(
+                            "Error while creating a new queue.")
+                    else:
+                        errMsg = self.trUtf8(
+                            "Error while renaming the active queue.")
+                    E5MessageBox.warning(None,
+                        title,
+                        """<p>{0}</p><p>{1}</p>""".format(errMsg, error))
+                else:
+                    if self.queuesListQueuesDialog is not None and \
+                       self.queuesListQueuesDialog.isVisible():
+                        self.queuesListQueuesDialog.refresh()
     
     def hgQueueDeletePurgeActivateQueue(self, name, operation):
         """
@@ -797,8 +829,6 @@
         if dlg.exec_() == QDialog.Accepted:
             queueName = dlg.getData()
             if queueName:
-                ioEncoding = Preferences.getSystem("IOEncoding")
-                process = QProcess()
                 args = []
                 args.append("qqueue")
                 if operation == Queues.QUEUE_PURGE:
@@ -807,29 +837,39 @@
                     args.append("--delete")
                 args.append(queueName)
                 
-                process.setWorkingDirectory(repodir)
-                process.start('hg', args)
-                procStarted = process.waitForStarted()
-                if procStarted:
-                    finished = process.waitForFinished(30000)
-                    if finished:
-                        if process.exitCode() != 0:
-                            error = \
-                                str(process.readAllStandardError(), ioEncoding, 'replace')
-                            if operation == Queues.QUEUE_PURGE:
-                                errMsg = self.trUtf8("Error while purging the queue.")
-                            elif operation == Queues.QUEUE_DELETE:
-                                errMsg = self.trUtf8("Error while deleting the queue.")
-                            elif operation == Queues.QUEUE_ACTIVATE:
-                                errMsg = self.trUtf8(
-                                    "Error while setting the active queue.")
-                            E5MessageBox.warning(None,
-                                title,
-                                """<p>{0}</p><p>{1}</p>""".format(errMsg, error))
-                        else:
-                            if self.queuesListQueuesDialog is not None and \
-                               self.queuesListQueuesDialog.isVisible():
-                                self.queuesListQueuesDialog.refresh()
+                client = self.vcs.getClient()
+                error = ""
+                if client:
+                    error = client.runcommand(args)[1]
+                else:
+                    ioEncoding = Preferences.getSystem("IOEncoding")
+                    process = QProcess()
+                    process.setWorkingDirectory(repodir)
+                    process.start('hg', args)
+                    procStarted = process.waitForStarted()
+                    if procStarted:
+                        finished = process.waitForFinished(30000)
+                        if finished:
+                            if process.exitCode() != 0:
+                                error = \
+                                    str(process.readAllStandardError(),
+                                        ioEncoding, 'replace')
+                
+                if error:
+                    if operation == Queues.QUEUE_PURGE:
+                        errMsg = self.trUtf8("Error while purging the queue.")
+                    elif operation == Queues.QUEUE_DELETE:
+                        errMsg = self.trUtf8("Error while deleting the queue.")
+                    elif operation == Queues.QUEUE_ACTIVATE:
+                        errMsg = self.trUtf8(
+                            "Error while setting the active queue.")
+                    E5MessageBox.warning(None,
+                        title,
+                        """<p>{0}</p><p>{1}</p>""".format(errMsg, error))
+                else:
+                    if self.queuesListQueuesDialog is not None and \
+                       self.queuesListQueuesDialog.isVisible():
+                        self.queuesListQueuesDialog.refresh()
     
     def hgQueueListQueues(self, name):
         """

eric ide

mercurial