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 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 try: |
11 try: |
12 str = unicode # __IGNORE_WARNING__ |
12 str = unicode |
13 except (NameError): |
13 except NameError: |
14 pass |
14 pass |
15 |
15 |
16 import os |
16 import os |
17 |
17 |
18 from PyQt4.QtCore import pyqtSlot, QProcess, QTimer, QCoreApplication |
18 from PyQt4.QtCore import pyqtSlot, QProcess, QTimer, QCoreApplication |
19 from PyQt4.QtGui import QDialog, QListWidgetItem |
19 from PyQt4.QtGui import QDialog, QListWidgetItem |
20 |
20 |
21 from .Ui_HgQueuesListGuardsDialog import Ui_HgQueuesListGuardsDialog |
21 from .Ui_HgQueuesListGuardsDialog import Ui_HgQueuesListGuardsDialog |
22 |
22 |
23 import Preferences |
|
24 import UI.PixmapCache |
23 import UI.PixmapCache |
25 |
24 |
26 |
25 |
27 class HgQueuesListGuardsDialog(QDialog, Ui_HgQueuesListGuardsDialog): |
26 class HgQueuesListGuardsDialog(QDialog, Ui_HgQueuesListGuardsDialog): |
28 """ |
27 """ |
92 @param patch selected patch name (empty for current patch) |
91 @param patch selected patch name (empty for current patch) |
93 """ |
92 """ |
94 self.guardsList.clear() |
93 self.guardsList.clear() |
95 self.patchNameLabel.setText("") |
94 self.patchNameLabel.setText("") |
96 |
95 |
97 args = [] |
96 args = self.vcs.initCommand("qguard") |
98 args.append("qguard") |
|
99 if patch: |
97 if patch: |
100 args.append(patch) |
98 args.append(patch) |
101 |
99 |
102 output = "" |
100 output = "" |
103 if self.__hgClient: |
101 if self.__hgClient: |
104 output = self.__hgClient.runcommand(args)[0].strip() |
102 output = self.__hgClient.runcommand(args)[0].strip() |
105 else: |
103 else: |
106 ioEncoding = Preferences.getSystem("IOEncoding") |
|
107 process = QProcess() |
104 process = QProcess() |
108 process.setWorkingDirectory(self.__repodir) |
105 process.setWorkingDirectory(self.__repodir) |
109 process.start('hg', args) |
106 process.start('hg', args) |
110 procStarted = process.waitForStarted(5000) |
107 procStarted = process.waitForStarted(5000) |
111 if procStarted: |
108 if procStarted: |
112 finished = process.waitForFinished(30000) |
109 finished = process.waitForFinished(30000) |
113 if finished and process.exitCode() == 0: |
110 if finished and process.exitCode() == 0: |
114 output = \ |
111 output = str(process.readAllStandardOutput(), |
115 str(process.readAllStandardOutput(), |
112 self.vcs.getEncoding(), 'replace').strip() |
116 ioEncoding, 'replace').strip() |
|
117 |
113 |
118 if output: |
114 if output: |
119 patchName, guards = output.split(":", 1) |
115 patchName, guards = output.split(":", 1) |
120 self.patchNameLabel.setText(patchName) |
116 self.patchNameLabel.setText(patchName) |
121 guardsList = guards.strip().split() |
117 guardsList = guards.strip().split() |