eric6/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesListGuardsDialog.py

changeset 7370
5fb53279f2df
parent 7360
9190402e4505
child 7533
88261c96484b
equal deleted inserted replaced
7369:dbeeed55df08 7370:5fb53279f2df
5 5
6 """ 6 """
7 Module implementing a dialog to show the guards of a selected patch. 7 Module implementing a dialog to show the guards of a selected patch.
8 """ 8 """
9 9
10
11 import os 10 import os
12 11
13 from PyQt5.QtCore import pyqtSlot, Qt, QProcess, QTimer, QCoreApplication 12 from PyQt5.QtCore import pyqtSlot, Qt, QCoreApplication
14 from PyQt5.QtWidgets import QDialog, QListWidgetItem 13 from PyQt5.QtWidgets import QDialog, QListWidgetItem
15 14
16 from .Ui_HgQueuesListGuardsDialog import Ui_HgQueuesListGuardsDialog 15 from .Ui_HgQueuesListGuardsDialog import Ui_HgQueuesListGuardsDialog
17 16
18 import UI.PixmapCache 17 import UI.PixmapCache
32 """ 31 """
33 super(HgQueuesListGuardsDialog, self).__init__(parent) 32 super(HgQueuesListGuardsDialog, self).__init__(parent)
34 self.setupUi(self) 33 self.setupUi(self)
35 self.setWindowFlags(Qt.Window) 34 self.setWindowFlags(Qt.Window)
36 35
37 self.process = QProcess()
38 self.vcs = vcs 36 self.vcs = vcs
39 self.__hgClient = vcs.getClient() 37 self.__hgClient = vcs.getClient()
40 38
41 self.patchSelector.addItems([""] + patchesList) 39 self.patchSelector.addItems([""] + patchesList)
42 40
47 """ 45 """
48 Protected slot implementing a close event handler. 46 Protected slot implementing a close event handler.
49 47
50 @param e close event (QCloseEvent) 48 @param e close event (QCloseEvent)
51 """ 49 """
52 if self.__hgClient: 50 if self.__hgClient.isExecuting():
53 if self.__hgClient.isExecuting(): 51 self.__hgClient.cancel()
54 self.__hgClient.cancel()
55 else:
56 if (
57 self.process is not None and
58 self.process.state() != QProcess.NotRunning
59 ):
60 self.process.terminate()
61 QTimer.singleShot(2000, self.process.kill)
62 self.process.waitForFinished(3000)
63 52
64 e.accept() 53 e.accept()
65 54
66 def start(self, path): 55 def start(self, path):
67 """ 56 """
93 82
94 args = self.vcs.initCommand("qguard") 83 args = self.vcs.initCommand("qguard")
95 if patch: 84 if patch:
96 args.append(patch) 85 args.append(patch)
97 86
98 output = "" 87 output = self.__hgClient.runcommand(args)[0].strip()
99 if self.__hgClient:
100 output = self.__hgClient.runcommand(args)[0].strip()
101 else:
102 process = QProcess()
103 process.setWorkingDirectory(self.__repodir)
104 process.start('hg', args)
105 procStarted = process.waitForStarted(5000)
106 if procStarted:
107 finished = process.waitForFinished(30000)
108 if finished and process.exitCode() == 0:
109 output = str(process.readAllStandardOutput(),
110 self.vcs.getEncoding(), 'replace').strip()
111 88
112 if output: 89 if output:
113 patchName, guards = output.split(":", 1) 90 patchName, guards = output.split(":", 1)
114 self.patchNameLabel.setText(patchName) 91 self.patchNameLabel.setText(patchName)
115 guardsList = guards.strip().split() 92 guardsList = guards.strip().split()

eric ide

mercurial