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

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
diff -r 3fc8dfeb6ebe -r b99e7fd55fd3 src/eric7/Plugins/VcsPlugins/vcsMercurial/StripExtension/ProjectHelper.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/eric7/Plugins/VcsPlugins/vcsMercurial/StripExtension/ProjectHelper.py	Thu Jul 07 11:23:56 2022 +0200
@@ -0,0 +1,89 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2016 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing the strip extension project helper.
+"""
+
+from PyQt6.QtWidgets import QMenu
+
+from EricGui.EricAction import EricAction
+from EricWidgets import EricMessageBox
+
+from ..HgExtensionProjectHelper import HgExtensionProjectHelper
+
+import UI.PixmapCache
+
+
+class StripProjectHelper(HgExtensionProjectHelper):
+    """
+    Class implementing the strip extension project helper.
+    """
+    def __init__(self):
+        """
+        Constructor
+        """
+        super().__init__()
+    
+    def initActions(self):
+        """
+        Public method to generate the action objects.
+        """
+        self.hgStripAct = EricAction(
+            self.tr('Strip changesets'),
+            UI.PixmapCache.getIcon("fileDelete"),
+            self.tr('Strip changesets'),
+            0, 0, self, 'mercurial_strip')
+        self.hgStripAct.setStatusTip(self.tr(
+            'Strip changesets from a repository'
+        ))
+        self.hgStripAct.setWhatsThis(self.tr(
+            """<b>Strip changesets</b>"""
+            """<p>This deletes a changeset and all its descendants"""
+            """ from a repository. Each removed changeset will be"""
+            """ stored in .hg/strip-backup as a bundle file.</p>"""
+        ))
+        self.hgStripAct.triggered.connect(self.__hgStrip)
+        self.actions.append(self.hgStripAct)
+    
+    def initMenu(self, mainMenu):
+        """
+        Public method to generate the extension menu.
+        
+        @param mainMenu reference to the main menu
+        @type QMenu
+        @return populated menu (QMenu)
+        """
+        menu = QMenu(self.menuTitle(), mainMenu)
+        menu.setIcon(UI.PixmapCache.getIcon("fileDelete"))
+        menu.setTearOffEnabled(True)
+        
+        menu.addAction(self.hgStripAct)
+        
+        return menu
+    
+    def menuTitle(self):
+        """
+        Public method to get the menu title.
+        
+        @return title of the menu
+        @rtype str
+        """
+        return self.tr("Strip")
+    
+    def __hgStrip(self):
+        """
+        Private slot used to strip revisions from a repository.
+        """
+        shouldReopen = self.vcs.getExtensionObject("strip").hgStrip(
+            self.project.getProjectPath())
+        if shouldReopen:
+            res = EricMessageBox.yesNo(
+                None,
+                self.tr("Strip"),
+                self.tr("""The project should be reread. Do this now?"""),
+                yesDefault=True)
+            if res:
+                self.project.reopenProject()

eric ide

mercurial