diff -r c4ee8a81584c -r ff2971513d6d eric6/Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/largefiles.py --- a/eric6/Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/largefiles.py Tue Jan 12 20:03:30 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/largefiles.py Wed Jan 13 17:46:13 2021 +0100 @@ -13,9 +13,11 @@ from PyQt5.QtWidgets import QDialog from E5Gui.E5Application import e5App +from E5Gui import E5MessageBox from ..HgExtension import HgExtension from ..HgDialog import HgDialog +from ..HgClient import HgClient class Largefiles(HgExtension): @@ -45,13 +47,6 @@ projectDir = os.path.dirname(projectFile) - # find the root of the repo - repodir = projectDir - 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 - from .LfConvertDataDialog import LfConvertDataDialog dlg = LfConvertDataDialog(projectDir, direction) if dlg.exec() == QDialog.Accepted: @@ -72,7 +67,7 @@ args.extend(patterns) dia = HgDialog(self.tr('Convert Project - Converting'), self.vcs) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() res = dia.normalExit() and os.path.isdir( @@ -80,22 +75,44 @@ # step 2: create working directory contents if res: + # step 2.1: start a command server client for the new repo + client = HgClient(newName, "utf-8", self.vcs) + ok, err = client.startServer() + if not ok: + E5MessageBox.warning( + None, + self.tr("Mercurial Command Server"), + self.tr( + """<p>The Mercurial Command Server could not be""" + """ started.</p><p>Reason: {0}</p>""").format(err)) + return + + # step 2.2: create working directory contents args = self.vcs.initCommand("update") args.append("--verbose") dia = HgDialog(self.tr('Convert Project - Extracting'), - self.vcs, useClient=False) - res = dia.startProcess(args, newName) + self.vcs, client=client) + res = dia.startProcess(args) if res: dia.exec() res = dia.normalExit() and os.path.isfile(newProjectFile) + + # step 2.3: stop the command server client for the new repo + client.stopServer() # step 3: close current project and open new one if res: if direction == 'largefiles': - self.vcs.hgEditConfig(newName, largefilesData={ - "minsize": minSize, "pattern": patterns}) + self.vcs.hgEditConfig( + repoName=newName, + largefilesData={"minsize": minSize, + "pattern": patterns} + ) else: - self.vcs.hgEditConfig(newName, withLargefiles=False) + self.vcs.hgEditConfig( + repoName=newName, + withLargefiles=False + ) QTimer.singleShot( 0, lambda: e5App().getObject("Project").openProject( newProjectFile)) @@ -115,18 +132,6 @@ args.append("--normal") if isinstance(names, list): - dname = self.vcs.splitPathList(names)[0] - else: - dname = self.vcs.splitPath(names)[0] - - # 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 - - if isinstance(names, list): self.vcs.addArguments(args, names) else: args.append(names) @@ -134,7 +139,7 @@ dia = HgDialog( self.tr('Adding files to the Mercurial repository'), self.vcs) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() @@ -165,20 +170,12 @@ if res: dia.exec() - def hgLfVerify(self, projectDir, mode): + def hgLfVerify(self, mode): """ Public method to verify large files integrity. - @param projectDir directory name of the project (string) @param mode verify mode (string; one of 'large', 'lfa' or 'lfc') """ - # find the root of the repo - repodir = projectDir - 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 - args = self.vcs.initCommand("verify") if mode == "large": args.append("--large") @@ -192,6 +189,6 @@ dia = HgDialog( self.tr('Verifying the integrity of large files'), self.vcs) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec()