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

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2016 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the strip extension project helper.
8 """
9
10 from PyQt6.QtWidgets import QMenu
11
12 from EricGui.EricAction import EricAction
13 from EricWidgets import EricMessageBox
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 = EricAction(
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 = EricMessageBox.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