51 |
51 |
52 self.diff = None |
52 self.diff = None |
53 self.process = None |
53 self.process = None |
54 self.vcs = vcs |
54 self.vcs = vcs |
55 self.vcs.committed.connect(self.__committed) |
55 self.vcs.committed.connect(self.__committed) |
|
56 self.__hgClient = self.vcs.getClient() |
56 |
57 |
57 self.statusList.headerItem().setText(self.__lastColumn, "") |
58 self.statusList.headerItem().setText(self.__lastColumn, "") |
58 self.statusList.header().setSortIndicator(self.__pathColumn, Qt.AscendingOrder) |
59 self.statusList.header().setSortIndicator(self.__pathColumn, Qt.AscendingOrder) |
59 |
60 |
60 self.menuactions = [] |
61 self.menuactions = [] |
178 self.restoreButton.setEnabled(False) |
179 self.restoreButton.setEnabled(False) |
179 |
180 |
180 self.statusFilterCombo.clear() |
181 self.statusFilterCombo.clear() |
181 self.__statusFilters = [] |
182 self.__statusFilters = [] |
182 |
183 |
183 if self.process: |
184 self.setWindowTitle(self.trUtf8('Mercurial Status')) |
184 self.process.kill() |
|
185 else: |
|
186 self.process = QProcess() |
|
187 self.process.finished.connect(self.__procFinished) |
|
188 self.process.readyReadStandardOutput.connect(self.__readStdout) |
|
189 self.process.readyReadStandardError.connect(self.__readStderr) |
|
190 |
185 |
191 args = [] |
186 args = [] |
192 args.append('status') |
187 args.append('status') |
193 self.vcs.addArguments(args, self.vcs.options['global']) |
188 self.vcs.addArguments(args, self.vcs.options['global']) |
194 self.vcs.addArguments(args, self.vcs.options['status']) |
189 self.vcs.addArguments(args, self.vcs.options['status']) |
205 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
200 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
206 repodir = os.path.dirname(repodir) |
201 repodir = os.path.dirname(repodir) |
207 if repodir == os.sep: |
202 if repodir == os.sep: |
208 return |
203 return |
209 |
204 |
210 self.process.setWorkingDirectory(repodir) |
205 if self.__hgClient: |
211 |
|
212 self.setWindowTitle(self.trUtf8('Mercurial Status')) |
|
213 |
|
214 self.process.start('hg', args) |
|
215 procStarted = self.process.waitForStarted() |
|
216 if not procStarted: |
|
217 self.inputGroup.setEnabled(False) |
206 self.inputGroup.setEnabled(False) |
218 self.inputGroup.hide() |
207 self.inputGroup.hide() |
219 E5MessageBox.critical(self, |
208 |
220 self.trUtf8('Process Generation Error'), |
209 out, err = self.__hgClient.runcommand(args) |
221 self.trUtf8( |
210 if err: |
222 'The process {0} could not be started. ' |
211 self.__showError(err) |
223 'Ensure, that it is in the search path.' |
212 if out: |
224 ).format('hg')) |
213 for line in out.splitlines(): |
|
214 self.__processOutputLine(line) |
|
215 self.__finish() |
225 else: |
216 else: |
226 self.inputGroup.setEnabled(True) |
217 if self.process: |
227 self.inputGroup.show() |
218 self.process.kill() |
|
219 else: |
|
220 self.process = QProcess() |
|
221 self.process.finished.connect(self.__procFinished) |
|
222 self.process.readyReadStandardOutput.connect(self.__readStdout) |
|
223 self.process.readyReadStandardError.connect(self.__readStderr) |
|
224 |
|
225 self.process.setWorkingDirectory(repodir) |
|
226 |
|
227 self.process.start('hg', args) |
|
228 procStarted = self.process.waitForStarted() |
|
229 if not procStarted: |
|
230 self.inputGroup.setEnabled(False) |
|
231 self.inputGroup.hide() |
|
232 E5MessageBox.critical(self, |
|
233 self.trUtf8('Process Generation Error'), |
|
234 self.trUtf8( |
|
235 'The process {0} could not be started. ' |
|
236 'Ensure, that it is in the search path.' |
|
237 ).format('hg')) |
|
238 else: |
|
239 self.inputGroup.setEnabled(True) |
|
240 self.inputGroup.show() |
228 |
241 |
229 def __finish(self): |
242 def __finish(self): |
230 """ |
243 """ |
231 Private slot called when the process finished or the user pressed the button. |
244 Private slot called when the process finished or the user pressed the button. |
232 """ |
245 """ |
295 |
308 |
296 while self.process.canReadLine(): |
309 while self.process.canReadLine(): |
297 line = str(self.process.readLine(), |
310 line = str(self.process.readLine(), |
298 Preferences.getSystem("IOEncoding"), |
311 Preferences.getSystem("IOEncoding"), |
299 'replace') |
312 'replace') |
300 if line[0] in "ACIMR?!" and line[1] == " ": |
313 self.__processOutputLine(line) |
301 status, path = line.strip().split(" ", 1) |
314 |
302 self.__generateItem(status, path) |
315 def __processOutputLine(self, line): |
|
316 """ |
|
317 Private method to process the lines of output. |
|
318 |
|
319 @param line output line to be processed (string) |
|
320 """ |
|
321 if line[0] in "ACIMR?!" and line[1] == " ": |
|
322 status, path = line.strip().split(" ", 1) |
|
323 self.__generateItem(status, path) |
303 |
324 |
304 def __readStderr(self): |
325 def __readStderr(self): |
305 """ |
326 """ |
306 Private slot to handle the readyReadStandardError signal. |
327 Private slot to handle the readyReadStandardError signal. |
307 |
328 |
311 if self.process is not None: |
332 if self.process is not None: |
312 self.errorGroup.show() |
333 self.errorGroup.show() |
313 s = str(self.process.readAllStandardError(), |
334 s = str(self.process.readAllStandardError(), |
314 Preferences.getSystem("IOEncoding"), |
335 Preferences.getSystem("IOEncoding"), |
315 'replace') |
336 'replace') |
316 self.errors.insertPlainText(s) |
337 self.__showError(s) |
317 self.errors.ensureCursorVisible() |
338 |
|
339 def __showError(self, out): |
|
340 """ |
|
341 Private slot to show some error. |
|
342 |
|
343 @param out error to be shown (string) |
|
344 """ |
|
345 self.errorGroup.show() |
|
346 self.errors.insertPlainText(out) |
|
347 self.errors.ensureCursorVisible() |
318 |
348 |
319 def on_passwordCheckBox_toggled(self, isOn): |
349 def on_passwordCheckBox_toggled(self, isOn): |
320 """ |
350 """ |
321 Private slot to handle the password checkbox toggled. |
351 Private slot to handle the password checkbox toggled. |
322 |
352 |