--- a/eric6/Plugins/VcsPlugins/vcsMercurial/hg.py Sun Jan 17 13:53:08 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/hg.py Mon Feb 01 10:38:16 2021 +0100 @@ -330,7 +330,7 @@ dia = HgDialog( self.tr('Initial commit to Mercurial repository'), self) - res = dia.startProcess(args, projectDir) + res = dia.startProcess(args) if res: dia.exec() status = dia.normalExit() @@ -399,9 +399,9 @@ strings) @param message message for this operation (string) @param noDialog flag indicating quiet operations - @keyparam closeBranch flag indicating a close branch commit (boolean) - @keyparam mq flag indicating a queue commit (boolean) - @keyparam merge flag indicating a merge commit (boolean) + @param closeBranch flag indicating a close branch commit (boolean) + @param mq flag indicating a queue commit (boolean) + @param merge flag indicating a merge commit (boolean) """ msg = message @@ -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,15 +561,14 @@ 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) - @keyparam revision revision to update to (string) + @param revision revision to update to (string) @return flag indicating, that the update contained an add or delete (boolean) """ @@ -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() @@ -987,23 +905,14 @@ @param name file/directory name to be merged @type str - @keyparam rev revision to merge with + @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() @@ -1112,27 +1003,23 @@ """ Public method used to get the registered state of a file in the vcs. - @param name filename to check (string) + @param name file or directory name to check + @type str @return a combination of canBeCommited and canBeAdded + @rtype int """ if name.endswith(os.sep): name = name[:-1] name = os.path.normcase(name) - dname, fname = self.splitPath(name) - if fname == '.' and os.path.isdir(os.path.join(dname, self.adminDir)): + if ( + os.path.isdir(name) and + os.path.isdir(os.path.join(name, self.adminDir)) + ): return self.canBeCommitted if name in self.statusCache: return self.statusCache[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 0 - args = self.initCommand("status") args.append('--all') args.append('--noninteractive') @@ -1140,19 +1027,14 @@ output, error = self.__client.runcommand(args) if output: + repodir = self.getClient().getRepository() for line in output.splitlines(): if len(line) > 2 and line[0] in "MARC!?I" and line[1] == " ": flag, path = line.split(" ", 1) - absname = os.path.join(repodir, os.path.normcase(path)) - if flag not in "?I": - if fname == '.': - if absname.startswith(dname + os.path.sep): - return self.canBeCommitted - if absname == dname: - return self.canBeCommitted - else: - if absname == name: - return self.canBeCommitted + absname = Utilities.normcasepath( + os.path.join(repodir, path)) + if flag not in "?I" and absname == name: + return self.canBeCommitted return self.canBeAdded @@ -1182,13 +1064,6 @@ names[name] = self.statusCache[name] if not found: - # 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 names - args = self.initCommand("status") args.append('--all') args.append('--noninteractive') @@ -1196,11 +1071,12 @@ output, error = self.__client.runcommand(args) if output: + repoPath = self.getClient().getRepository() dirs = [x for x in names.keys() if os.path.isdir(x)] for line in output.splitlines(): if line and line[0] in "MARC!?I": flag, path = line.split(" ", 1) - name = os.path.normcase(os.path.join(repodir, path)) + name = os.path.normcase(os.path.join(repoPath, path)) dirName = os.path.dirname(name) if name.startswith(dname): if flag not in "?I": @@ -1291,15 +1167,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 +1320,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 +1336,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 +1375,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 +1401,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 +1418,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 +1427,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 +1458,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 +1471,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: @@ -1642,7 +1490,7 @@ repository. @param name file name to get from the repository (string) - @keyparam rev revision to retrieve (string) + @param rev revision to retrieve (string) @return contents of the file (string) and an error message (string) """ args = self.initCommand("cat") @@ -1662,25 +1510,18 @@ repository side-by-side. @param name file name to be diffed (string) - @keyparam extended flag indicating the extended variant (boolean) - @keyparam revisions tuple of two revisions (tuple of strings) + @param extended flag indicating the extended variant (boolean) + @param revisions tuple of two revisions (tuple of strings) @exception ValueError raised to indicate an invalid name parameter """ if isinstance(name, list): 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,28 +1570,29 @@ 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. @param name file/directory name to show the log of (string) - @keyparam isFile flag indicating log for a file is to be shown + @param isFile flag indicating log for a file is to be shown (boolean) """ + if name == self.getClient().getRepository(): + name = None + if self.logBrowser is None: from .HgLogBrowserDialog import HgLogBrowserDialog 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 +1600,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 +1613,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 +1648,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,14 +1662,13 @@ 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) - @keyparam force flag indicating a forced push (boolean) - @keyparam newBranch flag indicating to push a new branch (boolean) - @keyparam rev revision to be pushed (including all ancestors) (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) """ args = self.initCommand("push") args.append('-v') @@ -1850,26 +1680,18 @@ 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) - @keyparam mode mode of the operation (string, one of heads, parents, + @param mode mode of the operation (string, one of heads, parents, tip) """ if mode not in ("heads", "parents", "tip"): @@ -1941,18 +1763,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 +1789,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 +1820,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 +1842,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 """ @@ -2106,26 +1883,24 @@ dlg = HgUserConfigDialog(version=self.version) dlg.exec() - def hgEditConfig(self, name, withLargefiles=True, largefilesData=None): + def hgEditConfig(self, repoName=None, + withLargefiles=True, largefilesData=None): """ Public method used to edit the repository configuration file. - @param name file/directory name (string) + @param repoName directory name containing the repository + @type str @param withLargefiles flag indicating to configure the largefiles - section (boolean) + section + @type bool @param largefilesData dictionary with data for the largefiles - section of the data dialog (dict) + section of the data dialog + @type dict """ - dname, fname = self.splitPath(name) + if repoName is None: + repoName = self.getClient().getRepository() - # 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 - - cfgFile = os.path.join(repodir, self.adminDir, "hgrc") + cfgFile = os.path.join(repoName, self.adminDir, "hgrc") if not os.path.exists(cfgFile): # open dialog to enter the initial data withLargefiles = (self.isExtensionActive("largefiles") and @@ -2161,129 +1936,74 @@ cfg.write("patterns =\n") cfg.write(" {0}\n".format( "\n ".join(lfPattern))) - self.__monitorRepoIniFile(repodir) + self.__monitorRepoIniFile(repoName) self.__iniFileChanged(cfgFile) except OSError: pass 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 +2059,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 +2088,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 +2129,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 +2152,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 +2188,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 +2196,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 +2210,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 +2228,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 +2245,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 +2260,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 +2293,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,46 +2309,28 @@ 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() - def hgServe(self, name): + def hgServe(self, repoPath): """ Public method used to serve the project. - @param name directory name (string) + @param repoPath directory containing the repository + @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 - from .HgServeDialog import HgServeDialog - self.serveDlg = HgServeDialog(self, repodir) + self.serveDlg = HgServeDialog(self, repoPath) 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 +2361,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 +2371,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 +2402,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 +2439,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 +2448,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 +2488,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 +2506,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 +2528,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 +2540,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 +2553,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 +2576,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() @@ -3000,14 +2584,8 @@ """ Public method to delete all backup bundles in the backup area. """ - # 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 - - backupdir = os.path.join(repodir, self.adminDir, "strip-backup") + backupdir = os.path.join(self.getClient().getRepository(), + self.adminDir, "strip-backup") yes = E5MessageBox.yesNo( self.__ui, self.tr("Delete All Backups"), @@ -3018,7 +2596,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 +2767,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) @@ -3253,22 +2820,14 @@ self.iniFileChanged.emit() - def __monitorRepoIniFile(self, name): + def __monitorRepoIniFile(self, repodir): """ Private slot to add a repository configuration file to the list of monitored files. - @param name directory name pointing into the repository (string) + @param repodir directory name of the repository + @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 not repodir or os.path.splitdrive(repodir)[1] == os.sep: - return - cfgFile = os.path.join(repodir, self.adminDir, "hgrc") if os.path.exists(cfgFile): self.__iniWatcher.addPath(cfgFile) @@ -3412,7 +2971,7 @@ self.__client = None ########################################################################### - ## Status Monitor Thread methods + ## Status Monitor Thread methods ########################################################################### def _createStatusMonitorThread(self, interval, project): @@ -3429,14 +2988,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 +3002,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 +3028,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 +3057,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 +3074,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 +3082,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 +3106,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 +3140,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 +3191,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 +3222,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 +3257,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()