Tue, 12 Jan 2021 20:03:30 +0100
Mercurial: started more code cleanup.
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/CloseheadExtension/HgCloseHeadSelectionDialog.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/CloseheadExtension/HgCloseHeadSelectionDialog.py Tue Jan 12 20:03:30 2021 +0100 @@ -17,14 +17,12 @@ """ Class implementing a dialog to select the heads to be closed. """ - def __init__(self, vcs, ppath, parent=None): + def __init__(self, vcs, parent=None): """ Constructor @param vcs reference to the VCS object @type Hg - @param ppath directory containing the repository - @type str @param parent reference to the parent widget @type QWidget """ @@ -34,18 +32,16 @@ self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) - heads = self.__getHeads(vcs, ppath) + heads = self.__getHeads(vcs) for revision, branch in heads: QTreeWidgetItem(self.headsList, [revision, branch]) - def __getHeads(self, vcs, ppath): + def __getHeads(self, vcs): """ Private method to get the open heads. @param vcs reference to the VCS object @type Hg - @param ppath directory containing the repository - @type str @return list of tuples containing the revision and the corresponding branch name @rtype list of tuples of (str, str)
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/CloseheadExtension/ProjectHelper.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/CloseheadExtension/ProjectHelper.py Tue Jan 12 20:03:30 2021 +0100 @@ -75,5 +75,4 @@ """ Private slot used to close arbitrary heads. """ - self.vcs.getExtensionObject("closehead").hgCloseheads( - self.project.getProjectPath()) + self.vcs.getExtensionObject("closehead").hgCloseheads()
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/CloseheadExtension/closehead.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/CloseheadExtension/closehead.py Tue Jan 12 20:03:30 2021 +0100 @@ -7,8 +7,6 @@ Module implementing the closehead extension interface. """ -import os - from PyQt5.QtWidgets import QDialog from ..HgExtension import HgExtension @@ -28,26 +26,17 @@ """ super(Closehead, self).__init__(vcs) - def hgCloseheads(self, name, revisions=None): + def hgCloseheads(self, revisions=None): """ Public method to close arbitrary heads. - @param name file/directory name - @type str @param revisions revisions of branch heads to be closed @type str """ - # find the root of the repo - repodir = self.vcs.splitPath(name)[0] - while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - message = "" if not revisions: from .HgCloseHeadSelectionDialog import HgCloseHeadSelectionDialog - dlg = HgCloseHeadSelectionDialog(self.vcs, name) + dlg = HgCloseHeadSelectionDialog(self.vcs) if dlg.exec() == QDialog.Accepted: revisions, message = dlg.getData() @@ -68,6 +57,6 @@ args += ["--rev", revision] dia = HgDialog(self.tr("Closing Heads"), self.vcs) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec()
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/GpgExtension/HgGpgSignaturesDialog.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/GpgExtension/HgGpgSignaturesDialog.py Tue Jan 12 20:03:30 2021 +0100 @@ -7,7 +7,6 @@ Module implementing a dialog showing signed changesets. """ -import os import re from PyQt5.QtCore import pyqtSlot, Qt, QCoreApplication @@ -53,27 +52,15 @@ e.accept() - def start(self, path): + def start(self): """ Public slot to start the list command. - - @param path name of directory (string) """ self.errorGroup.hide() self.intercept = False self.activateWindow() - self.__path = path - dname, fname = self.vcs.splitPath(path) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - args = self.vcs.initCommand("sigs") out, err = self.__hgClient.runcommand(args) @@ -203,8 +190,7 @@ self.signaturesList.selectedItems()[0].text(0) .split(":")[0].strip() ) - self.vcs.getExtensionObject("gpg").hgGpgVerifySignatures( - self.__path, rev) + self.vcs.getExtensionObject("gpg").hgGpgVerifySignatures(rev) @pyqtSlot(str) def on_categoryCombo_activated(self, txt):
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/GpgExtension/ProjectHelper.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/GpgExtension/ProjectHelper.py Tue Jan 12 20:03:30 2021 +0100 @@ -105,19 +105,16 @@ """ Private slot used to list all signed changesets. """ - self.vcs.getExtensionObject("gpg").hgGpgSignatures( - self.project.getProjectPath()) + self.vcs.getExtensionObject("gpg").hgGpgSignatures() def __hgGpgVerifySignatures(self): """ Private slot used to verify the signatures of a revision. """ - self.vcs.getExtensionObject("gpg").hgGpgVerifySignatures( - self.project.getProjectPath()) + self.vcs.getExtensionObject("gpg").hgGpgVerifySignatures() def __hgGpgSign(self): """ Private slot used to sign a revision. """ - self.vcs.getExtensionObject("gpg").hgGpgSign( - self.project.getProjectPath()) + self.vcs.getExtensionObject("gpg").hgGpgSign()
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/GpgExtension/gpg.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/GpgExtension/gpg.py Tue Jan 12 20:03:30 2021 +0100 @@ -37,36 +37,26 @@ if self.gpgSignaturesDialog is not None: self.gpgSignaturesDialog.close() - def hgGpgSignatures(self, path): + def hgGpgSignatures(self): """ Public method used to list all signed changesets. - - @param path directory name of the project (string) """ from .HgGpgSignaturesDialog import HgGpgSignaturesDialog self.gpgSignaturesDialog = HgGpgSignaturesDialog(self.vcs) self.gpgSignaturesDialog.show() - self.gpgSignaturesDialog.start(path) + self.gpgSignaturesDialog.start() - def hgGpgVerifySignatures(self, path, rev=None): + def hgGpgVerifySignatures(self, rev=None): """ Public method used to verify the signatures of a revision. - @param path directory name of the project (string) @param rev revision to check (string) """ - # find the root of the repo - repodir = self.vcs.splitPath(path)[0] - while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - if rev is None: dlg = HgRevisionSelectionDialog( - self.vcs.hgGetTagsList(repodir), - self.vcs.hgGetBranchesList(repodir), - self.vcs.hgGetBookmarksList(repodir)) + self.vcs.hgGetTagsList(), + self.vcs.hgGetBranchesList(), + self.vcs.hgGetBookmarksList()) if dlg.exec() == QDialog.Accepted: rev = dlg.getRevision(revset=False) @@ -77,31 +67,22 @@ args.append(rev) dia = HgDialog(self.tr('Verify Signatures'), self.vcs) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() - def hgGpgSign(self, path, revisions=None): + def hgGpgSign(self, revisions=None): """ Public method used to list the available bookmarks. - @param path directory name of the project - @type str @param revisions list containing the revisions to be signed @type list of str """ - # find the root of the repo - repodir = self.vcs.splitPath(path)[0] - while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - if revisions is None: from .HgGpgSignDialog import HgGpgSignDialog - dlg = HgGpgSignDialog(self.vcs.hgGetTagsList(repodir), - self.vcs.hgGetBranchesList(repodir), - self.vcs.hgGetBookmarksList(repodir)) + dlg = HgGpgSignDialog(self.vcs.hgGetTagsList(), + self.vcs.hgGetBranchesList(), + self.vcs.hgGetBookmarksList()) if dlg.exec() == QDialog.Accepted: revision, noCommit, message, keyId, local, force = ( dlg.getData() @@ -136,6 +117,6 @@ args.append(rev) dia = HgDialog(self.tr('Sign Revision'), self.vcs) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec()
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgAnnotateDialog.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgAnnotateDialog.py Tue Jan 12 20:03:30 2021 +0100 @@ -7,7 +7,6 @@ Module implementing a dialog to show the output of the hg annotate command. """ -import os import re from PyQt5.QtCore import Qt, QCoreApplication @@ -75,15 +74,6 @@ self.activateWindow() self.lineno = 1 - dname, fname = self.vcs.splitPath(fn) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - args = self.vcs.initCommand("annotate") args.append('--follow') args.append('--user')
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgBookmarksInOutDialog.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgBookmarksInOutDialog.py Tue Jan 12 20:03:30 2021 +0100 @@ -7,8 +7,8 @@ Module implementing a dialog to show a list of incoming or outgoing bookmarks. """ -import os - +##import os +## from PyQt5.QtCore import Qt, QCoreApplication from PyQt5.QtWidgets import ( QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem @@ -71,11 +71,10 @@ e.accept() - def start(self, path): + def start(self): """ Public slot to start the bookmarks command. - @param path name of directory to be listed (string) @exception ValueError raised to indicate an invalid dialog mode """ self.errorGroup.hide() @@ -83,15 +82,6 @@ self.intercept = False self.activateWindow() - dname, fname = self.vcs.splitPath(path) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - if self.mode == self.INCOMING: args = self.vcs.initCommand("incoming") elif self.mode == self.OUTGOING:
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgBookmarksListDialog.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgBookmarksListDialog.py Tue Jan 12 20:03:30 2021 +0100 @@ -7,8 +7,6 @@ Module implementing a dialog to show a list of bookmarks. """ -import os - from PyQt5.QtCore import pyqtSlot, Qt, QCoreApplication, QPoint from PyQt5.QtWidgets import ( QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem, QLineEdit, QMenu, @@ -48,7 +46,6 @@ self.vcs = vcs self.__bookmarksList = None - self.__repoDir = None self.__hgClient = vcs.getClient() self.__bookmarksDefined = False self.__currentRevision = "" @@ -71,11 +68,10 @@ e.accept() - def start(self, path, bookmarksList): + def start(self, bookmarksList): """ Public slot to start the bookmarks command. - @param path name of directory to be listed (string) @param bookmarksList reference to string list receiving the bookmarks (list of strings) """ @@ -90,16 +86,6 @@ self.__bookmarksList = bookmarksList del self.__bookmarksList[:] # clear the list - dname, fname = self.vcs.splitPath(path) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - self.__repoDir = repodir - args = self.vcs.initCommand("bookmarks") self.refreshButton.setEnabled(False) @@ -245,7 +231,7 @@ else: self.__currentRevision = "" - self.start(self.__repoDir, self.__bookmarksList) + self.start(self.__bookmarksList) @pyqtSlot(QPoint) def on_bookmarksList_customContextMenuRequested(self, pos): @@ -286,8 +272,7 @@ itm = self.bookmarksList.currentItem() bookmark = itm.text(3).strip() if bookmark: - shouldReopen = self.vcs.vcsUpdate( - self.__repoDir, revision=bookmark) + shouldReopen = self.vcs.vcsUpdate(revision=bookmark) if shouldReopen: res = E5MessageBox.yesNo( None, @@ -314,7 +299,7 @@ self.tr("""<p>Shall the bookmark <b>{0}</b> really be""" """ deleted?</p>""").format(bookmark)) if yes: - self.vcs.hgBookmarkDelete(self.__repoDir, bookmark=bookmark) + self.vcs.hgBookmarkDelete(bookmark=bookmark) self.on_refreshButton_clicked() def __renameBookmark(self): @@ -331,7 +316,7 @@ .format(bookmark), QLineEdit.Normal) if ok and bool(newName): - self.vcs.hgBookmarkRename(self.__repoDir, (bookmark, newName)) + self.vcs.hgBookmarkRename((bookmark, newName)) self.on_refreshButton_clicked() def __pullBookmark(self): @@ -341,7 +326,7 @@ itm = self.bookmarksList.currentItem() bookmark = itm.text(3).strip() if bookmark: - self.vcs.hgBookmarkPull(self.__repoDir, bookmark=bookmark) + self.vcs.hgBookmarkPull(bookmark=bookmark) self.on_refreshButton_clicked() def __pushBookmark(self): @@ -351,5 +336,5 @@ itm = self.bookmarksList.currentItem() bookmark = itm.text(3).strip() if bookmark: - self.vcs.hgBookmarkPush(self.__repoDir, bookmark=bookmark) + self.vcs.hgBookmarkPush(bookmark=bookmark) self.on_refreshButton_clicked()
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgConflictsListDialog.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgConflictsListDialog.py Tue Jan 12 20:03:30 2021 +0100 @@ -8,8 +8,6 @@ conflicts. """ -import os - from PyQt5.QtCore import pyqtSlot, Qt, QPoint from PyQt5.QtWidgets import ( QAbstractButton, QDialogButtonBox, QHeaderView, QTreeWidgetItem, @@ -83,25 +81,14 @@ super(HgConflictsListDialog, self).show() - def start(self, path): + def start(self): """ Public slot to start the tags command. - - @param path name of directory to list conflicts for (string) """ self.errorGroup.hide() QApplication.processEvents() self.intercept = False - dname, fname = self.vcs.splitPath(path) - - # find the root of the repo - self.__repodir = dname - while not os.path.isdir( - os.path.join(self.__repodir, self.vcs.adminDir)): - self.__repodir = os.path.dirname(self.__repodir) - if os.path.splitdrive(self.__repodir)[1] == os.sep: - return self.activateWindow() self.raise_() @@ -220,7 +207,7 @@ self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) self.refreshButton.setEnabled(False) - self.start(self.__repodir) + self.start() @pyqtSlot(QTreeWidgetItem, int) def on_conflictsList_itemDoubleClicked(self, item, column):
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgDialog.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgDialog.py Tue Jan 12 20:03:30 2021 +0100 @@ -79,6 +79,7 @@ elif button == self.buttonBox.button(QDialogButtonBox.Cancel): self.vcs.getClient().cancel() + # TODO: workingDir is obsolete def startProcess(self, args, workingDir=None, showArgs=True, environment=None): """
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Tue Jan 12 20:03:30 2021 +0100 @@ -991,7 +991,6 @@ args.append('{0}:0'.format(startRev)) if ( not self.projectMode and - not self.fname == "." and not self.stopCheckBox.isChecked() ): args.append('--follow') @@ -1050,15 +1049,18 @@ self.commandMode = "log" self.__finish() - def start(self, fn, bundle=None, isFile=False, noEntries=0): + def start(self, name=None, bundle=None, isFile=False, noEntries=0): """ Public slot to start the hg log command. - @param fn filename to show the log for (string) - @param bundle name of a bundle file (string) + @param name file/directory name to show the log for + @type str + @param bundle name of a bundle file + @type str @param isFile flag indicating log for a file is to be shown - (boolean) - @param noEntries number of entries to get (0 = default) (int) + @type bool + @param noEntries number of entries to get (0 = default) + @type int """ self.__bundle = bundle self.__isFile = isFile @@ -1079,18 +1081,10 @@ self.__initData() - self.__filename = fn - self.dname, self.fname = self.vcs.splitPath(fn) + self.__filename = name - # find the root of the repo - self.repodir = self.dname - while not os.path.isdir(os.path.join(self.repodir, self.vcs.adminDir)): - self.repodir = os.path.dirname(self.repodir) - if os.path.splitdrive(self.repodir)[1] == os.sep: - return - - self.projectMode = (self.fname == "." and self.dname == self.repodir) - self.stopCheckBox.setDisabled(self.projectMode or self.fname == ".") + self.projectMode = name is None + self.stopCheckBox.setDisabled(self.projectMode) self.activateWindow() self.raise_() @@ -1961,7 +1955,7 @@ else: newPhase = self.phases["draft"] data = (revs, "d", False) - res = self.vcs.hgPhase(self.repodir, data) + res = self.vcs.hgPhase(data) if res: for itm in self.logTree.selectedItems(): itm.setText(self.PhaseColumn, newPhase) @@ -1981,7 +1975,7 @@ itm.text(self.RevisionColumn).strip().split(":", 1)[0]) if revs: - shouldReopen = self.vcs.hgGraft(self.repodir, revs) + shouldReopen = self.vcs.hgGraft(revs) if shouldReopen: res = E5MessageBox.yesNo( None, @@ -2005,7 +1999,7 @@ itm = self.logTree.selectedItems()[0] rev = itm.text(self.RevisionColumn).strip().split(":", 1)[0] tag = itm.text(self.TagsColumn).strip().split(", ", 1)[0] - res = self.vcs.vcsTag(self.repodir, revision=rev, tagName=tag) + res = self.vcs.vcsTag(revision=rev, tagName=tag) if res: self.on_refreshButton_clicked() @@ -2022,8 +2016,7 @@ if revs: closeheadExtension = self.vcs.getExtensionObject("closehead") if closeheadExtension is not None: - closeheadExtension.hgCloseheads( - self.repodir, revisions=revs) + closeheadExtension.hgCloseheads(revisions=revs) self.on_refreshButton_clicked() @@ -2053,7 +2046,7 @@ if bookmark: rev = bookmark if rev: - shouldReopen = self.vcs.vcsUpdate(self.repodir, revision=rev) + shouldReopen = self.vcs.vcsUpdate(revision=rev) if shouldReopen: res = E5MessageBox.yesNo( None, @@ -2086,7 +2079,7 @@ QLineEdit.Normal) if ok and bool(bookmark): self.vcs.hgBookmarkDefine( - self.repodir, revision="rev({0})".format(rev), + revision="rev({0})".format(rev), bookmark=bookmark) self.on_refreshButton_clicked() @@ -2101,7 +2094,7 @@ rev, changeset = ( itm.text(self.RevisionColumn).strip().split(":", 1) ) - bookmarksList = self.vcs.hgGetBookmarksList(self.repodir) + bookmarksList = self.vcs.hgGetBookmarksList() bookmark, ok = QInputDialog.getItem( self, self.tr("Move Bookmark"), @@ -2111,7 +2104,7 @@ 0, False) if ok and bool(bookmark): self.vcs.hgBookmarkMove( - self.repodir, revision="rev({0})".format(rev), + revision="rev({0})".format(rev), bookmark=bookmark) self.on_refreshButton_clicked() @@ -2128,8 +2121,7 @@ revs.append(rev) if revs: - self.vcs.getExtensionObject("largefiles").hgLfPull( - self.repodir, revisions=revs) + self.vcs.getExtensionObject("largefiles").hgLfPull(revisions=revs) @pyqtSlot() def __pullActTriggered(self): @@ -2147,7 +2139,7 @@ rev = itm.text(self.RevisionColumn).split(":")[1].strip() if rev: revs.append(rev) - shouldReopen = self.vcs.hgPull(self.repodir, revisions=revs) + shouldReopen = self.vcs.hgPull(revisions=revs) refresh = True if self.initialCommandMode == "incoming": addNext = True @@ -2176,7 +2168,7 @@ if not itm.data(0, self.__incomingRole): rev = itm.text(self.RevisionColumn).strip().split(":", 1)[0] if rev: - self.vcs.hgPush(self.repodir, rev=rev) + self.vcs.hgPush(rev=rev) self.on_refreshButton_clicked( addNext=self.initialCommandMode == "outgoing") @@ -2185,7 +2177,7 @@ """ Private slot to push all changes to a remote repository. """ - self.vcs.hgPush(self.repodir) + self.vcs.hgPush() self.on_refreshButton_clicked() @pyqtSlot() @@ -2197,7 +2189,7 @@ if not itm.data(0, self.__incomingRole): rev = itm.text(self.RevisionColumn).strip().split(":", 1)[1] shouldReopen = self.vcs.getExtensionObject("strip").hgStrip( - self.repodir, rev=rev) + rev=rev) if shouldReopen: res = E5MessageBox.yesNo( None, @@ -2221,7 +2213,7 @@ if not itm.data(0, self.__incomingRole): rev = "rev({0})".format( itm.text(self.RevisionColumn).strip().split(":", 1)[0]) - self.vcs.vcsMerge(self.repodir, rev=rev) + self.vcs.vcsMerge("", rev=rev) @pyqtSlot() def __bundleActTriggered(self): @@ -2280,7 +2272,7 @@ "all": False, } - self.vcs.hgBundle(self.repodir, bundleData=bundleData) + self.vcs.hgBundle(bundleData=bundleData) @pyqtSlot() def __unbundleActTriggered(self): @@ -2288,8 +2280,7 @@ Private slot to apply the currently previewed bundle file. """ if self.initialCommandMode == "incoming" and bool(self.__bundle): - shouldReopen = self.vcs.hgUnbundle(self.repodir, - files=[self.__bundle]) + shouldReopen = self.vcs.hgUnbundle(files=[self.__bundle]) if shouldReopen: res = E5MessageBox.yesNo( None, @@ -2300,7 +2291,7 @@ e5App().getObject("Project").reopenProject() return - self.vcs.vcsLogBrowser(self.repodir) + self.vcs.vcsLogBrowser() self.close() @pyqtSlot() @@ -2316,8 +2307,7 @@ revs.append(rev) if revs: - self.vcs.getExtensionObject("gpg").hgGpgSign( - self.repodir, revisions=revs) + self.vcs.getExtensionObject("gpg").hgGpgSign(revisions=revs) @pyqtSlot() def __gpgVerifyActTriggered(self): @@ -2329,7 +2319,7 @@ rev = itm.text(self.RevisionColumn).split(":", 1)[0].strip() if rev: self.vcs.getExtensionObject("gpg").hgGpgVerifySignatures( - self.repodir, rev=rev) + rev=rev) def __selectAllActTriggered(self, select=True): """ @@ -2685,7 +2675,7 @@ @param link text of the selected link @type str """ - if ":" in link: + if ":" in link and self.__filename is not None: scheme, path = link.split(":", 1) if scheme == "sbsdiff" and "_" in path: rev1, rev2 = path.split("_", 1)
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgStatusDialog.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgStatusDialog.py Tue Jan 12 20:03:30 2021 +0100 @@ -327,13 +327,6 @@ self.dname, fname = self.vcs.splitPath(fn) args.append(fn) - # find the root of the repo - repodir = self.dname - while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - self.refreshButton.setEnabled(False) out, err = self.__hgClient.runcommand(args) @@ -448,7 +441,7 @@ """ Private slot to prepare the actions button menu before it is shown. """ - if self.vcs.canCommitMerge(self.dname): + if self.vcs.canCommitMerge(): self.__commitMergeAct.setEnabled(True) self.__abortMergeAct.setEnabled(True) @@ -776,7 +769,7 @@ """ Private slot used to abort an uncommitted merge. """ - self.vcs.hgAbortMerge(self.dname) + self.vcs.hgAbortMerge() self.__committed() ###########################################################################
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgSummaryDialog.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgSummaryDialog.py Tue Jan 12 20:03:30 2021 +0100 @@ -8,8 +8,6 @@ directory state. """ -import os - from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QDialog, QDialogButtonBox @@ -40,11 +38,10 @@ self.vcs = vcs self.vcs.committed.connect(self.__committed) - def start(self, path, mq=False, largefiles=False): + def start(self, mq=False, largefiles=False): """ Public slot to start the hg summary command. - @param path path name of the working directory (string) @param mq flag indicating to show the queue status as well (boolean) @param largefiles flag indicating to show the largefiles status as well (boolean) @@ -53,7 +50,6 @@ self.refreshButton.setEnabled(False) self.summary.clear() - self.__path = path self.__mq = mq self.__largefiles = largefiles @@ -65,13 +61,6 @@ if self.__largefiles: args.append("--large") - # find the root of the repo - repodir = self.__path - while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - client = self.vcs.getClient() output, error = client.runcommand(args) if error: @@ -97,7 +86,7 @@ """ Private slot to refresh the status display. """ - self.start(self.__path, mq=self.__mq) + self.start(mq=self.__mq) def __committed(self): """
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgTagBranchListDialog.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgTagBranchListDialog.py Tue Jan 12 20:03:30 2021 +0100 @@ -7,8 +7,6 @@ Module implementing a dialog to show a list of tags or branches. """ -import os - from PyQt5.QtCore import pyqtSlot, Qt, QCoreApplication, QPoint from PyQt5.QtWidgets import ( QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem, QMenu, @@ -71,11 +69,10 @@ e.accept() - def start(self, path, tags, tagsList, allTagsList): + def start(self, tags, tagsList, allTagsList): """ Public slot to start the tags command. - @param path name of directory to be listed (string) @param tags flag indicating a list of tags is requested (False = branches, True = tags) @param tagsList reference to string list receiving the tags @@ -97,15 +94,6 @@ self.tagsList = tagsList self.allTagsList = allTagsList - dname, fname = self.vcs.splitPath(path) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - self.__repoDir = repodir if self.tagsMode: args = self.vcs.initCommand("tags") @@ -241,7 +229,7 @@ """ Private method to highlight the current branch with a bold font. """ - self.__currentBranch = self.vcs.hgGetCurrentBranch(self.__repoDir) + self.__currentBranch = self.vcs.hgGetCurrentBranch() if self.__currentBranch: items = self.tagList.findItems( self.__currentBranch, Qt.MatchCaseSensitive, 3) @@ -269,8 +257,7 @@ else: self.__currentRevision = "" - self.start(self.__repoDir, self.tagsMode, self.tagsList, - self.allTagsList) + self.start(self.tagsMode, self.tagsList, self.allTagsList) @pyqtSlot(QPoint) def on_tagList_customContextMenuRequested(self, pos): @@ -315,7 +302,7 @@ itm = self.tagList.currentItem() rev = itm.text(0).strip() if rev: - shouldReopen = self.vcs.vcsUpdate(self.__repoDir, revision=rev) + shouldReopen = self.vcs.vcsUpdate(revision=rev) if shouldReopen: res = E5MessageBox.yesNo( None, @@ -350,19 +337,19 @@ """</p>""").format(branch)) if yes: switched = False - currentBranch = self.vcs.hgGetCurrentBranch(self.__repoDir) + currentBranch = self.vcs.hgGetCurrentBranch() if currentBranch != branch: # step 1: switch to branch to be closed switched = True - self.vcs.vcsUpdate(self.__repoDir, noDialog=True, + self.vcs.vcsUpdate(noDialog=True, revision=branch) - self.vcs.vcsCommit(self.__repoDir, - "Branch <{0}> closed.".format(branch), + + ppath = e5App().getObject("Project").getProjectPath() + self.vcs.vcsCommit(ppath, "Branch <{0}> closed.".format(branch), noDialog=True, closeBranch=True) if switched: - self.vcs.vcsUpdate(self.__repoDir, noDialog=True, - revision=currentBranch) + self.vcs.vcsUpdate(noDialog=True, revision=currentBranch) self.on_refreshButton_clicked() @@ -384,5 +371,4 @@ branches) yes = dlg.exec() == QDialog.Accepted if yes: - self.vcs.getExtensionObject("closehead").hgCloseheads( - self.__repoDir, branches) + self.vcs.getExtensionObject("closehead").hgCloseheads(branches)
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/histedit.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/histedit.py Tue Jan 12 20:03:30 2021 +0100 @@ -49,9 +49,9 @@ from .HgHisteditConfigDialog import HgHisteditConfigDialog res = False - dlg = HgHisteditConfigDialog(self.vcs.hgGetTagsList(repodir), - self.vcs.hgGetBranchesList(repodir), - self.vcs.hgGetBookmarksList(repodir), + dlg = HgHisteditConfigDialog(self.vcs.hgGetTagsList(), + self.vcs.hgGetBranchesList(), + self.vcs.hgGetBookmarksList(), rev) if dlg.exec() == QDialog.Accepted: rev, force, keep = dlg.getData()
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/ProjectHelper.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/ProjectHelper.py Tue Jan 12 20:03:30 2021 +0100 @@ -206,8 +206,7 @@ """ Private slot to pull missing large files into the local repository. """ - self.vcs.getExtensionObject("largefiles").hgLfPull( - self.project.getProjectPath()) + self.vcs.getExtensionObject("largefiles").hgLfPull() def __hgLfSummary(self): """
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/largefiles.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/largefiles.py Tue Jan 12 20:03:30 2021 +0100 @@ -138,20 +138,12 @@ if res: dia.exec() - def hgLfPull(self, projectDir, revisions=None): + def hgLfPull(self, revisions=None): """ Public method to pull missing large files into the local repository. - @param projectDir directory name of the project (string) @param revisions list of revisions to pull (list of string) """ - # find the root of the repo - repodir = projectDir - while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - revs = [] if revisions: revs = revisions @@ -169,7 +161,7 @@ args.append(rev) dia = HgDialog(self.tr("Pulling large files"), self.vcs) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec()
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py Tue Jan 12 20:03:30 2021 +0100 @@ -1308,8 +1308,7 @@ self.hgBookmarkOutgoingAct.setEnabled(self.vcs.canPush()) if self.vcs.version >= (3, 8): self.hgBookmarkPushCurrentAct.setEnabled(self.vcs.canPull()) - self.hgCommitMergeAct.setEnabled( - self.vcs.canCommitMerge(self.project.ppath)) + self.hgCommitMergeAct.setEnabled(self.vcs.canCommitMerge()) def initMenu(self, menu): """ @@ -1654,20 +1653,20 @@ Private slot used to show the log of changes coming into the repository. """ - self.vcs.hgIncoming(self.project.ppath) + self.vcs.hgIncoming() def __hgOutgoing(self): """ Private slot used to show the log of changes going out of the repository. """ - self.vcs.hgOutgoing(self.project.ppath) + self.vcs.hgOutgoing() def __hgPull(self): """ Private slot used to pull changes from a remote repository. """ - shouldReopen = self.vcs.hgPull(self.project.ppath) + shouldReopen = self.vcs.hgPull() if shouldReopen: res = E5MessageBox.yesNo( self.parent(), @@ -1681,32 +1680,32 @@ """ Private slot used to push changes to a remote repository. """ - self.vcs.hgPush(self.project.ppath) + self.vcs.hgPush() def __hgPushForced(self): """ Private slot used to push changes to a remote repository using the force option. """ - self.vcs.hgPush(self.project.ppath, force=True) + self.vcs.hgPush(force=True) def __hgHeads(self): """ Private slot used to show the heads of the repository. """ - self.vcs.hgInfo(self.project.ppath, mode="heads") + self.vcs.hgInfo(mode="heads") def __hgParents(self): """ Private slot used to show the parents of the repository. """ - self.vcs.hgInfo(self.project.ppath, mode="parents") + self.vcs.hgInfo(mode="parents") def __hgTip(self): """ Private slot used to show the tip of the repository. """ - self.vcs.hgInfo(self.project.ppath, mode="tip") + self.vcs.hgInfo(mode="tip") def __hgResolved(self): """ @@ -1732,13 +1731,13 @@ """ Private slot used to abort an uncommitted merge. """ - self.vcs.hgAbortMerge(self.project.ppath) + self.vcs.hgAbortMerge() def __hgShowConflicts(self): """ Private slot used to list all files with conflicts. """ - self.vcs.hgConflicts(self.project.ppath) + self.vcs.hgConflicts() def __hgReMerge(self): """ @@ -1750,25 +1749,25 @@ """ Private slot used to list the tags of the project. """ - self.vcs.hgListTagBranch(self.project.ppath, True) + self.vcs.hgListTagBranch(True) def __hgBranchList(self): """ Private slot used to list the branches of the project. """ - self.vcs.hgListTagBranch(self.project.ppath, False) + self.vcs.hgListTagBranch(False) def __hgBranch(self): """ Private slot used to create a new branch for the project. """ - self.vcs.hgBranch(self.project.ppath) + self.vcs.hgBranch() def __hgShowBranch(self): """ Private slot used to show the current branch for the project. """ - self.vcs.hgShowBranch(self.project.ppath) + self.vcs.hgShowBranch() def __hgConfigure(self): """ @@ -1790,7 +1789,7 @@ """ Private slot to push a new named branch. """ - self.vcs.hgPush(self.project.ppath, newBranch=True) + self.vcs.hgPush(newBranch=True) def __hgEditUserConfig(self): """ @@ -1808,31 +1807,31 @@ """ Private slot used to show the combined configuration. """ - self.vcs.hgShowConfig(self.project.ppath) + self.vcs.hgShowConfig() def __hgVerify(self): """ Private slot used to verify the integrity of the repository. """ - self.vcs.hgVerify(self.project.ppath) + self.vcs.hgVerify() def __hgShowPaths(self): """ Private slot used to show the aliases for remote repositories. """ - self.vcs.hgShowPaths(self.project.ppath) + self.vcs.hgShowPaths() def __hgRecover(self): """ Private slot used to recover from an interrupted transaction. """ - self.vcs.hgRecover(self.project.ppath) + self.vcs.hgRecover() def __hgIdentify(self): """ Private slot used to identify the project directory. """ - self.vcs.hgIdentify(self.project.ppath) + self.vcs.hgIdentify() def __hgCreateIgnore(self): """ @@ -1844,19 +1843,19 @@ """ Private slot used to create a changegroup file. """ - self.vcs.hgBundle(self.project.ppath) + self.vcs.hgBundle() def __hgPreviewBundle(self): """ Private slot used to preview a changegroup file. """ - self.vcs.hgPreviewBundle(self.project.ppath) + self.vcs.hgPreviewBundle() def __hgUnbundle(self): """ Private slot used to apply changegroup files. """ - shouldReopen = self.vcs.hgUnbundle(self.project.ppath) + shouldReopen = self.vcs.hgUnbundle() if shouldReopen: res = E5MessageBox.yesNo( self.parent(), @@ -1870,37 +1869,37 @@ """ Private slot used to execute the bisect --good command. """ - self.vcs.hgBisect(self.project.ppath, "good") + self.vcs.hgBisect("good") def __hgBisectBad(self): """ Private slot used to execute the bisect --bad command. """ - self.vcs.hgBisect(self.project.ppath, "bad") + self.vcs.hgBisect("bad") def __hgBisectSkip(self): """ Private slot used to execute the bisect --skip command. """ - self.vcs.hgBisect(self.project.ppath, "skip") + self.vcs.hgBisect("skip") def __hgBisectReset(self): """ Private slot used to execute the bisect --reset command. """ - self.vcs.hgBisect(self.project.ppath, "reset") + self.vcs.hgBisect("reset") def __hgBackout(self): """ Private slot used to back out changes of a changeset. """ - self.vcs.hgBackout(self.project.ppath) + self.vcs.hgBackout() def __hgRollback(self): """ Private slot used to rollback the last transaction. """ - self.vcs.hgRollback(self.project.ppath) + self.vcs.hgRollback() def __hgServe(self): """ @@ -1912,7 +1911,7 @@ """ Private slot used to import a patch file. """ - shouldReopen = self.vcs.hgImport(self.project.ppath) + shouldReopen = self.vcs.hgImport() if shouldReopen: res = E5MessageBox.yesNo( self.parent(), @@ -1926,7 +1925,7 @@ """ Private slot used to export revisions to patch files. """ - self.vcs.hgExport(self.project.ppath) + self.vcs.hgExport() def __hgRevert(self): """ @@ -1946,13 +1945,13 @@ """ Private slot used to change the phase of revisions. """ - self.vcs.hgPhase(self.project.ppath) + self.vcs.hgPhase() def __hgGraft(self): """ Private slot used to copy changesets from another branch. """ - shouldReopen = self.vcs.hgGraft(self.project.getProjectPath()) + shouldReopen = self.vcs.hgGraft() if shouldReopen: res = E5MessageBox.yesNo( None, @@ -1967,7 +1966,7 @@ Private slot used to continue the last copying session after conflicts were resolved. """ - shouldReopen = self.vcs.hgGraftContinue(self.project.getProjectPath()) + shouldReopen = self.vcs.hgGraftContinue() if shouldReopen: res = E5MessageBox.yesNo( None, @@ -1981,7 +1980,7 @@ """ Private slot used to stop an interrupted copying session. """ - shouldReopen = self.vcs.hgGraftStop(self.project.getProjectPath()) + shouldReopen = self.vcs.hgGraftStop() if shouldReopen: res = E5MessageBox.yesNo( None, @@ -1996,7 +1995,7 @@ Private slot used to abort an interrupted copying session and perform a rollback. """ - shouldReopen = self.vcs.hgGraftAbort(self.project.getProjectPath()) + shouldReopen = self.vcs.hgGraftAbort() if shouldReopen: res = E5MessageBox.yesNo( None, @@ -2034,68 +2033,68 @@ """ Private slot used to list the bookmarks. """ - self.vcs.hgListBookmarks(self.project.getProjectPath()) + self.vcs.hgListBookmarks() def __hgBookmarkDefine(self): """ Private slot used to define a bookmark. """ - self.vcs.hgBookmarkDefine(self.project.getProjectPath()) + self.vcs.hgBookmarkDefine() def __hgBookmarkDelete(self): """ Private slot used to delete a bookmark. """ - self.vcs.hgBookmarkDelete(self.project.getProjectPath()) + self.vcs.hgBookmarkDelete() def __hgBookmarkRename(self): """ Private slot used to rename a bookmark. """ - self.vcs.hgBookmarkRename(self.project.getProjectPath()) + self.vcs.hgBookmarkRename() def __hgBookmarkMove(self): """ Private slot used to move a bookmark. """ - self.vcs.hgBookmarkMove(self.project.getProjectPath()) + self.vcs.hgBookmarkMove() def __hgBookmarkIncoming(self): """ Private slot used to show a list of incoming bookmarks. """ - self.vcs.hgBookmarkIncoming(self.project.getProjectPath()) + self.vcs.hgBookmarkIncoming() def __hgBookmarkOutgoing(self): """ Private slot used to show a list of outgoing bookmarks. """ - self.vcs.hgBookmarkOutgoing(self.project.getProjectPath()) + self.vcs.hgBookmarkOutgoing() def __hgBookmarkPull(self): """ Private slot used to pull a bookmark from a remote repository. """ - self.vcs.hgBookmarkPull(self.project.getProjectPath()) + self.vcs.hgBookmarkPull() def __hgBookmarkPullCurrent(self): """ Private slot used to pull the current bookmark from a remote repository. """ - self.vcs.hgBookmarkPull(self.project.getProjectPath(), current=True) + self.vcs.hgBookmarkPull(current=True) def __hgBookmarkPush(self): """ Private slot used to push a bookmark to a remote repository. """ - self.vcs.hgBookmarkPush(self.project.getProjectPath()) + self.vcs.hgBookmarkPush() def __hgBookmarkPushCurrent(self): """ Private slot used to push the current bookmark to a remote repository. """ - self.vcs.hgBookmarkPush(self.project.getProjectPath(), current=True) + self.vcs.hgBookmarkPush(current=True) def __hgDeleteBackups(self): """
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/RebaseExtension/rebase.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/RebaseExtension/rebase.py Tue Jan 12 20:03:30 2021 +0100 @@ -43,9 +43,9 @@ res = False from .HgRebaseDialog import HgRebaseDialog - dlg = HgRebaseDialog(self.vcs.hgGetTagsList(repodir), - self.vcs.hgGetBranchesList(repodir), - self.vcs.hgGetBookmarksList(repodir), + dlg = HgRebaseDialog(self.vcs.hgGetTagsList(), + self.vcs.hgGetBranchesList(), + self.vcs.hgGetBookmarksList(), self.vcs.version) if dlg.exec() == QDialog.Accepted: (indicator, sourceRev, destRev, collapse, keep, keepBranches,
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/StripExtension/strip.py Tue Jan 12 17:19:02 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/StripExtension/strip.py Tue Jan 12 20:03:30 2021 +0100 @@ -7,8 +7,6 @@ Module implementing the strip extension interface. """ -import os - from PyQt5.QtWidgets import QDialog from ..HgExtension import HgExtension @@ -28,29 +26,20 @@ """ super(Strip, self).__init__(vcs) - def hgStrip(self, name, rev=""): + def hgStrip(self, rev=""): """ Public method to strip revisions from a repository. - @param name file/directory name - @type str @param rev revision to strip from @type str @return flag indicating that the project should be reread @rtype bool """ - # find the root of the repo - repodir = self.vcs.splitPath(name)[0] - while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return False - from .HgStripDialog import HgStripDialog res = False - dlg = HgStripDialog(self.vcs.hgGetTagsList(repodir), - self.vcs.hgGetBranchesList(repodir), - self.vcs.hgGetBookmarksList(repodir), + dlg = HgStripDialog(self.vcs.hgGetTagsList(), + self.vcs.hgGetBranchesList(), + self.vcs.hgGetBookmarksList(), rev) if dlg.exec() == QDialog.Accepted: rev, bookmark, force, noBackup, keep = dlg.getData() @@ -71,7 +60,7 @@ dia = HgDialog( self.tr("Stripping changesets from repository"), self.vcs) - res = dia.startProcess(args, repodir) + res = dia.startProcess(args) if res: dia.exec() res = dia.hasAddOrDelete()
--- 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()