eric7/Plugins/VcsPlugins/vcsMercurial/StripExtension/ProjectHelper.py

branch
eric7
changeset 8312
800c432b34c8
parent 8218
7c09585bd960
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2016 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the strip extension project helper.
8 """
9
10 from PyQt5.QtWidgets import QMenu
11
12 from E5Gui.E5Action import E5Action
13 from E5Gui import E5MessageBox
14
15 from ..HgExtensionProjectHelper import HgExtensionProjectHelper
16
17 import UI.PixmapCache
18
19
20 class StripProjectHelper(HgExtensionProjectHelper):
21 """
22 Class implementing the strip extension project helper.
23 """
24 def __init__(self):
25 """
26 Constructor
27 """
28 super().__init__()
29
30 def initActions(self):
31 """
32 Public method to generate the action objects.
33 """
34 self.hgStripAct = E5Action(
35 self.tr('Strip changesets'),
36 UI.PixmapCache.getIcon("fileDelete"),
37 self.tr('Strip changesets'),
38 0, 0, self, 'mercurial_strip')
39 self.hgStripAct.setStatusTip(self.tr(
40 'Strip changesets from a repository'
41 ))
42 self.hgStripAct.setWhatsThis(self.tr(
43 """<b>Strip changesets</b>"""
44 """<p>This deletes a changeset and all its descendants"""
45 """ from a repository. Each removed changeset will be"""
46 """ stored in .hg/strip-backup as a bundle file.</p>"""
47 ))
48 self.hgStripAct.triggered.connect(self.__hgStrip)
49 self.actions.append(self.hgStripAct)
50
51 def initMenu(self, mainMenu):
52 """
53 Public method to generate the extension menu.
54
55 @param mainMenu reference to the main menu
56 @type QMenu
57 @return populated menu (QMenu)
58 """
59 menu = QMenu(self.menuTitle(), mainMenu)
60 menu.setIcon(UI.PixmapCache.getIcon("fileDelete"))
61 menu.setTearOffEnabled(True)
62
63 menu.addAction(self.hgStripAct)
64
65 return menu
66
67 def menuTitle(self):
68 """
69 Public method to get the menu title.
70
71 @return title of the menu
72 @rtype str
73 """
74 return self.tr("Strip")
75
76 def __hgStrip(self):
77 """
78 Private slot used to strip revisions from a repository.
79 """
80 shouldReopen = self.vcs.getExtensionObject("strip").hgStrip(
81 self.project.getProjectPath())
82 if shouldReopen:
83 res = E5MessageBox.yesNo(
84 None,
85 self.tr("Strip"),
86 self.tr("""The project should be reread. Do this now?"""),
87 yesDefault=True)
88 if res:
89 self.project.reopenProject()

eric ide

mercurial