78 @param patch selected patch name (empty for current patch) |
79 @param patch selected patch name (empty for current patch) |
79 """ |
80 """ |
80 self.guardsList.clear() |
81 self.guardsList.clear() |
81 self.patchNameLabel.setText("") |
82 self.patchNameLabel.setText("") |
82 |
83 |
83 ioEncoding = Preferences.getSystem("IOEncoding") |
|
84 process = QProcess() |
|
85 args = [] |
84 args = [] |
86 args.append("qguard") |
85 args.append("qguard") |
87 if patch: |
86 if patch: |
88 args.append(patch) |
87 args.append(patch) |
89 |
88 |
90 process.setWorkingDirectory(self.__repodir) |
89 output = "" |
91 process.start('hg', args) |
90 if self.__hgClient: |
92 procStarted = process.waitForStarted() |
91 output = self.__hgClient.runcommand(args)[0].strip() |
93 if procStarted: |
92 else: |
94 finished = process.waitForFinished(30000) |
93 ioEncoding = Preferences.getSystem("IOEncoding") |
95 if finished and process.exitCode() == 0: |
94 process = QProcess() |
96 output = \ |
95 process.setWorkingDirectory(self.__repodir) |
97 str(process.readAllStandardOutput(), ioEncoding, 'replace').strip() |
96 process.start('hg', args) |
98 if output: |
97 procStarted = process.waitForStarted() |
99 patchName, guards = output.split(":", 1) |
98 if procStarted: |
100 self.patchNameLabel.setText(patchName) |
99 finished = process.waitForFinished(30000) |
101 guardsList = guards.strip().split() |
100 if finished and process.exitCode() == 0: |
102 for guard in guardsList: |
101 output = \ |
103 if guard.startswith("+"): |
102 str(process.readAllStandardOutput(), |
104 icon = UI.PixmapCache.getIcon("plus.png") |
103 ioEncoding, 'replace').strip() |
105 guard = guard[1:] |
104 |
106 elif guard.startswith("-"): |
105 if output: |
107 icon = UI.PixmapCache.getIcon("minus.png") |
106 patchName, guards = output.split(":", 1) |
108 guard = guard[1:] |
107 self.patchNameLabel.setText(patchName) |
109 else: |
108 guardsList = guards.strip().split() |
110 icon = None |
109 for guard in guardsList: |
111 guard = self.trUtf8("Unguarded") |
110 if guard.startswith("+"): |
112 itm = QListWidgetItem(guard, self.guardsList) |
111 icon = UI.PixmapCache.getIcon("plus.png") |
113 if icon: |
112 guard = guard[1:] |
114 itm.setIcon(icon) |
113 elif guard.startswith("-"): |
|
114 icon = UI.PixmapCache.getIcon("minus.png") |
|
115 guard = guard[1:] |
|
116 else: |
|
117 icon = None |
|
118 guard = self.trUtf8("Unguarded") |
|
119 itm = QListWidgetItem(guard, self.guardsList) |
|
120 if icon: |
|
121 itm.setIcon(icon) |