--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgSummaryDialog.py Sun Sep 27 14:17:38 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgSummaryDialog.py Tue Sep 29 18:58:05 2020 +0200 @@ -8,16 +8,11 @@ directory state. """ - import os -from PyQt5.QtCore import pyqtSlot, QProcess, QTimer +from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QDialog, QDialogButtonBox -from E5Gui import E5MessageBox - -from .HgUtilities import prepareProcess - from .Ui_HgSummaryDialog import Ui_HgSummaryDialog @@ -44,28 +39,6 @@ self.vcs = vcs self.vcs.committed.connect(self.__committed) - - self.process = QProcess() - prepareProcess(self.process, language="C") - self.process.finished.connect(self.__procFinished) - self.process.readyReadStandardOutput.connect(self.__readStdout) - self.process.readyReadStandardError.connect(self.__readStderr) - - def closeEvent(self, e): - """ - Protected slot implementing a close event handler. - - @param e close event (QCloseEvent) - """ - if ( - self.process is not None and - self.process.state() != QProcess.NotRunning - ): - self.process.terminate() - QTimer.singleShot(2000, self.process.kill) - self.process.waitForFinished(3000) - - e.accept() def start(self, path, mq=False, largefiles=False): """ @@ -99,36 +72,12 @@ if os.path.splitdrive(repodir)[1] == os.sep: return - if self.process: - self.process.kill() - - self.process.setWorkingDirectory(repodir) - - self.__buffer = [] - - self.process.start('hg', args) - procStarted = self.process.waitForStarted(5000) - if not procStarted: - E5MessageBox.critical( - self, - self.tr('Process Generation Error'), - self.tr( - 'The process {0} could not be started. ' - 'Ensure, that it is in the search path.' - ).format('hg')) - - def __finish(self): - """ - Private slot called when the process finished or the user pressed - the button. - """ - if ( - self.process is not None and - self.process.state() != QProcess.NotRunning - ): - self.process.terminate() - QTimer.singleShot(2000, self.process.kill) - self.process.waitForFinished(3000) + client = self.vcs.getClient() + output, error = client.runcommand(args) + if error: + self.__showError(error) + else: + self.__processOutput(output.splitlines()) self.refreshButton.setEnabled(True) @@ -143,53 +92,6 @@ elif button == self.refreshButton: self.on_refreshButton_clicked() - def __procFinished(self, exitCode, exitStatus): - """ - Private slot connected to the finished signal. - - @param exitCode exit code of the process (integer) - @param exitStatus exit status of the process (QProcess.ExitStatus) - """ - self.__processOutput(self.__buffer) - self.__finish() - - def __readStdout(self): - """ - Private slot to handle the readyReadStandardOutput signal. - - It reads the output of the process, formats it and inserts it into - the contents pane. - """ - if self.process is not None: - self.process.setReadChannel(QProcess.StandardOutput) - - while self.process.canReadLine(): - line = str(self.process.readLine(), self.vcs.getEncoding(), - 'replace') - self.__buffer.append(line) - - def __readStderr(self): - """ - Private slot to handle the readyReadStandardError signal. - - It reads the error output of the process and inserts it into the - error pane. - """ - if self.process is not None: - s = str(self.process.readAllStandardError(), - self.vcs.getEncoding(), 'replace') - self.__showError(s) - - def __showError(self, out): - """ - Private slot to show some error. - - @param out error to be shown (string) - """ - self.errorGroup.show() - self.errors.insertPlainText(out) - self.errors.ensureCursorVisible() - @pyqtSlot() def on_refreshButton_clicked(self): """ @@ -204,6 +106,16 @@ if self.isVisible(): self.on_refreshButton_clicked() + def __showError(self, out): + """ + Private slot to show some error. + + @param out error to be shown (string) + """ + self.errorGroup.show() + self.errors.insertPlainText(out) + self.errors.ensureCursorVisible() + def __processOutput(self, output): """ Private method to process the output into nice readable text.