Thu, 09 Feb 2017 20:03:00 +0100
Started to add a 'Create Changegroup' action to the Mercurial log browser tools menu.
Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py | file | annotate | diff | comparison | revisions | |
Plugins/VcsPlugins/vcsMercurial/hg.py | file | annotate | diff | comparison | revisions |
--- a/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Thu Feb 09 19:52:17 2017 +0100 +++ b/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Thu Feb 09 20:03:00 2017 +0100 @@ -316,6 +316,23 @@ self.__actionsMenu.addSeparator() + self.__bundleAct = self.__actionsMenu.addAction( + UI.PixmapCache.getIcon("vcsCreateChangegroup.png"), + self.tr("Create Changegroup"), self.__bundleActTriggered) + self.__bundleAct.setToolTip(self.tr( + "Create a changegroup file containing the selected changesets")) + self.__bundleAct.setWhatsThis(self.tr( + """<b>Create Changegroup</b>\n<p>This creates a changegroup""" + """ file containing the selected revisions. If no revisions""" + """ are selected, all changesets will be bundled. If one""" + """ revision is selected, it will be interpreted as the base""" + """ revision. Otherwise the lowest revision will be used as""" + """ the base revision and all other revision will be bundled.""" + """ If the dialog is showing outgoing changesets, all""" + """ selected changesets will be bundled.</p>""")) + + self.__actionsMenu.addSeparator() + self.__stripAct = self.__actionsMenu.addAction( UI.PixmapCache.getIcon("fileDelete.png"), self.tr("Strip Changesets"), self.__stripActTriggered) @@ -326,7 +343,7 @@ UI.PixmapCache.getIcon("actionsToolButton.png")) self.actionsButton.setMenu(self.__actionsMenu) - # TODO: add action "Create Changegroup" (>=2 revs, lowest rev is base) + # TODO: add action "Create Changegroup" (>=1 revs, lowest rev is base) # TODO: add action "Sign Revision" (>= 1 revs) (GPG extension) # TODO: add action "Verify Signature" (1 rev) (GPG extension) @@ -1457,9 +1474,12 @@ self.vcs.isExtensionActive("strip") and len(self.logTree.selectedItems()) == 1) + self.__bundleAct.setEnabled(self.logTree.topLevelItemCount() > 0) + self.actionsButton.setEnabled(True) else: self.actionsButton.setEnabled(False) + # TODO: add code to enable menu in incoming / outgoing mode as well def __updateDetailsAndFiles(self): """ @@ -2134,6 +2154,18 @@ itm.text(self.RevisionColumn).strip().split(":", 1)[0]) self.vcs.vcsMerge(self.repodir, rev=rev) + @pyqtSlot() + def __bundleActTriggered(self): + """ + Private slot to create a changegroup file. + """ + if self.initialCommandMode == "log": + # TODO: implement bundle + pass + elif self.initialCommandMode == "outgoing": + # TODO: implement bundle for outgoing mode + pass + def __actionMode(self): """ Private method to get the selected action mode.
--- a/Plugins/VcsPlugins/vcsMercurial/hg.py Thu Feb 09 19:52:17 2017 +0100 +++ b/Plugins/VcsPlugins/vcsMercurial/hg.py Thu Feb 09 20:03:00 2017 +0100 @@ -2518,11 +2518,14 @@ return status - def hgBundle(self, name): + def hgBundle(self, name, bundleData=None): """ Public method to create a changegroup file. - @param name file/directory name (string) + @param name file/directory name + @type str + @param bundleData dictionary containing the bundle creation information + @type dict """ dname, fname = self.splitPath(name) @@ -2533,60 +2536,68 @@ if os.path.splitdrive(repodir)[1] == os.sep: return - from .HgBundleDialog import HgBundleDialog - dlg = HgBundleDialog(self.hgGetTagsList(repodir), - self.hgGetBranchesList(repodir), - self.hgGetBookmarksList(repodir)) - if dlg.exec_() == QDialog.Accepted: - revs, baseRevs, compression, all = dlg.getParameters() - - fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( - None, - self.tr("Create changegroup"), - self.__lastChangeGroupPath or repodir, - self.tr("Mercurial Changegroup Files (*.hg)"), - None, - E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) - - if not fname: - return # user aborted + if bundleData is None: + from .HgBundleDialog import HgBundleDialog + dlg = HgBundleDialog(self.hgGetTagsList(repodir), + self.hgGetBranchesList(repodir), + self.hgGetBookmarksList(repodir)) + if dlg.exec_() != QDialog.Accepted: + return - ext = QFileInfo(fname).suffix() - if not ext: - ex = selectedFilter.split("(*")[1].split(")")[0] - if ex: - fname += ex - if QFileInfo(fname).exists(): - res = E5MessageBox.yesNo( - self.__ui, - self.tr("Create changegroup"), - self.tr("<p>The Mercurial changegroup file <b>{0}</b> " - "already exists. Overwrite it?</p>") - .format(fname), - icon=E5MessageBox.Warning) - if not res: - return - fname = Utilities.toNativeSeparators(fname) - self.__lastChangeGroupPath = os.path.dirname(fname) - - args = self.initCommand("bundle") - if all: - args.append("--all") - for rev in revs: - args.append("--rev") - args.append(rev) - for baseRev in baseRevs: - args.append("--base") - args.append(baseRev) - if compression: - args.append("--type") - args.append(compression) - args.append(fname) - - dia = HgDialog(self.tr('Create changegroup'), self) - res = dia.startProcess(args, repodir) - if res: - dia.exec_() + revs, baseRevs, compression, all = dlg.getParameters() + else: + revs = bundleData["revs"] + baseRevs = [bundleData["base"]] + compression = "" + all = bundleData["all"] + + fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( + None, + self.tr("Create changegroup"), + self.__lastChangeGroupPath or repodir, + self.tr("Mercurial Changegroup Files (*.hg)"), + None, + E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) + + if not fname: + return # user aborted + + ext = QFileInfo(fname).suffix() + if not ext: + ex = selectedFilter.split("(*")[1].split(")")[0] + if ex: + fname += ex + if QFileInfo(fname).exists(): + res = E5MessageBox.yesNo( + self.__ui, + self.tr("Create changegroup"), + self.tr("<p>The Mercurial changegroup file <b>{0}</b> " + "already exists. Overwrite it?</p>") + .format(fname), + icon=E5MessageBox.Warning) + if not res: + return + fname = Utilities.toNativeSeparators(fname) + self.__lastChangeGroupPath = os.path.dirname(fname) + + args = self.initCommand("bundle") + if all: + args.append("--all") + for rev in revs: + args.append("--rev") + args.append(rev) + for baseRev in baseRevs: + args.append("--base") + args.append(baseRev) + if compression: + args.append("--type") + args.append(compression) + args.append(fname) + + dia = HgDialog(self.tr('Create changegroup'), self) + res = dia.startProcess(args, repodir) + if res: + dia.exec_() def hgPreviewBundle(self, name): """