7 Module implementing a dialog to show all guards for all patches. |
7 Module implementing a dialog to show all guards for all patches. |
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 QProcess, QCoreApplication |
18 from PyQt4.QtCore import QProcess, QCoreApplication |
19 from PyQt4.QtGui import QDialog, QTreeWidgetItem |
19 from PyQt4.QtGui import QDialog, QTreeWidgetItem |
20 |
20 |
21 from .Ui_HgQueuesListAllGuardsDialog import Ui_HgQueuesListAllGuardsDialog |
21 from .Ui_HgQueuesListAllGuardsDialog import Ui_HgQueuesListAllGuardsDialog |
22 |
22 |
23 import Preferences |
|
24 import UI.PixmapCache |
23 import UI.PixmapCache |
25 |
24 |
26 |
25 |
27 class HgQueuesListAllGuardsDialog(QDialog, Ui_HgQueuesListAllGuardsDialog): |
26 class HgQueuesListAllGuardsDialog(QDialog, Ui_HgQueuesListAllGuardsDialog): |
28 """ |
27 """ |
57 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
56 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
58 repodir = os.path.dirname(repodir) |
57 repodir = os.path.dirname(repodir) |
59 if os.path.splitdrive(repodir)[1] == os.sep: |
58 if os.path.splitdrive(repodir)[1] == os.sep: |
60 return |
59 return |
61 |
60 |
62 args = [] |
61 args = self.vcs.initCommand("qguard") |
63 args.append("qguard") |
|
64 args.append("--list") |
62 args.append("--list") |
65 |
63 |
66 output = "" |
64 output = "" |
67 if self.__hgClient: |
65 if self.__hgClient: |
68 output = self.__hgClient.runcommand(args)[0] |
66 output = self.__hgClient.runcommand(args)[0] |
69 else: |
67 else: |
70 ioEncoding = Preferences.getSystem("IOEncoding") |
|
71 process = QProcess() |
68 process = QProcess() |
72 process.setWorkingDirectory(repodir) |
69 process.setWorkingDirectory(repodir) |
73 process.start('hg', args) |
70 process.start('hg', args) |
74 procStarted = process.waitForStarted(5000) |
71 procStarted = process.waitForStarted(5000) |
75 if procStarted: |
72 if procStarted: |
76 finished = process.waitForFinished(30000) |
73 finished = process.waitForFinished(30000) |
77 if finished and process.exitCode() == 0: |
74 if finished and process.exitCode() == 0: |
78 output = str( |
75 output = str(process.readAllStandardOutput(), |
79 process.readAllStandardOutput(), ioEncoding, 'replace') |
76 self.vcs.getEncoding(), 'replace') |
80 |
77 |
81 if output: |
78 if output: |
82 guardsDict = {} |
79 guardsDict = {} |
83 for line in output.splitlines(): |
80 for line in output.splitlines(): |
84 if line: |
81 if line: |
94 elif guard.startswith("-"): |
91 elif guard.startswith("-"): |
95 icon = UI.PixmapCache.getIcon("minus.png") |
92 icon = UI.PixmapCache.getIcon("minus.png") |
96 guard = guard[1:] |
93 guard = guard[1:] |
97 else: |
94 else: |
98 icon = None |
95 icon = None |
99 guard = self.trUtf8("Unguarded") |
96 guard = self.tr("Unguarded") |
100 itm = QTreeWidgetItem(patchItm, [guard]) |
97 itm = QTreeWidgetItem(patchItm, [guard]) |
101 if icon: |
98 if icon: |
102 itm.setIcon(0, icon) |
99 itm.setIcon(0, icon) |
103 else: |
100 else: |
104 QTreeWidgetItem(self.guardsTree, [self.trUtf8("no patches found")]) |
101 QTreeWidgetItem(self.guardsTree, [self.tr("no patches found")]) |