38 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
38 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
39 |
39 |
40 self.process = QProcess() |
40 self.process = QProcess() |
41 self.vcs = vcs |
41 self.vcs = vcs |
42 self.__bookmarksList = None |
42 self.__bookmarksList = None |
|
43 self.__hgClient = vcs.getClient() |
43 |
44 |
44 self.bookmarksList.headerItem().setText(self.bookmarksList.columnCount(), "") |
45 self.bookmarksList.headerItem().setText(self.bookmarksList.columnCount(), "") |
45 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder) |
46 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder) |
46 |
47 |
47 self.process.finished.connect(self.__procFinished) |
48 self.process.finished.connect(self.__procFinished) |
86 return |
87 return |
87 |
88 |
88 args = [] |
89 args = [] |
89 args.append('bookmarks') |
90 args.append('bookmarks') |
90 |
91 |
91 self.process.kill() |
92 if self.__hgClient: |
92 self.process.setWorkingDirectory(repodir) |
|
93 |
|
94 self.process.start('hg', args) |
|
95 procStarted = self.process.waitForStarted() |
|
96 if not procStarted: |
|
97 self.inputGroup.setEnabled(False) |
93 self.inputGroup.setEnabled(False) |
98 self.inputGroup.hide() |
94 self.inputGroup.hide() |
99 E5MessageBox.critical(self, |
95 |
100 self.trUtf8('Process Generation Error'), |
96 out, err = self.__hgClient.runcommand(args) |
101 self.trUtf8( |
97 if err: |
102 'The process {0} could not be started. ' |
98 self.__showError(err) |
103 'Ensure, that it is in the search path.' |
99 if out: |
104 ).format('hg')) |
100 for line in out.splitlines(): |
|
101 self.__processOutputLine(line) |
|
102 self.__finish() |
105 else: |
103 else: |
106 self.inputGroup.setEnabled(True) |
104 self.process.kill() |
107 self.inputGroup.show() |
105 self.process.setWorkingDirectory(repodir) |
|
106 |
|
107 self.process.start('hg', args) |
|
108 procStarted = self.process.waitForStarted() |
|
109 if not procStarted: |
|
110 self.inputGroup.setEnabled(False) |
|
111 self.inputGroup.hide() |
|
112 E5MessageBox.critical(self, |
|
113 self.trUtf8('Process Generation Error'), |
|
114 self.trUtf8( |
|
115 'The process {0} could not be started. ' |
|
116 'Ensure, that it is in the search path.' |
|
117 ).format('hg')) |
|
118 else: |
|
119 self.inputGroup.setEnabled(True) |
|
120 self.inputGroup.show() |
108 |
121 |
109 def __finish(self): |
122 def __finish(self): |
110 """ |
123 """ |
111 Private slot called when the process finished or the user pressed the button. |
124 Private slot called when the process finished or the user pressed the button. |
112 """ |
125 """ |
140 @param button button that was clicked (QAbstractButton) |
153 @param button button that was clicked (QAbstractButton) |
141 """ |
154 """ |
142 if button == self.buttonBox.button(QDialogButtonBox.Close): |
155 if button == self.buttonBox.button(QDialogButtonBox.Close): |
143 self.close() |
156 self.close() |
144 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): |
157 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): |
145 self.__finish() |
158 if self.__hgClient: |
|
159 self.__hgClient.cancel() |
|
160 else: |
|
161 self.__finish() |
146 |
162 |
147 def __procFinished(self, exitCode, exitStatus): |
163 def __procFinished(self, exitCode, exitStatus): |
148 """ |
164 """ |
149 Private slot connected to the finished signal. |
165 Private slot connected to the finished signal. |
150 |
166 |
196 |
212 |
197 while self.process.canReadLine(): |
213 while self.process.canReadLine(): |
198 s = str(self.process.readLine(), |
214 s = str(self.process.readLine(), |
199 Preferences.getSystem("IOEncoding"), |
215 Preferences.getSystem("IOEncoding"), |
200 'replace').strip() |
216 'replace').strip() |
201 l = s.split() |
217 self.__processOutputLine(s) |
202 if l[-1][0] in "1234567890": |
218 |
203 # last element is a rev:changeset |
219 def __processOutputLine(self, line): |
204 rev, changeset = l[-1].split(":", 1) |
220 """ |
205 del l[-1] |
221 Private method to process the lines of output. |
206 if l[0] == "*": |
222 |
207 status = "current" |
223 @param line output line to be processed (string) |
208 del l[0] |
224 """ |
209 else: |
225 l = line.split() |
210 status = "" |
226 if l[-1][0] in "1234567890": |
211 name = " ".join(l) |
227 # last element is a rev:changeset |
212 self.__generateItem(rev, changeset, status, name) |
228 rev, changeset = l[-1].split(":", 1) |
213 if self.__bookmarksList is not None: |
229 del l[-1] |
214 self.__bookmarksList.append(name) |
230 if l[0] == "*": |
|
231 status = "current" |
|
232 del l[0] |
|
233 else: |
|
234 status = "" |
|
235 name = " ".join(l) |
|
236 self.__generateItem(rev, changeset, status, name) |
|
237 if self.__bookmarksList is not None: |
|
238 self.__bookmarksList.append(name) |
215 |
239 |
216 def __readStderr(self): |
240 def __readStderr(self): |
217 """ |
241 """ |
218 Private slot to handle the readyReadStderr signal. |
242 Private slot to handle the readyReadStderr signal. |
219 |
243 |
220 It reads the error output of the process and inserts it into the |
244 It reads the error output of the process and inserts it into the |
221 error pane. |
245 error pane. |
222 """ |
246 """ |
223 if self.process is not None: |
247 if self.process is not None: |
224 self.errorGroup.show() |
|
225 s = str(self.process.readAllStandardError(), |
248 s = str(self.process.readAllStandardError(), |
226 Preferences.getSystem("IOEncoding"), |
249 Preferences.getSystem("IOEncoding"), |
227 'replace') |
250 'replace') |
228 self.errors.insertPlainText(s) |
251 self.__showError(s) |
229 self.errors.ensureCursorVisible() |
252 |
|
253 def __showError(self, out): |
|
254 """ |
|
255 Private slot to show some error. |
|
256 |
|
257 @param out error to be shown (string) |
|
258 """ |
|
259 self.errorGroup.show() |
|
260 self.errors.insertPlainText(out) |
|
261 self.errors.ensureCursorVisible() |
230 |
262 |
231 def on_passwordCheckBox_toggled(self, isOn): |
263 def on_passwordCheckBox_toggled(self, isOn): |
232 """ |
264 """ |
233 Private slot to handle the password checkbox toggled. |
265 Private slot to handle the password checkbox toggled. |
234 |
266 |