Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesDefineGuardsDialog.py

changeset 1254
c077fa008aae
parent 1131
7781e396c903
child 1256
885706dbb69f
equal deleted inserted replaced
1253:4a994190cf8b 1254:c077fa008aae
34 @param parent reference to the parent widget (QWidget) 34 @param parent reference to the parent widget (QWidget)
35 """ 35 """
36 super().__init__(parent) 36 super().__init__(parent)
37 self.setupUi(self) 37 self.setupUi(self)
38 38
39 self.process = QProcess() 39 self.process = None
40 self.vcs = vcs 40 self.vcs = vcs
41 self.extension = extension 41 self.extension = extension
42 self.__hgClient = vcs.getClient()
42 43
43 self.__patches = patchesList[:] 44 self.__patches = patchesList[:]
44 self.patchSelector.addItems([""] + self.__patches) 45 self.patchSelector.addItems([""] + self.__patches)
45 46
46 self.plusButton.setIcon(UI.PixmapCache.getIcon("plus.png")) 47 self.plusButton.setIcon(UI.PixmapCache.getIcon("plus.png"))
122 self.guardCombo.clear() 123 self.guardCombo.clear()
123 guardsList = self.extension.getGuardsList(self.__repodir) 124 guardsList = self.extension.getGuardsList(self.__repodir)
124 self.guardCombo.addItems(guardsList) 125 self.guardCombo.addItems(guardsList)
125 self.guardCombo.setEditText("") 126 self.guardCombo.setEditText("")
126 127
127 ioEncoding = Preferences.getSystem("IOEncoding")
128 process = QProcess()
129 args = [] 128 args = []
130 args.append("qguard") 129 args.append("qguard")
131 if patch: 130 if patch:
132 args.append(patch) 131 args.append(patch)
133 132
134 process.setWorkingDirectory(self.__repodir) 133 output = ""
135 process.start('hg', args) 134 if self.__hgClient:
136 procStarted = process.waitForStarted() 135 output = self.__hgClient.runcommand(args)[0]
137 if procStarted: 136 else:
138 finished = process.waitForFinished(30000) 137 ioEncoding = Preferences.getSystem("IOEncoding")
139 if finished and process.exitCode() == 0: 138 process = QProcess()
140 output = \ 139 process.setWorkingDirectory(self.__repodir)
141 str(process.readAllStandardOutput(), ioEncoding, 'replace').strip() 140 process.start('hg', args)
142 if output: 141 procStarted = process.waitForStarted()
143 patchName, guards = output.split(":", 1) 142 if procStarted:
144 self.patchNameLabel.setText(patchName) 143 finished = process.waitForFinished(30000)
145 guardsList = guards.strip().split() 144 if finished and process.exitCode() == 0:
146 for guard in guardsList: 145 output = \
147 if guard.startswith("+"): 146 str(process.readAllStandardOutput(), ioEncoding, 'replace').strip()
148 icon = UI.PixmapCache.getIcon("plus.png") 147
149 guard = guard[1:] 148 if output:
150 sign = "+" 149 patchName, guards = output.split(":", 1)
151 elif guard.startswith("-"): 150 self.patchNameLabel.setText(patchName)
152 icon = UI.PixmapCache.getIcon("minus.png") 151 guardsList = guards.strip().split()
153 guard = guard[1:] 152 for guard in guardsList:
154 sign = "-" 153 if guard.startswith("+"):
155 else: 154 icon = UI.PixmapCache.getIcon("plus.png")
156 continue 155 guard = guard[1:]
157 itm = QListWidgetItem(icon, guard, self.guardsList) 156 sign = "+"
158 itm.setData(Qt.UserRole, sign) 157 elif guard.startswith("-"):
158 icon = UI.PixmapCache.getIcon("minus.png")
159 guard = guard[1:]
160 sign = "-"
161 else:
162 continue
163 itm = QListWidgetItem(icon, guard, self.guardsList)
164 itm.setData(Qt.UserRole, sign)
159 165
160 self.on_guardsList_itemSelectionChanged() 166 self.on_guardsList_itemSelectionChanged()
161 167
162 @pyqtSlot() 168 @pyqtSlot()
163 def on_guardsList_itemSelectionChanged(self): 169 def on_guardsList_itemSelectionChanged(self):
253 for row in range(self.guardsList.count()): 259 for row in range(self.guardsList.count()):
254 itm = self.guardsList.item(row) 260 itm = self.guardsList.item(row)
255 guard = itm.data(Qt.UserRole) + itm.text() 261 guard = itm.data(Qt.UserRole) + itm.text()
256 guardsList.append(guard) 262 guardsList.append(guard)
257 263
258 ioEncoding = Preferences.getSystem("IOEncoding")
259 process = QProcess()
260 args = [] 264 args = []
261 args.append("qguard") 265 args.append("qguard")
262 args.append(self.patchNameLabel.text()) 266 args.append(self.patchNameLabel.text())
263 if guardsList: 267 if guardsList:
264 args.append("--") 268 args.append("--")
265 args.extend(guardsList) 269 args.extend(guardsList)
266 else: 270 else:
267 args.append("--none") 271 args.append("--none")
268 272
269 process.setWorkingDirectory(self.__repodir) 273 error = ""
270 process.start('hg', args) 274 if self.__hgClient:
271 procStarted = process.waitForStarted() 275 error = self.__hgClient.runcommand(args)[1]
272 if procStarted: 276 else:
273 finished = process.waitForFinished(30000) 277 ioEncoding = Preferences.getSystem("IOEncoding")
274 if finished: 278 process = QProcess()
275 if process.exitCode() == 0: 279 process.setWorkingDirectory(self.__repodir)
276 self.__dirtyList = False 280 process.start('hg', args)
277 self.on_patchSelector_activated(self.patchNameLabel.text()) 281 procStarted = process.waitForStarted()
282 if procStarted:
283 finished = process.waitForFinished(30000)
284 if finished:
285 if process.exitCode() != 0:
286 error = \
287 str(process.readAllStandardError(), ioEncoding, 'replace')
278 else: 288 else:
279 error = \
280 str(process.readAllStandardError(), ioEncoding, 'replace')
281 E5MessageBox.warning(self, 289 E5MessageBox.warning(self,
282 self.trUtf8("Apply Guard Definitions"), 290 self.trUtf8("Apply Guard Definitions"),
283 self.trUtf8("""<p>The defined guards could not be""" 291 self.trUtf8("""The Mercurial process did not finish"""
284 """ applied.</p><p>Reason: {0}</p>""")\ 292 """ in time."""))
285 .format(error)) 293
286 else: 294 if error:
287 E5MessageBox.warning(self, 295 E5MessageBox.warning(self,
288 self.trUtf8("Apply Guard Definitions"), 296 self.trUtf8("Apply Guard Definitions"),
289 self.trUtf8("""The Mercurial process did not finish in time.""")) 297 self.trUtf8("""<p>The defined guards could not be"""
298 """ applied.</p><p>Reason: {0}</p>""")\
299 .format(error))
300 else:
301 self.__dirtyList = False
302 self.on_patchSelector_activated(self.patchNameLabel.text())

eric ide

mercurial