eric6/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesDefineGuardsDialog.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 define guards for patches. 7 Module implementing a dialog to define guards for patches.
8 """ 8 """
9 9
10
11 import os 10 import os
12 11
13 from PyQt5.QtCore import pyqtSlot, Qt, QProcess, QCoreApplication 12 from PyQt5.QtCore import pyqtSlot, Qt, QCoreApplication
14 from PyQt5.QtWidgets import ( 13 from PyQt5.QtWidgets import (
15 QDialog, QDialogButtonBox, QAbstractButton, QListWidgetItem 14 QDialog, QDialogButtonBox, QAbstractButton, QListWidgetItem
16 ) 15 )
17 16
18 from E5Gui import E5MessageBox 17 from E5Gui import E5MessageBox
59 """ 58 """
60 Protected slot implementing a close event handler. 59 Protected slot implementing a close event handler.
61 60
62 @param e close event (QCloseEvent) 61 @param e close event (QCloseEvent)
63 """ 62 """
64 if self.__hgClient: 63 if self.__hgClient.isExecuting():
65 if self.__hgClient.isExecuting(): 64 self.__hgClient.cancel()
66 self.__hgClient.cancel()
67 65
68 if self.__dirtyList: 66 if self.__dirtyList:
69 res = E5MessageBox.question( 67 res = E5MessageBox.question(
70 self, 68 self,
71 self.tr("Unsaved Changes"), 69 self.tr("Unsaved Changes"),
133 131
134 args = self.vcs.initCommand("qguard") 132 args = self.vcs.initCommand("qguard")
135 if patch: 133 if patch:
136 args.append(patch) 134 args.append(patch)
137 135
138 output = "" 136 output = self.__hgClient.runcommand(args)[0]
139 if self.__hgClient:
140 output = self.__hgClient.runcommand(args)[0]
141 else:
142 process = QProcess()
143 process.setWorkingDirectory(self.__repodir)
144 process.start('hg', args)
145 procStarted = process.waitForStarted(5000)
146 if procStarted:
147 finished = process.waitForFinished(30000)
148 if finished and process.exitCode() == 0:
149 output = str(process.readAllStandardOutput(),
150 self.vcs.getEncoding(), 'replace').strip()
151 137
152 if output: 138 if output:
153 patchName, guards = output.split(":", 1) 139 patchName, guards = output.split(":", 1)
154 self.patchNameLabel.setText(patchName) 140 self.patchNameLabel.setText(patchName)
155 guardsList = guards.strip().split() 141 guardsList = guards.strip().split()
273 args.append("--") 259 args.append("--")
274 args.extend(guardsList) 260 args.extend(guardsList)
275 else: 261 else:
276 args.append("--none") 262 args.append("--none")
277 263
278 error = "" 264 error = self.__hgClient.runcommand(args)[1]
279 if self.__hgClient:
280 error = self.__hgClient.runcommand(args)[1]
281 else:
282 process = QProcess()
283 process.setWorkingDirectory(self.__repodir)
284 process.start('hg', args)
285 procStarted = process.waitForStarted(5000)
286 if procStarted:
287 finished = process.waitForFinished(30000)
288 if finished:
289 if process.exitCode() != 0:
290 error = str(process.readAllStandardError(),
291 self.vcs.getEncoding(), 'replace')
292 else:
293 E5MessageBox.warning(
294 self,
295 self.tr("Apply Guard Definitions"),
296 self.tr(
297 """The Mercurial process did not finish"""
298 """ in time."""))
299 265
300 if error: 266 if error:
301 E5MessageBox.warning( 267 E5MessageBox.warning(
302 self, 268 self,
303 self.tr("Apply Guard Definitions"), 269 self.tr("Apply Guard Definitions"),

eric ide

mercurial