src/eric7/Plugins/VcsPlugins/vcsMercurial/FastexportExtension/fastexport.py

branch
eric7
changeset 11076
2989645b2618
parent 11075
282fc28b44ee
child 11077
e9bb2fe26a50
--- a/src/eric7/Plugins/VcsPlugins/vcsMercurial/FastexportExtension/fastexport.py	Tue Dec 03 14:21:36 2024 +0100
+++ b/src/eric7/Plugins/VcsPlugins/vcsMercurial/FastexportExtension/fastexport.py	Tue Dec 03 17:46:41 2024 +0100
@@ -16,7 +16,12 @@
 from eric7.EricWidgets.EricProgressDialog import EricProgressDialog
 
 from ..HgExtension import HgExtension
-from ..HgUtilities import getHgExecutable
+from ..HgUtilities import (
+    getHgExecutable,
+    isProgressInfo,
+    parseProgressInfo,
+    prepareProcess,
+)
 
 
 class Fastexport(HgExtension):
@@ -68,7 +73,7 @@
 
             args = self.vcs.initCommand("fastexport")
             args.extend(["--config", "progress.assume-tty=True"])
-            args.extend(["--config", "progress.format=topic number estimate"])
+            args.extend(["--config", "progress.format=topic bar number estimate"])
             if authormap:
                 args.extend(["--authormap", authormap])
             if importMarks:
@@ -81,6 +86,7 @@
             self.__progress = None
 
             self.__process = QProcess(parent=self)
+            prepareProcess(self.__process)
             self.__process.setStandardOutputFile(outputFile)
             self.__process.setWorkingDirectory(repoPath)
             self.__process.readyReadStandardError.connect(self.__readStderr)
@@ -96,16 +102,16 @@
             output = str(
                 self.__process.readAllStandardError(), self.vcs.getEncoding(), "replace"
             )
-            if output.lstrip().startswith("exporting "):
-                msg = output.splitlines()[-1]
-                topic, number, estimate = msg.split(None, 2)
-                value, maximum = number.split("/", 1)
+            msg = output.splitlines()[-1].strip()
+            topic, value, maximum, estimate = parseProgressInfo(msg)
+            if topic:
+                # it is a valid progress line
                 if self.__progress is None:
                     self.__progress = EricProgressDialog(
                         labelText="",
                         cancelButtonText=self.tr("Cancel"),
                         minimum=0,
-                        maximum=int(maximum),
+                        maximum=maximum,
                         labelFormat=self.tr("%v/%m Changesets"),
                         parent=self.ui,
                     )
@@ -116,7 +122,7 @@
                         estimate
                     )
                 )
-                self.__progress.setValue(int(value))
+                self.__progress.setValue(value)
 
                 if self.__progress.wasCanceled() and self.__process is not None:
                     self.__process.terminate()
@@ -125,7 +131,7 @@
                 if (
                     self.__progress
                     and not self.__progress.wasCanceled()
-                    and self.output.strip()
+                    and output.strip()
                 ):
                     EricMessageBox.warning(
                         self.ui,

eric ide

mercurial