69 def __finish(self): |
70 def __finish(self): |
70 """ |
71 """ |
71 Private slot called when the process finished or the user pressed |
72 Private slot called when the process finished or the user pressed |
72 the button. |
73 the button. |
73 """ |
74 """ |
74 if self.proc is not None and \ |
75 if self.process is not None and \ |
75 self.proc.state() != QProcess.NotRunning: |
76 self.process.state() != QProcess.NotRunning: |
76 self.proc.terminate() |
77 self.process.terminate() |
77 QTimer.singleShot(2000, self.proc.kill) |
78 QTimer.singleShot(2000, self.process.kill) |
78 self.proc.waitForFinished(3000) |
79 self.process.waitForFinished(3000) |
79 |
80 |
80 self.inputGroup.setEnabled(False) |
81 self.inputGroup.setEnabled(False) |
81 self.inputGroup.hide() |
82 self.inputGroup.hide() |
82 |
83 |
83 self.proc = None |
84 self.process = None |
84 |
85 |
85 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
86 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
86 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
87 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
87 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
88 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
88 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
89 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
146 if showArgs: |
147 if showArgs: |
147 self.resultbox.append(' '.join(args)) |
148 self.resultbox.append(' '.join(args)) |
148 self.resultbox.append('') |
149 self.resultbox.append('') |
149 |
150 |
150 if self.__hgClient is None: |
151 if self.__hgClient is None: |
151 self.proc = QProcess() |
152 self.process = QProcess() |
152 if environment: |
153 if environment: |
153 env = QProcessEnvironment.systemEnvironment() |
154 env = QProcessEnvironment.systemEnvironment() |
154 for key, value in environment.items(): |
155 for key, value in environment.items(): |
155 env.insert(key, value) |
156 env.insert(key, value) |
156 self.proc.setProcessEnvironment(env) |
157 self.process.setProcessEnvironment(env) |
157 |
158 |
158 self.proc.finished.connect(self.__procFinished) |
159 self.process.finished.connect(self.__procFinished) |
159 self.proc.readyReadStandardOutput.connect(self.__readStdout) |
160 self.process.readyReadStandardOutput.connect(self.__readStdout) |
160 self.proc.readyReadStandardError.connect(self.__readStderr) |
161 self.process.readyReadStandardError.connect(self.__readStderr) |
161 |
162 |
162 if workingDir: |
163 if workingDir: |
163 self.proc.setWorkingDirectory(workingDir) |
164 self.process.setWorkingDirectory(workingDir) |
164 self.proc.start('hg', args) |
165 self.process.start('hg', args) |
165 procStarted = self.proc.waitForStarted(5000) |
166 procStarted = self.process.waitForStarted(5000) |
166 if not procStarted: |
167 if not procStarted: |
167 self.buttonBox.setFocus() |
168 self.buttonBox.setFocus() |
168 self.inputGroup.setEnabled(False) |
169 self.inputGroup.setEnabled(False) |
169 E5MessageBox.critical( |
170 E5MessageBox.critical( |
170 self, |
171 self, |
217 Private slot to handle the readyReadStandardOutput signal. |
218 Private slot to handle the readyReadStandardOutput signal. |
218 |
219 |
219 It reads the output of the process, formats it and inserts it into |
220 It reads the output of the process, formats it and inserts it into |
220 the contents pane. |
221 the contents pane. |
221 """ |
222 """ |
222 if self.proc is not None: |
223 if self.process is not None: |
223 s = str(self.proc.readAllStandardOutput(), |
224 s = str(self.process.readAllStandardOutput(), |
224 self.vcs.getEncoding(), |
225 self.vcs.getEncoding(), |
225 'replace') |
226 'replace') |
226 self.__showOutput(s) |
227 self.__showOutput(s) |
227 |
228 |
228 def __showOutput(self, out): |
229 def __showOutput(self, out): |
248 Private slot to handle the readyReadStandardError signal. |
249 Private slot to handle the readyReadStandardError signal. |
249 |
250 |
250 It reads the error output of the process and inserts it into the |
251 It reads the error output of the process and inserts it into the |
251 error pane. |
252 error pane. |
252 """ |
253 """ |
253 if self.proc is not None: |
254 if self.process is not None: |
254 s = str(self.proc.readAllStandardError(), |
255 s = str(self.process.readAllStandardError(), |
255 self.vcs.getEncoding(), |
256 self.vcs.getEncoding(), |
256 'replace') |
257 'replace') |
257 self.__showError(s) |
258 self.__showError(s) |
258 |
259 |
259 def __showError(self, out): |
260 def __showError(self, out): |
292 self.errors.ensureCursorVisible() |
293 self.errors.ensureCursorVisible() |
293 else: |
294 else: |
294 self.errors.insertPlainText(inputTxt) |
295 self.errors.insertPlainText(inputTxt) |
295 self.errors.ensureCursorVisible() |
296 self.errors.ensureCursorVisible() |
296 |
297 |
297 self.proc.write(inputTxt) |
298 self.process.write(strToQByteArray(inputTxt)) |
298 |
299 |
299 self.passwordCheckBox.setChecked(False) |
300 self.passwordCheckBox.setChecked(False) |
300 self.input.clear() |
301 self.input.clear() |
301 |
302 |
302 def on_input_returnPressed(self): |
303 def on_input_returnPressed(self): |