--- a/src/eric7/Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/largefiles.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/largefiles.py Wed Jul 13 14:55:47 2022 +0200 @@ -24,18 +24,19 @@ """ Class implementing the largefiles extension interface. """ + def __init__(self, vcs): """ Constructor - + @param vcs reference to the Mercurial vcs object """ super().__init__(vcs) - + def hgLfconvert(self, direction, projectFile): """ Public slot to convert the repository format of the current project. - + @param direction direction of the conversion (string, one of 'largefiles' or 'normal') @param projectFile file name of the current project file (string) @@ -44,35 +45,36 @@ """ if direction not in ["largefiles", "normal"]: raise ValueError("Bad value for 'direction' parameter.") - + projectDir = os.path.dirname(projectFile) - + from .LfConvertDataDialog import LfConvertDataDialog + dlg = LfConvertDataDialog(projectDir, direction) if dlg.exec() == QDialog.DialogCode.Accepted: newName, minSize, patterns = dlg.getData() - newProjectFile = os.path.join( - newName, os.path.basename(projectFile)) - + newProjectFile = os.path.join(newName, os.path.basename(projectFile)) + # step 1: convert the current project to new project args = self.vcs.initCommand("lfconvert") - if direction == 'normal': - args.append('--to-normal') + if direction == "normal": + args.append("--to-normal") else: args.append("--size") args.append(str(minSize)) args.append(projectDir) args.append(newName) - if direction == 'largefiles' and patterns: + if direction == "largefiles" and patterns: args.extend(patterns) - - dia = HgDialog(self.tr('Convert Project - Converting'), self.vcs) + + dia = HgDialog(self.tr("Convert Project - Converting"), self.vcs) res = dia.startProcess(args) if res: dia.exec() res = dia.normalExit() and os.path.isdir( - os.path.join(newName, self.vcs.adminDir)) - + os.path.join(newName, self.vcs.adminDir) + ) + # step 2: create working directory contents if res: # step 2.1: start a command server client for the new repo @@ -84,43 +86,43 @@ self.tr("Mercurial Command Server"), self.tr( """<p>The Mercurial Command Server could not be""" - """ started.</p><p>Reason: {0}</p>""").format(err)) + """ 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, client=client) + dia = HgDialog( + self.tr("Convert Project - Extracting"), 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': + if direction == "largefiles": self.vcs.hgEditConfig( repoName=newName, - largefilesData={"minsize": minSize, - "pattern": patterns} + largefilesData={"minsize": minSize, "pattern": patterns}, ) else: - self.vcs.hgEditConfig( - repoName=newName, - withLargefiles=False - ) + self.vcs.hgEditConfig(repoName=newName, withLargefiles=False) QTimer.singleShot( - 0, lambda: ericApp().getObject("Project").openProject( - newProjectFile)) - + 0, + lambda: ericApp().getObject("Project").openProject(newProjectFile), + ) + def hgAdd(self, names, mode): """ Public method used to add a file to the Mercurial repository. - + @param names file name(s) to be added (string or list of string) @param mode add mode (string one of 'normal' or 'large') """ @@ -130,23 +132,21 @@ args.append("--large") else: args.append("--normal") - + if isinstance(names, list): self.vcs.addArguments(args, names) else: args.append(names) - - dia = HgDialog( - self.tr('Adding files to the Mercurial repository'), - self.vcs) + + dia = HgDialog(self.tr("Adding files to the Mercurial repository"), self.vcs) res = dia.startProcess(args) if res: dia.exec() - + def hgLfPull(self, revisions=None): """ Public method to pull missing large files into the local repository. - + @param revisions list of revisions to pull (list of string) """ revs = [] @@ -154,26 +154,27 @@ revs = revisions else: from .LfRevisionsInputDialog import LfRevisionsInputDialog + dlg = LfRevisionsInputDialog() if dlg.exec() == QDialog.DialogCode.Accepted: revs = dlg.getRevisions() - + if revs: args = self.vcs.initCommand("lfpull") args.append("-v") for rev in revs: args.append("--rev") args.append(rev) - + dia = HgDialog(self.tr("Pulling large files"), self.vcs) res = dia.startProcess(args) if res: dia.exec() - + def hgLfVerify(self, mode): """ Public method to verify large files integrity. - + @param mode verify mode (string; one of 'large', 'lfa' or 'lfc') """ args = self.vcs.initCommand("verify") @@ -185,10 +186,8 @@ args.append("--lfc") else: return - - dia = HgDialog( - self.tr('Verifying the integrity of large files'), - self.vcs) + + dia = HgDialog(self.tr("Verifying the integrity of large files"), self.vcs) res = dia.startProcess(args) if res: dia.exec()