--- a/eric6/Plugins/VcsPlugins/vcsMercurial/hg.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/hg.py Tue Jan 12 20:03:30 2021 +0100 @@ -479,25 +479,13 @@ if not res: return - if isinstance(name, list): - dname, fnames = self.splitPathList(name) - else: - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - if self.__commitDialog is not None: (msg, amend, commitSubrepositories, author, dateTime) = self.__commitDialog.getCommitData() self.__commitDialog.deleteLater() self.__commitDialog = None if amend and not msg: - msg = self.__getMostRecentCommitMessage(repodir) + msg = self.__getMostRecentCommitMessage() else: amend = False commitSubrepositories = False @@ -537,13 +525,12 @@ if isinstance(name, list): self.addArguments(args, name) else: - if dname != repodir or fname != ".": - args.append(name) + args.append(name) dia = HgDialog( self.tr('Committing changes to Mercurial repository'), self) - res = dia.startProcess(args, dname) + res = dia.startProcess(args) if res: dia.exec() self.committed.emit() @@ -554,15 +541,13 @@ self.__forgotNames = [] self.checkVCSStatus() - def __getMostRecentCommitMessage(self, repodir): + def __getMostRecentCommitMessage(self): """ Private method to get the most recent commit message. Note: This message is extracted from the parent commit of the working directory. - @param repodir path containing the repository - @type str @return most recent commit message @rtype str """ @@ -576,13 +561,12 @@ return output - def vcsUpdate(self, name, noDialog=False, revision=None): + def vcsUpdate(self, name=None, noDialog=False, revision=None): """ Public method used to update a file/directory with the Mercurial repository. - @param name file/directory name to be updated (string or list of - strings) + @param name file/directory name to be updated (not used) @param noDialog flag indicating quiet operations (boolean) @param revision revision to update to (string) @return flag indicating, that the update contained an add @@ -595,18 +579,6 @@ args.append("-r") args.append(revision) - if isinstance(name, list): - dname, fnames = self.splitPathList(name) - else: - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - if noDialog: out, err = self.__client.runcommand(args) res = False @@ -614,7 +586,7 @@ dia = HgDialog(self.tr( 'Synchronizing with the Mercurial repository'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() res = dia.hasAddOrDelete() @@ -633,24 +605,6 @@ args.append("-v") if isinstance(name, list): - if isDir: - dname, fname = os.path.split(name[0]) - else: - dname, fnames = self.splitPathList(name) - else: - if isDir: - dname, fname = os.path.split(name) - else: - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - - if isinstance(name, list): self.addArguments(args, name) else: args.append(name) @@ -662,7 +616,7 @@ self.tr( 'Adding files/directories to the Mercurial repository'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() @@ -706,19 +660,10 @@ args.append('--force') if isinstance(name, list): - dname, fnames = self.splitPathList(name) self.addArguments(args, name) else: - dname, fname = self.splitPath(name) args.append(name) - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - if noDialog: out, err = self.__client.runcommand(args) res = err == "" @@ -728,7 +673,7 @@ 'Removing files/directories from the Mercurial' ' repository'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() res = dia.normalExitWithoutErrors() @@ -768,20 +713,12 @@ args.append(name) args.append(target) - dname, fname = self.splitPath(name) - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - if noDialog: out, err = self.__client.runcommand(args) res = err == "" else: dia = HgDialog(self.tr('Renaming {0}').format(name), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() res = dia.normalExit() @@ -860,10 +797,9 @@ self.summary = HgSummaryDialog(self) self.summary.show() self.summary.raise_() - self.summary.start(self.__projectHelper.getProject().getProjectPath(), - mq=mq, largefiles=largefiles) + self.summary.start(mq=mq, largefiles=largefiles) - def vcsTag(self, name, revision=None, tagName=None): + def vcsTag(self, name=None, revision=None, tagName=None): """ Public method used to set/remove a tag in the Mercurial repository. @@ -873,17 +809,8 @@ @param tagName name of the tag (string) @return flag indicating a performed tag action (boolean) """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - from .HgTagDialog import HgTagDialog - dlg = HgTagDialog(self.hgGetTagsList(repodir, withType=True), + dlg = HgTagDialog(self.hgGetTagsList(withType=True), revision, tagName) if dlg.exec() == QDialog.Accepted: tag, revision, tagOp, force = dlg.getParameters() @@ -915,7 +842,7 @@ dia = HgDialog(self.tr('Tagging in the Mercurial repository'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() @@ -934,21 +861,12 @@ args.append("--no-backup") args.append("-v") if isinstance(name, list): - dname, fnames = self.splitPathList(name) self.addArguments(args, name) names = name[:] else: - dname, fname = self.splitPath(name) args.append(name) names = [name] - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - project = e5App().getObject("Project") names = [project.getRelativePath(nam) for nam in names] if names[0]: @@ -971,7 +889,7 @@ """ the project?""")) if yes: dia = HgDialog(self.tr('Reverting changes'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() res = dia.hasAddOrDelete() @@ -990,20 +908,11 @@ @param rev revision to merge with @type str """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - if not rev: from .HgMergeDialog import HgMergeDialog - dlg = HgMergeDialog(self.hgGetTagsList(repodir), - self.hgGetBranchesList(repodir), - self.hgGetBookmarksList(repodir)) + dlg = HgMergeDialog(self.hgGetTagsList(), + self.hgGetBranchesList(), + self.hgGetBookmarksList()) if dlg.exec() == QDialog.Accepted: rev, force = dlg.getParameters() else: @@ -1021,8 +930,8 @@ args.append("--rev") args.append(rev) - dia = HgDialog(self.tr('Merging').format(name), self) - res = dia.startProcess(args, repodir) + dia = HgDialog(self.tr('Merging'), self) + res = dia.startProcess(args) if res: dia.exec() self.checkVCSStatus() @@ -1038,21 +947,12 @@ args.append("--tool") args.append("internal:merge") if isinstance(name, list): - dname, fnames = self.splitPathList(name) self.addArguments(args, name) names = name[:] else: - dname, fname = self.splitPath(name) args.append(name) names = [name] - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - project = e5App().getObject("Project") names = [project.getRelativePath(nam) for nam in names] if names[0]: @@ -1074,7 +974,7 @@ self.tr("""Do you really want to re-merge the project?""")) if yes: dia = HgDialog(self.tr('Re-Merging').format(name), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() self.checkVCSStatus() @@ -1088,19 +988,10 @@ @return flag indicating, that the switch contained an add or delete (boolean) """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - from .HgRevisionSelectionDialog import HgRevisionSelectionDialog - dlg = HgRevisionSelectionDialog(self.hgGetTagsList(repodir), - self.hgGetBranchesList(repodir), - self.hgGetBookmarksList(repodir), + dlg = HgRevisionSelectionDialog(self.hgGetTagsList(), + self.hgGetBranchesList(), + self.hgGetBookmarksList(), self.tr("Current branch tip")) if dlg.exec() == QDialog.Accepted: rev = dlg.getRevision() @@ -1291,15 +1182,8 @@ args = [] self.addArguments(args, commandList) - # find the root of the repo - repodir = name - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - dia = HgDialog(self.tr('Mercurial command'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() @@ -1451,17 +1335,9 @@ args.append(name) args.append(target) - dname, fname = self.splitPath(name) - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - dia = HgDialog( self.tr('Copying {0}').format(name), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() res = dia.normalExit() @@ -1475,11 +1351,10 @@ project.appendFile(target) return res - def hgGetTagsList(self, repodir, withType=False): + def hgGetTagsList(self, withType=False): """ Public method to get the list of tags. - @param repodir directory name of the repository (string) @param withType flag indicating to get the tag type as well (boolean) @return list of tags (list of string) or list of tuples of tag name and flag indicating a local tag (list of tuple of string @@ -1515,11 +1390,10 @@ self.tagsList = tagsList return self.tagsList[:] - def hgGetBranchesList(self, repodir): + def hgGetBranchesList(self): """ Public method to get the list of branches. - @param repodir directory name of the repository (string) @return list of branches (list of string) """ args = self.initCommand("branches") @@ -1542,11 +1416,10 @@ return self.branchesList[:] - def hgListTagBranch(self, path, tags=True): + def hgListTagBranch(self, tags=True): """ Public method used to list the available tags or branches. - @param path directory name of the project (string) @param tags flag indicating listing of branches or tags (False = branches, True = tags) """ @@ -1560,8 +1433,8 @@ else: self.tagsList = [] allTagsBranchesList = None - self.tagbranchList.start(path, tags, - self.tagsList, allTagsBranchesList) + self.tagbranchList.start( + tags, self.tagsList, allTagsBranchesList) else: if not self.showedBranches: self.showedBranches = True @@ -1569,9 +1442,8 @@ else: self.branchesList = [] allTagsBranchesList = None - self.tagbranchList.start(path, tags, - self.branchesList, - self.allTagsBranchesList) + self.tagbranchList.start( + tags, self.branchesList, self.allTagsBranchesList) def hgAnnotate(self, name): """ @@ -1601,10 +1473,8 @@ @param name file/directory name to be diffed (string) """ if isinstance(name, list): - dname, fnames = self.splitPathList(name) names = name[:] else: - dname, fname = self.splitPath(name) names = [name] for nam in names: if os.path.isfile(nam): @@ -1616,17 +1486,10 @@ if nam == project.ppath and not project.saveAllScripts(): return - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - from .HgRevisionsSelectionDialog import HgRevisionsSelectionDialog - dlg = HgRevisionsSelectionDialog(self.hgGetTagsList(repodir), - self.hgGetBranchesList(repodir), - self.hgGetBookmarksList(repodir)) + dlg = HgRevisionsSelectionDialog(self.hgGetTagsList(), + self.hgGetBranchesList(), + self.hgGetBookmarksList()) if dlg.exec() == QDialog.Accepted: revisions = dlg.getRevisions() if self.diff is None: @@ -1670,17 +1533,10 @@ raise ValueError("Wrong parameter type") if extended: - # find the root of the repo - repodir = self.splitPath(name)[0] - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - from .HgRevisionsSelectionDialog import HgRevisionsSelectionDialog - dlg = HgRevisionsSelectionDialog(self.hgGetTagsList(repodir), - self.hgGetBranchesList(repodir), - self.hgGetBookmarksList(repodir)) + dlg = HgRevisionsSelectionDialog(self.hgGetTagsList(), + self.hgGetBranchesList(), + self.hgGetBookmarksList()) if dlg.exec() == QDialog.Accepted: rev1, rev2 = dlg.getRevisions() else: @@ -1729,7 +1585,7 @@ self.sbsDiff.raise_() self.sbsDiff.compare(output1, output2, name1, name2) - def vcsLogBrowser(self, name, isFile=False): + def vcsLogBrowser(self, name=None, isFile=False): """ Public method used to browse the log of a file/directory from the Mercurial repository. @@ -1743,14 +1599,12 @@ self.logBrowser = HgLogBrowserDialog(self) self.logBrowser.show() self.logBrowser.raise_() - self.logBrowser.start(name, isFile=isFile) + self.logBrowser.start(name=name, isFile=isFile) - def hgIncoming(self, name): + def hgIncoming(self): """ Public method used to view the log of incoming changes from the Mercurial repository. - - @param name file/directory name to show the log of (string) """ if self.logBrowserIncoming is None: from .HgLogBrowserDialog import HgLogBrowserDialog @@ -1758,14 +1612,12 @@ self, mode="incoming") self.logBrowserIncoming.show() self.logBrowserIncoming.raise_() - self.logBrowserIncoming.start(name) + self.logBrowserIncoming.start() - def hgOutgoing(self, name): + def hgOutgoing(self): """ Public method used to view the log of outgoing changes from the Mercurial repository. - - @param name file/directory name to show the log of (string) """ if self.logBrowserOutgoing is None: from .HgLogBrowserDialog import HgLogBrowserDialog @@ -1773,14 +1625,12 @@ self, mode="outgoing") self.logBrowserOutgoing.show() self.logBrowserOutgoing.raise_() - self.logBrowserOutgoing.start(name) + self.logBrowserOutgoing.start() - def hgPull(self, name, revisions=None): + def hgPull(self, revisions=None): """ Public method used to pull changes from a remote Mercurial repository. - @param name directory name of the project to be pulled to - @type str @param revisions list of revisions to be pulled @type list of str @return flag indicating, that the update contained an add @@ -1810,15 +1660,8 @@ args.append("--rev") args.append(rev) - # find the root of the repo - repodir = self.splitPath(name)[0] - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - dia = HgDialog(title, self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() res = dia.hasAddOrDelete() @@ -1831,11 +1674,10 @@ self.checkVCSStatus() return res - def hgPush(self, name, force=False, newBranch=False, rev=None): + def hgPush(self, force=False, newBranch=False, rev=None): """ Public method used to push changes to a remote Mercurial repository. - @param name directory name of the project to be pushed from (string) @param force flag indicating a forced push (boolean) @param newBranch flag indicating to push a new branch (boolean) @param rev revision to be pushed (including all ancestors) (string) @@ -1850,25 +1692,17 @@ args.append('--rev') args.append(rev) - # find the root of the repo - repodir = self.splitPath(name)[0] - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - dia = HgDialog( self.tr('Pushing to a remote Mercurial repository'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() self.checkVCSStatus() - def hgInfo(self, ppath, mode="heads"): + def hgInfo(self, mode="heads"): """ Public method to show information about the heads of the repository. - @param ppath local path to get the repository infos (string) @param mode mode of the operation (string, one of heads, parents, tip) """ @@ -1941,18 +1775,16 @@ dlg = VcsRepositoryInfoDialog(None, "\n".join(info)) dlg.exec() - def hgConflicts(self, name): + def hgConflicts(self): """ Public method used to show a list of files containing conflicts. - - @param name file/directory name to be resolved (string) """ if self.conflictsDlg is None: from .HgConflictsListDialog import HgConflictsListDialog self.conflictsDlg = HgConflictsListDialog(self) self.conflictsDlg.show() self.conflictsDlg.raise_() - self.conflictsDlg.start(name) + self.conflictsDlg.start() def hgResolved(self, name, unresolve=False): """ @@ -1969,46 +1801,27 @@ args.append("--mark") if isinstance(name, list): - dname, fnames = self.splitPathList(name) self.addArguments(args, name) else: - dname, fname = self.splitPath(name) args.append(name) - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - if unresolve: title = self.tr("Marking as 'unresolved'") else: title = self.tr("Marking as 'resolved'") dia = HgDialog(title, self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() self.checkVCSStatus() - def hgAbortMerge(self, name): + def hgAbortMerge(self): """ Public method to abort an uncommitted merge. - @param name file/directory name (string) @return flag indicating, that the abortion contained an add or delete (boolean) """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - if self.version >= (4, 5, 0): args = self.initCommand("merge") args.append("--abort") @@ -2019,30 +1832,19 @@ dia = HgDialog( self.tr('Aborting uncommitted merge'), self) - res = dia.startProcess(args, repodir, False) + res = dia.startProcess(args, showArgs=False) if res: dia.exec() res = dia.hasAddOrDelete() self.checkVCSStatus() return res - def hgBranch(self, name): + def hgBranch(self): """ Public method used to create a branch in the Mercurial repository. - - @param name file/directory name to be branched (string) """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - from .HgBranchInputDialog import HgBranchInputDialog - dlg = HgBranchInputDialog(self.hgGetBranchesList(repodir)) + dlg = HgBranchInputDialog(self.hgGetBranchesList()) if dlg.exec() == QDialog.Accepted: name, commit = dlg.getData() name = name.strip().replace(" ", "_") @@ -2052,43 +1854,30 @@ dia = HgDialog( self.tr('Creating branch in the Mercurial repository'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() if commit: self.vcsCommit( - repodir, + name, self.tr("Created new branch <{0}>.").format( name)) - def hgShowBranch(self, name): + def hgShowBranch(self): """ Public method used to show the current branch of the working directory. - - @param name file/directory name (string) """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - args = self.initCommand("branch") dia = HgDialog(self.tr('Showing current branch'), self) - res = dia.startProcess(args, repodir, False) + res = dia.startProcess(args, showArgs=False) if res: dia.exec() - def hgGetCurrentBranch(self, repodir): + def hgGetCurrentBranch(self): """ Public method to get the current branch of the working directory. - @param repodir directory name of the repository - @type str @return name of the current branch @rtype str """ @@ -2168,122 +1957,67 @@ self.repoEditor = MiniEditor(cfgFile, "Properties") self.repoEditor.show() - def hgVerify(self, name): + def hgVerify(self): """ Public method to verify the integrity of the repository. - - @param name file/directory name (string) """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - args = self.initCommand("verify") dia = HgDialog( self.tr('Verifying the integrity of the Mercurial repository'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() - def hgShowConfig(self, name): + def hgShowConfig(self): """ Public method to show the combined configuration. - - @param name file/directory name (string) """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - args = self.initCommand("showconfig") args.append("--untrusted") dia = HgDialog( self.tr('Showing the combined configuration settings'), self) - res = dia.startProcess(args, repodir, False) + res = dia.startProcess(args, showArgs=False) if res: dia.exec() - def hgShowPaths(self, name): + def hgShowPaths(self): """ Public method to show the path aliases for remote repositories. - - @param name file/directory name (string) """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - args = self.initCommand("paths") dia = HgDialog( self.tr('Showing aliases for remote repositories'), self) - res = dia.startProcess(args, repodir, False) + res = dia.startProcess(args, showArgs=False) if res: dia.exec() - def hgRecover(self, name): + def hgRecover(self): """ Public method to recover an interrupted transaction. - - @param name file/directory name (string) """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - args = self.initCommand("recover") dia = HgDialog( self.tr('Recovering from interrupted transaction'), self) - res = dia.startProcess(args, repodir, False) + res = dia.startProcess(args, showArgs=False) if res: dia.exec() - def hgIdentify(self, name): + def hgIdentify(self): """ Public method to identify the current working directory. - - @param name file/directory name (string) """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - args = self.initCommand("identify") dia = HgDialog(self.tr('Identifying project directory'), self) - res = dia.startProcess(args, repodir, False) + res = dia.startProcess(args, showArgs=False) if res: dia.exec() @@ -2339,29 +2073,18 @@ return status - def hgBundle(self, name, bundleData=None): + def hgBundle(self, bundleData=None): """ Public method to create a changegroup file. - @param name file/directory name - @type str @param bundleData dictionary containing the bundle creation information @type dict """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - if bundleData is None: from .HgBundleDialog import HgBundleDialog - dlg = HgBundleDialog(self.hgGetTagsList(repodir), - self.hgGetBranchesList(repodir), - self.hgGetBookmarksList(repodir), + dlg = HgBundleDialog(self.hgGetTagsList(), + self.hgGetBranchesList(), + self.hgGetBookmarksList(), version=self.version) if dlg.exec() != QDialog.Accepted: return @@ -2379,7 +2102,7 @@ fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( None, self.tr("Create changegroup"), - self.__lastChangeGroupPath or repodir, + self.__lastChangeGroupPath, self.tr("Mercurial Changegroup Files (*.hg)"), None, E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) @@ -2420,30 +2143,19 @@ args.append(fname) dia = HgDialog(self.tr('Create changegroup'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() - def hgPreviewBundle(self, name): + def hgPreviewBundle(self): """ Public method used to view the log of incoming changes from a changegroup file. - - @param name directory name on which to base the changegroup (string) """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - file = E5FileDialog.getOpenFileName( None, self.tr("Preview changegroup"), - self.__lastChangeGroupPath or repodir, + self.__lastChangeGroupPath, self.tr("Mercurial Changegroup Files (*.hg);;All Files (*)")) if file: self.__lastChangeGroupPath = os.path.dirname(file) @@ -2454,35 +2166,24 @@ self, mode="incoming") self.logBrowserIncoming.show() self.logBrowserIncoming.raise_() - self.logBrowserIncoming.start(name, bundle=file) + self.logBrowserIncoming.start(bundle=file) - def hgUnbundle(self, name, files=None): + def hgUnbundle(self, files=None): """ Public method to apply changegroup files. - @param name directory name - @type str @param files list of bundle files to be applied @type list of str @return flag indicating, that the update contained an add or delete @rtype bool """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - res = False if not files: files = E5FileDialog.getOpenFileNames( None, self.tr("Apply changegroups"), - self.__lastChangeGroupPath or repodir, + self.__lastChangeGroupPath, self.tr("Mercurial Changegroup Files (*.hg);;All Files (*)")) if files: @@ -2501,7 +2202,7 @@ args.extend(files) dia = HgDialog(self.tr('Apply changegroups'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() res = dia.hasAddOrDelete() @@ -2509,13 +2210,13 @@ return res - def hgBisect(self, name, subcommand): + def hgBisect(self, subcommand): """ Public method to perform bisect commands. - @param name file/directory name (string) - @param subcommand name of the subcommand (string, one of 'good', 'bad', + @param subcommand name of the subcommand (one of 'good', 'bad', 'skip' or 'reset') + @type str @exception ValueError raised to indicate an invalid bisect subcommand """ if subcommand not in ("good", "bad", "skip", "reset"): @@ -2523,21 +2224,12 @@ self.tr("Bisect subcommand ({0}) invalid.") .format(subcommand)) - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - rev = "" if subcommand in ("good", "bad", "skip"): from .HgRevisionSelectionDialog import HgRevisionSelectionDialog - dlg = HgRevisionSelectionDialog(self.hgGetTagsList(repodir), - self.hgGetBranchesList(repodir), - self.hgGetBookmarksList(repodir)) + dlg = HgRevisionSelectionDialog(self.hgGetTagsList(), + self.hgGetBranchesList(), + self.hgGetBookmarksList()) if dlg.exec() == QDialog.Accepted: rev = dlg.getRevision() else: @@ -2550,7 +2242,7 @@ dia = HgDialog( self.tr('Mercurial Bisect ({0})').format(subcommand), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() @@ -2567,23 +2259,14 @@ args.append('-v') if isinstance(name, list): - dname, fnames = self.splitPathList(name) self.addArguments(args, name) else: - dname, fname = self.splitPath(name) args.append(name) - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - dia = HgDialog( self.tr('Removing files from the Mercurial repository only'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() if isinstance(name, list): @@ -2591,26 +2274,15 @@ else: self.__forgotNames.append(name) - def hgBackout(self, name): + def hgBackout(self): """ Public method used to backout an earlier changeset from the Mercurial repository. - - @param name directory name (string or list of strings) """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - from .HgBackoutDialog import HgBackoutDialog - dlg = HgBackoutDialog(self.hgGetTagsList(repodir), - self.hgGetBranchesList(repodir), - self.hgGetBookmarksList(repodir)) + dlg = HgBackoutDialog(self.hgGetTagsList(), + self.hgGetBranchesList(), + self.hgGetBookmarksList()) if dlg.exec() == QDialog.Accepted: rev, merge, date, user, message = dlg.getParameters() if not rev: @@ -2635,25 +2307,14 @@ args.append(rev) dia = HgDialog(self.tr('Backing out changeset'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() - def hgRollback(self, name): + def hgRollback(self): """ Public method used to rollback the last transaction. - - @param name directory name (string or list of strings) """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - res = E5MessageBox.yesNo( None, self.tr("Rollback last transaction"), @@ -2662,7 +2323,7 @@ icon=E5MessageBox.Warning) if res: dia = HgDialog(self.tr('Rollback last transaction'), self) - res = dia.startProcess(["rollback"], repodir) + res = dia.startProcess(["rollback"]) if res: dia.exec() @@ -2685,23 +2346,13 @@ self.serveDlg = HgServeDialog(self, repodir) self.serveDlg.show() - def hgImport(self, name): + def hgImport(self): """ Public method to import a patch file. - @param name directory name of the project to import into (string) @return flag indicating, that the import contained an add, a delete or a change to the project file (boolean) """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - from .HgImportDialog import HgImportDialog dlg = HgImportDialog(self) if dlg.exec() == QDialog.Accepted: @@ -2732,7 +2383,7 @@ args.append(patchFile) dia = HgDialog(self.tr("Import Patch"), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() res = dia.hasAddOrDelete() @@ -2742,23 +2393,12 @@ return res - def hgExport(self, name): + def hgExport(self): """ Public method to export patches to files. - - @param name directory name of the project to export from (string) """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - from .HgExportDialog import HgExportDialog - dlg = HgExportDialog(self.hgGetBookmarksList(repodir), + dlg = HgExportDialog(self.hgGetBookmarksList(), self.version >= (4, 7, 0)) if dlg.exec() == QDialog.Accepted: (filePattern, revisions, bookmark, switchParent, allText, @@ -2784,29 +2424,19 @@ args.append(rev) dia = HgDialog(self.tr("Export Patches"), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() - def hgPhase(self, name, data=None): + def hgPhase(self, data=None): """ Public method to change the phase of revisions. - @param name directory name of the project to export from (string) @param data tuple giving phase data (list of revisions, phase, flag indicating a forced operation) (list of strings, string, boolean) @return flag indicating success (boolean) @exception ValueError raised to indicate an invalid phase """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - if data is None: from .HgPhaseDialog import HgPhaseDialog dlg = HgPhaseDialog() @@ -2831,7 +2461,7 @@ args.append(rev) dia = HgDialog(self.tr("Change Phase"), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() res = dia.normalExitWithoutErrors() @@ -2840,22 +2470,14 @@ return res - def hgGraft(self, path, revs=None): + def hgGraft(self, revs=None): """ Public method to copy changesets from another branch. - @param path directory name of the project (string) @param revs list of revisions to show in the revisions pane (list of strings) @return flag indicating that the project should be reread (boolean) """ - # find the root of the repo - repodir = self.splitPath(path)[0] - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - from .HgGraftDialog import HgGraftDialog res = False dlg = HgGraftDialog(self, revs) @@ -2888,19 +2510,17 @@ args.extend(revs) dia = HgDialog(self.tr('Copy Changesets'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() res = dia.hasAddOrDelete() self.checkVCSStatus() return res - def __hgGraftSubCommand(self, path, subcommand, title): + def __hgGraftSubCommand(self, subcommand, title): """ Private method to perform a Mercurial graft subcommand. - @param path directory name of the project - @type str @param subcommand subcommand flag @type str @param title tirle of the dialog @@ -2908,19 +2528,12 @@ @return flag indicating that the project should be reread @rtype bool """ - # find the root of the repo - repodir = self.splitPath(path)[0] - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - args = self.initCommand("graft") args.append(subcommand) args.append("--verbose") dia = HgDialog(title, self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() res = dia.hasAddOrDelete() @@ -2937,7 +2550,7 @@ @rtype bool """ return self.__hgGraftSubCommand( - path, "--continue", self.tr('Copy Changesets (Continue)')) + "--continue", self.tr('Copy Changesets (Continue)')) def hgGraftStop(self, path): """ @@ -2949,7 +2562,7 @@ @rtype bool """ return self.__hgGraftSubCommand( - path, "--stop", self.tr('Copy Changesets (Stop)')) + "--stop", self.tr('Copy Changesets (Stop)')) def hgGraftAbort(self, path): """ @@ -2962,19 +2575,12 @@ @rtype bool """ return self.__hgGraftSubCommand( - path, "--abort", self.tr('Copy Changesets (Abort)')) + "--abort", self.tr('Copy Changesets (Abort)')) def hgArchive(self): """ Public method to create an unversioned archive from the repository. """ - # find the root of the repo - repodir = self.__projectHelper.getProject().getProjectPath() - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - from .HgArchiveDialog import HgArchiveDialog dlg = HgArchiveDialog(self) if dlg.exec() == QDialog.Accepted: @@ -2992,7 +2598,7 @@ args.append(archive) dia = HgDialog(self.tr("Create Unversioned Archive"), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() @@ -3018,7 +2624,7 @@ shutil.rmtree(backupdir, True) ########################################################################### - ## Methods to deal with subrepositories are below. + ## Methods to deal with sub-repositories are below. ########################################################################### def getHgSubPath(self): @@ -3189,25 +2795,14 @@ ): self.__defaultPushConfigured = True - def canCommitMerge(self, name): + def canCommitMerge(self): """ Public method to check, if the working directory is an uncommitted merge. - @param name file/directory name - @type str @return flag indicating commit merge capability @rtype bool """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - args = self.initCommand("identify") output, error = self.__client.runcommand(args) @@ -3412,7 +3007,7 @@ self.__client = None ########################################################################### - ## Status Monitor Thread methods + ## Status Monitor Thread methods ########################################################################### def _createStatusMonitorThread(self, interval, project): @@ -3429,14 +3024,12 @@ return HgStatusMonitorThread(interval, project, self) ########################################################################### - ## Bookmarks methods + ## Bookmarks methods ########################################################################### - def hgListBookmarks(self, path): + def hgListBookmarks(self): """ Public method used to list the available bookmarks. - - @param path directory name of the project (string) """ self.bookmarksList = [] @@ -3445,13 +3038,12 @@ self.bookmarksListDlg = HgBookmarksListDialog(self) self.bookmarksListDlg.show() self.bookmarksListDlg.raise_() - self.bookmarksListDlg.start(path, self.bookmarksList) + self.bookmarksListDlg.start(self.bookmarksList) - def hgGetBookmarksList(self, repodir): + def hgGetBookmarksList(self): """ Public method to get the list of bookmarks. - @param repodir directory name of the repository (string) @return list of bookmarks (list of string) """ args = self.initCommand("bookmarks") @@ -3472,29 +3064,21 @@ return self.bookmarksList[:] - def hgBookmarkDefine(self, name, revision=None, bookmark=None): + def hgBookmarkDefine(self, revision=None, bookmark=None): """ Public method to define a bookmark. - @param name file/directory name (string) @param revision revision to set bookmark for (string) @param bookmark name of the bookmark (string) """ - # find the root of the repo - repodir = self.splitPath(name)[0] - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - if bool(revision) and bool(bookmark): ok = True else: from .HgBookmarkDialog import HgBookmarkDialog dlg = HgBookmarkDialog(HgBookmarkDialog.DEFINE_MODE, - self.hgGetTagsList(repodir), - self.hgGetBranchesList(repodir), - self.hgGetBookmarksList(repodir)) + self.hgGetTagsList(), + self.hgGetBranchesList(), + self.hgGetBookmarksList()) if dlg.exec() == QDialog.Accepted: revision, bookmark = dlg.getData() ok = True @@ -3509,24 +3093,16 @@ args.append(bookmark) dia = HgDialog(self.tr('Mercurial Bookmark'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() - def hgBookmarkDelete(self, name, bookmark=None): + def hgBookmarkDelete(self, bookmark=None): """ Public method to delete a bookmark. - @param name file/directory name (string) @param bookmark name of the bookmark (string) """ - # find the root of the repo - repodir = self.splitPath(name)[0] - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - if bookmark: ok = True else: @@ -3534,7 +3110,7 @@ None, self.tr("Delete Bookmark"), self.tr("Select the bookmark to be deleted:"), - [""] + sorted(self.hgGetBookmarksList(repodir)), + [""] + sorted(self.hgGetBookmarksList()), 0, True) if ok and bookmark: args = self.initCommand("bookmarks") @@ -3542,29 +3118,20 @@ args.append(bookmark) dia = HgDialog(self.tr('Delete Mercurial Bookmark'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() - def hgBookmarkRename(self, name, renameInfo=None): + def hgBookmarkRename(self, renameInfo=None): """ Public method to rename a bookmark. - @param name file/directory name - @type str @param renameInfo old and new names of the bookmark @type tuple of str and str """ - # find the root of the repo - repodir = self.splitPath(name)[0] - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - if not renameInfo: from .HgBookmarkRenameDialog import HgBookmarkRenameDialog - dlg = HgBookmarkRenameDialog(self.hgGetBookmarksList(repodir)) + dlg = HgBookmarkRenameDialog(self.hgGetBookmarksList()) if dlg.exec() == QDialog.Accepted: renameInfo = dlg.getData() @@ -3575,33 +3142,25 @@ args.append(renameInfo[1]) dia = HgDialog(self.tr('Rename Mercurial Bookmark'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() - def hgBookmarkMove(self, name, revision=None, bookmark=None): + def hgBookmarkMove(self, revision=None, bookmark=None): """ Public method to move a bookmark. - @param name file/directory name (string) @param revision revision to set bookmark for (string) @param bookmark name of the bookmark (string) """ - # find the root of the repo - repodir = self.splitPath(name)[0] - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - if bool(revision) and bool(bookmark): ok = True else: from .HgBookmarkDialog import HgBookmarkDialog dlg = HgBookmarkDialog(HgBookmarkDialog.MOVE_MODE, - self.hgGetTagsList(repodir), - self.hgGetBranchesList(repodir), - self.hgGetBookmarksList(repodir)) + self.hgGetTagsList(), + self.hgGetBranchesList(), + self.hgGetBookmarksList()) if dlg.exec() == QDialog.Accepted: revision, bookmark = dlg.getData() ok = True @@ -3617,39 +3176,34 @@ args.append(bookmark) dia = HgDialog(self.tr('Move Mercurial Bookmark'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() - def hgBookmarkIncoming(self, name): + def hgBookmarkIncoming(self): """ Public method to show a list of incoming bookmarks. - - @param name file/directory name (string) """ from .HgBookmarksInOutDialog import HgBookmarksInOutDialog self.bookmarksInOutDlg = HgBookmarksInOutDialog( self, HgBookmarksInOutDialog.INCOMING) self.bookmarksInOutDlg.show() - self.bookmarksInOutDlg.start(name) + self.bookmarksInOutDlg.start() - def hgBookmarkOutgoing(self, name): + def hgBookmarkOutgoing(self): """ Public method to show a list of outgoing bookmarks. - - @param name file/directory name (string) """ from .HgBookmarksInOutDialog import HgBookmarksInOutDialog self.bookmarksInOutDlg = HgBookmarksInOutDialog( self, HgBookmarksInOutDialog.OUTGOING) self.bookmarksInOutDlg.show() - self.bookmarksInOutDlg.start(name) + self.bookmarksInOutDlg.start() - def __getInOutBookmarks(self, repodir, incoming): + def __getInOutBookmarks(self, incoming): """ Private method to get the list of incoming or outgoing bookmarks. - @param repodir directory name of the repository (string) @param incoming flag indicating to get incoming bookmarks (boolean) @return list of bookmarks (list of string) """ @@ -3673,31 +3227,22 @@ return bookmarksList - def hgBookmarkPull(self, name, current=False, bookmark=None): + def hgBookmarkPull(self, current=False, bookmark=None): """ Public method to pull a bookmark from a remote repository. - @param name file/directory name - @type str @param current flag indicating to pull the current bookmark @type bool @param bookmark name of the bookmark @type str """ - # find the root of the repo - repodir = self.splitPath(name)[0] - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - if current: bookmark = "." ok = True elif bookmark: ok = True else: - bookmarks = self.__getInOutBookmarks(repodir, True) + bookmarks = self.__getInOutBookmarks(True) bookmark, ok = QInputDialog.getItem( None, self.tr("Pull Bookmark"), @@ -3713,35 +3258,26 @@ dia = HgDialog(self.tr( 'Pulling bookmark from a remote Mercurial repository'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() - def hgBookmarkPush(self, name, current=False, bookmark=None): + def hgBookmarkPush(self, current=False, bookmark=None): """ Public method to push a bookmark to a remote repository. - @param name file/directory name - @type str @param current flag indicating to push the current bookmark @type bool @param bookmark name of the bookmark @type str """ - # find the root of the repo - repodir = self.splitPath(name)[0] - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - if current: bookmark = "." ok = True elif bookmark: ok = True else: - bookmarks = self.__getInOutBookmarks(repodir, False) + bookmarks = self.__getInOutBookmarks(False) bookmark, ok = QInputDialog.getItem( None, self.tr("Push Bookmark"), @@ -3757,6 +3293,6 @@ dia = HgDialog(self.tr( 'Pushing bookmark to a remote Mercurial repository'), self) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec()