diff -r eb01ab7aeb06 -r 757334671130 eric6/Plugins/VcsPlugins/vcsMercurial/HgDiffGenerator.py --- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgDiffGenerator.py Mon Oct 12 17:23:15 2020 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgDiffGenerator.py Mon Oct 12 17:39:45 2020 +0200 @@ -66,61 +66,63 @@ @return flag indicating a successful start of the diff command (boolean) """ - with E5OverrideCursor(): - if qdiff: - args = self.vcs.initCommand("qdiff") - else: - args = self.vcs.initCommand("diff") - - if self.vcs.hasSubrepositories(): - args.append("--subrepos") - - if bundle: - args.append('--repository') - args.append(bundle) - elif ( - self.vcs.bundleFile and - os.path.exists(self.vcs.bundleFile) - ): - args.append('--repository') - args.append(self.vcs.bundleFile) + if qdiff: + args = self.vcs.initCommand("qdiff") + else: + args = self.vcs.initCommand("diff") + + if self.vcs.hasSubrepositories(): + args.append("--subrepos") + + if bundle: + args.append('--repository') + args.append(bundle) + elif ( + self.vcs.bundleFile and + os.path.exists(self.vcs.bundleFile) + ): + args.append('--repository') + args.append(self.vcs.bundleFile) + + if versions is not None: + rev1 = self.__getVersionArg(versions[0]) + rev2 = None + if len(versions) == 2: + rev2 = self.__getVersionArg(versions[1]) - if versions is not None: - rev1 = self.__getVersionArg(versions[0]) - rev2 = None - if len(versions) == 2: - rev2 = self.__getVersionArg(versions[1]) - - if rev1 is not None or rev2 is not None: - args.append('-r') - if rev1 is not None and rev2 is not None: - args.append('{0}:{1}'.format(rev1, rev2)) - elif rev2 is None: - args.append(rev1) - elif rev1 is None: - args.append(':{0}'.format(rev2)) - - if isinstance(fn, list): - dname, fnames = self.vcs.splitPathList(fn) - self.vcs.addArguments(args, fn) - else: - dname, fname = self.vcs.splitPath(fn) - args.append(fn) - - self.__oldFile = "" - self.__oldFileLine = -1 - self.__fileSeparators = [] - self.__output = [] - self.__errors = [] - + if rev1 is not None or rev2 is not None: + args.append('-r') + if rev1 is not None and rev2 is not None: + args.append('{0}:{1}'.format(rev1, rev2)) + elif rev2 is None: + args.append(rev1) + elif rev1 is None: + args.append(':{0}'.format(rev2)) + + if isinstance(fn, list): + dname, fnames = self.vcs.splitPathList(fn) + self.vcs.addArguments(args, fn) + else: + dname, fname = self.vcs.splitPath(fn) + args.append(fn) + + self.__oldFile = "" + self.__oldFileLine = -1 + self.__fileSeparators = [] + self.__output = [] + self.__errors = [] + + with E5OverrideCursor(): out, err = self.__hgClient.runcommand(args) if err: self.__errors = err.splitlines(True) if out: - for line in out.splitlines(True): - self.__processOutputLine(line) + self.__output = out.splitlines(True) + for lineno, line in enumerate(self.__output): + if line.startswith(("--- ", "+++ ")): + self.__processFileLine(lineno, line) if self.__hgClient.wasCanceled(): break @@ -160,14 +162,17 @@ f = f.split("/", 1)[1] return f - def __processFileLine(self, line): + def __processFileLine(self, lineno, line): """ Private slot to process a line giving the old/new file. - @param line line to be processed (string) + @param lineno line number of line to be processed + @type int + @param line line to be processed + @type str """ if line.startswith('---'): - self.__oldFileLine = len(self.__output) + self.__oldFileLine = lineno self.__oldFile = self.__extractFileName(line) else: newFile = self.__extractFileName(line) @@ -177,17 +182,3 @@ else: self.__fileSeparators.append( (self.__oldFile, newFile, self.__oldFileLine)) - - def __processOutputLine(self, line): - """ - Private method to process the lines of output. - - @param line output line to be processed (string) - """ - if ( - line.startswith("--- ") or - line.startswith("+++ ") - ): - self.__processFileLine(line) - - self.__output.append(line)