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

branch
eric7
changeset 11076
2989645b2618
parent 11075
282fc28b44ee
child 11077
e9bb2fe26a50
equal deleted inserted replaced
11075:282fc28b44ee 11076:2989645b2618
14 14
15 from eric7.EricWidgets import EricMessageBox 15 from eric7.EricWidgets import EricMessageBox
16 from eric7.EricWidgets.EricProgressDialog import EricProgressDialog 16 from eric7.EricWidgets.EricProgressDialog import EricProgressDialog
17 17
18 from ..HgExtension import HgExtension 18 from ..HgExtension import HgExtension
19 from ..HgUtilities import getHgExecutable 19 from ..HgUtilities import (
20 getHgExecutable,
21 isProgressInfo,
22 parseProgressInfo,
23 prepareProcess,
24 )
20 25
21 26
22 class Fastexport(HgExtension): 27 class Fastexport(HgExtension):
23 """ 28 """
24 Class implementing the fastexport extension interface. 29 Class implementing the fastexport extension interface.
66 repoPath = self.vcs.getClient().getRepository() 71 repoPath = self.vcs.getClient().getRepository()
67 hgExecutable = getHgExecutable() 72 hgExecutable = getHgExecutable()
68 73
69 args = self.vcs.initCommand("fastexport") 74 args = self.vcs.initCommand("fastexport")
70 args.extend(["--config", "progress.assume-tty=True"]) 75 args.extend(["--config", "progress.assume-tty=True"])
71 args.extend(["--config", "progress.format=topic number estimate"]) 76 args.extend(["--config", "progress.format=topic bar number estimate"])
72 if authormap: 77 if authormap:
73 args.extend(["--authormap", authormap]) 78 args.extend(["--authormap", authormap])
74 if importMarks: 79 if importMarks:
75 args.extend(["--import-marks", importMarks]) 80 args.extend(["--import-marks", importMarks])
76 if exportMarks: 81 if exportMarks:
79 args.extend(["--rev", revision]) 84 args.extend(["--rev", revision])
80 85
81 self.__progress = None 86 self.__progress = None
82 87
83 self.__process = QProcess(parent=self) 88 self.__process = QProcess(parent=self)
89 prepareProcess(self.__process)
84 self.__process.setStandardOutputFile(outputFile) 90 self.__process.setStandardOutputFile(outputFile)
85 self.__process.setWorkingDirectory(repoPath) 91 self.__process.setWorkingDirectory(repoPath)
86 self.__process.readyReadStandardError.connect(self.__readStderr) 92 self.__process.readyReadStandardError.connect(self.__readStderr)
87 self.__process.finished.connect(self.__processFinished) 93 self.__process.finished.connect(self.__processFinished)
88 self.__process.start(hgExecutable, args) 94 self.__process.start(hgExecutable, args)
94 """ 100 """
95 if self.__process is not None: 101 if self.__process is not None:
96 output = str( 102 output = str(
97 self.__process.readAllStandardError(), self.vcs.getEncoding(), "replace" 103 self.__process.readAllStandardError(), self.vcs.getEncoding(), "replace"
98 ) 104 )
99 if output.lstrip().startswith("exporting "): 105 msg = output.splitlines()[-1].strip()
100 msg = output.splitlines()[-1] 106 topic, value, maximum, estimate = parseProgressInfo(msg)
101 topic, number, estimate = msg.split(None, 2) 107 if topic:
102 value, maximum = number.split("/", 1) 108 # it is a valid progress line
103 if self.__progress is None: 109 if self.__progress is None:
104 self.__progress = EricProgressDialog( 110 self.__progress = EricProgressDialog(
105 labelText="", 111 labelText="",
106 cancelButtonText=self.tr("Cancel"), 112 cancelButtonText=self.tr("Cancel"),
107 minimum=0, 113 minimum=0,
108 maximum=int(maximum), 114 maximum=maximum,
109 labelFormat=self.tr("%v/%m Changesets"), 115 labelFormat=self.tr("%v/%m Changesets"),
110 parent=self.ui, 116 parent=self.ui,
111 ) 117 )
112 self.__progress.setWindowTitle(self.tr("Mercurial Fastexport")) 118 self.__progress.setWindowTitle(self.tr("Mercurial Fastexport"))
113 self.__progress.show() 119 self.__progress.show()
114 self.__progress.setLabelText( 120 self.__progress.setLabelText(
115 self.tr("Exporting repository (time remaining: {0}) ...").format( 121 self.tr("Exporting repository (time remaining: {0}) ...").format(
116 estimate 122 estimate
117 ) 123 )
118 ) 124 )
119 self.__progress.setValue(int(value)) 125 self.__progress.setValue(value)
120 126
121 if self.__progress.wasCanceled() and self.__process is not None: 127 if self.__progress.wasCanceled() and self.__process is not None:
122 self.__process.terminate() 128 self.__process.terminate()
123 129
124 else: 130 else:
125 if ( 131 if (
126 self.__progress 132 self.__progress
127 and not self.__progress.wasCanceled() 133 and not self.__progress.wasCanceled()
128 and self.output.strip() 134 and output.strip()
129 ): 135 ):
130 EricMessageBox.warning( 136 EricMessageBox.warning(
131 self.ui, 137 self.ui,
132 self.tr("Mercurial Fastexport"), 138 self.tr("Mercurial Fastexport"),
133 self.tr( 139 self.tr(

eric ide

mercurial