Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesDefineGuardsDialog.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2791
a9577f248f04
parent 3008
7848489bcb92
child 3058
0a02c433f52d
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
14 pass 14 pass
15 15
16 import os 16 import os
17 17
18 from PyQt4.QtCore import pyqtSlot, Qt, QProcess, QTimer, QCoreApplication 18 from PyQt4.QtCore import pyqtSlot, Qt, QProcess, QTimer, QCoreApplication
19 from PyQt4.QtGui import QDialog, QDialogButtonBox, QAbstractButton, QListWidgetItem 19 from PyQt4.QtGui import QDialog, QDialogButtonBox, QAbstractButton, \
20 QListWidgetItem
20 21
21 from E5Gui import E5MessageBox 22 from E5Gui import E5MessageBox
22 23
23 from .Ui_HgQueuesDefineGuardsDialog import Ui_HgQueuesDefineGuardsDialog 24 from .Ui_HgQueuesDefineGuardsDialog import Ui_HgQueuesDefineGuardsDialog
24 25
110 self.on_patchSelector_activated("") 111 self.on_patchSelector_activated("")
111 112
112 @pyqtSlot(str) 113 @pyqtSlot(str)
113 def on_patchSelector_activated(self, patch): 114 def on_patchSelector_activated(self, patch):
114 """ 115 """
115 Private slot to get the list of guards defined for the given patch name. 116 Private slot to get the list of guards defined for the given patch
117 name.
116 118
117 @param patch selected patch name (empty for current patch) 119 @param patch selected patch name (empty for current patch)
118 """ 120 """
119 if self.__dirtyList: 121 if self.__dirtyList:
120 res = E5MessageBox.question(self, 122 res = E5MessageBox.question(self,
153 process.start('hg', args) 155 process.start('hg', args)
154 procStarted = process.waitForStarted(5000) 156 procStarted = process.waitForStarted(5000)
155 if procStarted: 157 if procStarted:
156 finished = process.waitForFinished(30000) 158 finished = process.waitForFinished(30000)
157 if finished and process.exitCode() == 0: 159 if finished and process.exitCode() == 0:
158 output = \ 160 output = str(process.readAllStandardOutput(), ioEncoding,
159 str(process.readAllStandardOutput(), ioEncoding, 'replace').strip() 161 'replace').strip()
160 162
161 if output: 163 if output:
162 patchName, guards = output.split(":", 1) 164 patchName, guards = output.split(":", 1)
163 self.patchNameLabel.setText(patchName) 165 self.patchNameLabel.setText(patchName)
164 guardsList = guards.strip().split() 166 guardsList = guards.strip().split()
239 """ 241 """
240 Private slot to remove guard definitions from the list. 242 Private slot to remove guard definitions from the list.
241 """ 243 """
242 res = E5MessageBox.yesNo(self, 244 res = E5MessageBox.yesNo(self,
243 self.trUtf8("Remove Guards"), 245 self.trUtf8("Remove Guards"),
244 self.trUtf8("""Do you really want to remove the selected guards?""")) 246 self.trUtf8(
247 """Do you really want to remove the selected guards?"""))
245 if res: 248 if res:
246 for guardItem in self.guardsList.selectedItems(): 249 for guardItem in self.guardsList.selectedItems():
247 row = self.guardsList.row(guardItem) 250 row = self.guardsList.row(guardItem)
248 itm = self.guardsList.takeItem(row) 251 itm = self.guardsList.takeItem(row)
249 del itm 252 del itm
294 procStarted = process.waitForStarted(5000) 297 procStarted = process.waitForStarted(5000)
295 if procStarted: 298 if procStarted:
296 finished = process.waitForFinished(30000) 299 finished = process.waitForFinished(30000)
297 if finished: 300 if finished:
298 if process.exitCode() != 0: 301 if process.exitCode() != 0:
299 error = \ 302 error = str(
300 str(process.readAllStandardError(), ioEncoding, 'replace') 303 process.readAllStandardError(), ioEncoding,
304 'replace')
301 else: 305 else:
302 E5MessageBox.warning(self, 306 E5MessageBox.warning(self,
303 self.trUtf8("Apply Guard Definitions"), 307 self.trUtf8("Apply Guard Definitions"),
304 self.trUtf8("""The Mercurial process did not finish""" 308 self.trUtf8(
305 """ in time.""")) 309 """The Mercurial process did not finish"""
310 """ in time."""))
306 311
307 if error: 312 if error:
308 E5MessageBox.warning(self, 313 E5MessageBox.warning(self,
309 self.trUtf8("Apply Guard Definitions"), 314 self.trUtf8("Apply Guard Definitions"),
310 self.trUtf8("""<p>The defined guards could not be""" 315 self.trUtf8("""<p>The defined guards could not be"""
311 """ applied.</p><p>Reason: {0}</p>""")\ 316 """ applied.</p><p>Reason: {0}</p>""")\
312 .format(error)) 317 .format(error))
313 else: 318 else:
314 self.__dirtyList = False 319 self.__dirtyList = False
315 self.on_patchSelector_activated(self.patchNameLabel.text()) 320 self.on_patchSelector_activated(
321 self.patchNameLabel.text())

eric ide

mercurial