Sat, 04 Aug 2018 14:48:27 +0200
hg, ProjectHelper: added support for graft --stop and graft --abort as of Mercurial 4.7.0.
Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py | file | annotate | diff | comparison | revisions | |
Plugins/VcsPlugins/vcsMercurial/hg.py | file | annotate | diff | comparison | revisions |
--- a/Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py Sat Aug 04 14:05:07 2018 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py Sat Aug 04 14:48:27 2018 +0200 @@ -971,8 +971,6 @@ self.hgPhaseAct.triggered.connect(self.__hgPhase) self.actions.append(self.hgPhaseAct) - # TODO: Mercurial 4.7: add action for graft --stop - # TODO: Mercurial 4.7: add action for graft --abort self.hgGraftAct = E5Action( self.tr('Copy Changesets'), UI.PixmapCache.getIcon("vcsGraft.png"), @@ -1005,6 +1003,36 @@ self.hgGraftContinueAct.triggered.connect(self.__hgGraftContinue) self.actions.append(self.hgGraftContinueAct) + if self.vcs.version >= (4, 7, 0): + self.hgGraftStopAct = E5Action( + self.tr('Stop Copying Session'), + self.tr('Stop Copying Session'), + 0, 0, self, 'mercurial_graft_stop') + self.hgGraftStopAct.setStatusTip(self.tr( + 'Stop the interrupted copying session' + )) + self.hgGraftStopAct.setWhatsThis(self.tr( + """<b>Stop Copying Session</b>""" + """<p>This stops the interrupted copying session.</p>""" + )) + self.hgGraftStopAct.triggered.connect(self.__hgGraftStop) + self.actions.append(self.hgGraftStopAct) + + self.hgGraftAbortAct = E5Action( + self.tr('Abort Copying Session'), + self.tr('Abort Copying Session'), + 0, 0, self, 'mercurial_graft_abort') + self.hgGraftAbortAct.setStatusTip(self.tr( + 'Abort the interrupted copying session and rollback' + )) + self.hgGraftAbortAct.setWhatsThis(self.tr( + """<b>Abort Copying Session</b>""" + """<p>This aborts the interrupted copying session and""" + """ rollbacks to the state before the copy.</p>""" + )) + self.hgGraftAbortAct.triggered.connect(self.__hgGraftAbort) + self.actions.append(self.hgGraftAbortAct) + self.hgAddSubrepoAct = E5Action( self.tr('Add'), UI.PixmapCache.getIcon("vcsAdd.png"), @@ -1377,13 +1405,14 @@ self.__extensionsMenu)) self.vcs.activeExtensionsChanged.connect(self.__showExtensionMenu) - # TODO: Mercurial 4.7: add action for graft --stop - # TODO: Mercurial 4.7: add action for graft --abort graftMenu = QMenu(self.tr("Copy Changesets"), menu) graftMenu.setIcon(UI.PixmapCache.getIcon("vcsGraft.png")) graftMenu.setTearOffEnabled(True) graftMenu.addAction(self.hgGraftAct) graftMenu.addAction(self.hgGraftContinueAct) + if self.vcs.version >= (4, 7, 0): + graftMenu.addAction(self.hgGraftStopAct) + graftMenu.addAction(self.hgGraftAbortAct) subrepoMenu = QMenu(self.tr("Sub-Repository"), menu) subrepoMenu.setTearOffEnabled(True) @@ -1910,6 +1939,35 @@ if res: self.project.reopenProject() + def __hgGraftStop(self): + """ + Private slot used to stop an interrupted copying session. + """ + shouldReopen = self.vcs.hgGraftStop(self.project.getProjectPath()) + if shouldReopen: + res = E5MessageBox.yesNo( + None, + self.tr("Copy Changesets (Stop)"), + self.tr("""The project should be reread. Do this now?"""), + yesDefault=True) + if res: + self.project.reopenProject() + + def __hgGraftAbort(self): + """ + Private slot used to abort an interrupted copying session and perform + a rollback. + """ + shouldReopen = self.vcs.hgGraftAbort(self.project.getProjectPath()) + if shouldReopen: + res = E5MessageBox.yesNo( + None, + self.tr("Copy Changesets (Abort)"), + self.tr("""The project should be reread. Do this now?"""), + yesDefault=True) + if res: + self.project.reopenProject() + def __hgAddSubrepository(self): """ Private slot used to add a sub-repository.
--- a/Plugins/VcsPlugins/vcsMercurial/hg.py Sat Aug 04 14:05:07 2018 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/hg.py Sat Aug 04 14:48:27 2018 +0200 @@ -3038,12 +3038,18 @@ self.checkVCSStatus() return res - def hgGraftContinue(self, path): + def __hgGraftSubCommand(self, path, subcommand, title): """ - Public method to continue copying changesets from another branch. - - @param path directory name of the project (string) - @return flag indicating that the project should be reread (boolean) + 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 + @type str + @return flag indicating that the project should be reread + @rtype bool """ # find the root of the repo repodir = self.splitPath(path)[0] @@ -3053,18 +3059,53 @@ return args = self.initCommand("graft") - args.append("--continue") + args.append(subcommand) args.append("--verbose") - dia = HgDialog(self.tr('Copy Changesets (Continue)'), self) + dia = HgDialog(title, self) res = dia.startProcess(args, repodir) if res: dia.exec_() res = dia.hasAddOrDelete() self.checkVCSStatus() return res - # TODO: Mercurial 4.7: add action for graft --stop - # TODO: Mercurial 4.7: add action for graft --abort + + def hgGraftContinue(self, path): + """ + Public method to continue copying changesets from another branch. + + @param path directory name of the project + @type str + @return flag indicating that the project should be reread + @rtype bool + """ + return self.__hgGraftSubCommand( + path, "--continue", self.tr('Copy Changesets (Continue)')) + + def hgGraftStop(self, path): + """ + Public method to stop an interrupted copying session. + + @param path directory name of the project + @type str + @return flag indicating that the project should be reread + @rtype bool + """ + return self.__hgGraftSubCommand( + path, "--stop", self.tr('Copy Changesets (Stop)')) + + def hgGraftAbort(self, path): + """ + Public method to abort an interrupted copying session and perform + a rollback. + + @param path directory name of the project + @type str + @return flag indicating that the project should be reread + @rtype bool + """ + return self.__hgGraftSubCommand( + path, "--abort", self.tr('Copy Changesets (Abort)')) def hgArchive(self): """