diff -r dbeeed55df08 -r 5fb53279f2df eric6/Plugins/VcsPlugins/vcsMercurial/HgDiffGenerator.py --- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgDiffGenerator.py Wed Jan 08 19:13:57 2020 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgDiffGenerator.py Mon Jan 13 19:23:08 2020 +0100 @@ -7,10 +7,9 @@ Module implementing a class to generate the output of the hg diff command. """ - import os -from PyQt5.QtCore import pyqtSignal, QProcess, QTimer, QObject +from PyQt5.QtCore import pyqtSignal, QObject class HgDiffGenerator(QObject): @@ -33,29 +32,13 @@ self.vcs = vcs self.__hgClient = self.vcs.getClient() - if self.__hgClient: - self.process = None - else: - self.process = QProcess() - self.process.finished.connect(self.__finish) - self.process.readyReadStandardOutput.connect(self.__readStdout) - self.process.readyReadStandardError.connect(self.__readStderr) def stopProcess(self): """ Public slot to stop the diff process. """ - if self.__hgClient: - if self.__hgClient.isExecuting(): - self.__hgClient.cancel() - else: - 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) + if self.__hgClient.isExecuting(): + self.__hgClient.cancel() def __getVersionArg(self, version): """ @@ -124,34 +107,18 @@ self.__output = [] self.__errors = [] - if self.__hgClient: - out, err = self.__hgClient.runcommand(args) - - if err: - self.__errors = err.splitlines(True) - - if out: - for line in out.splitlines(True): - self.__processOutputLine(line) - if self.__hgClient.wasCanceled(): - break - - self.__finish() - else: - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - - self.process.kill() - self.process.setWorkingDirectory(repodir) - - self.process.start('hg', args) - procStarted = self.process.waitForStarted(5000) - if not procStarted: - return False + out, err = self.__hgClient.runcommand(args) + + if err: + self.__errors = err.splitlines(True) + + if out: + for line in out.splitlines(True): + self.__processOutputLine(line) + if self.__hgClient.wasCanceled(): + break + + self.__finish() return True @@ -218,29 +185,3 @@ self.__processFileLine(line) self.__output.append(line) - - 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. - """ - self.process.setReadChannel(QProcess.StandardOutput) - - while self.process.canReadLine(): - line = str(self.process.readLine(), self.vcs.getEncoding(), - 'replace') - self.__processOutputLine(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.__errors.append(s)