Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/ProjectHelper.py

changeset 3310
a2032ed66aec
child 3315
bd1a25ead18d
equal deleted inserted replaced
3309:b5f782f7d43b 3310:a2032ed66aec
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2014 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the shelve extension project helper.
8 """
9
10 from PyQt4.QtGui import QMenu
11
12 from E5Gui.E5Action import E5Action
13
14 from ..HgExtensionProjectHelper import HgExtensionProjectHelper
15
16
17 class LargefilesProjectHelper(HgExtensionProjectHelper):
18 """
19 Class implementing the queues extension project helper.
20 """
21 def __init__(self):
22 """
23 Constructor
24 """
25 super().__init__()
26
27 def initActions(self):
28 """
29 Public method to generate the action objects.
30 """
31 self.hgConvertToLargefilesAct = E5Action(
32 self.tr('Convert repository to largefiles'),
33 self.tr('Convert repository to largefiles...'),
34 0, 0, self, 'mercurial_convert_to_largefiles')
35 self.hgConvertToLargefilesAct.setStatusTip(self.tr(
36 'Convert the repository of the project to a largefiles repository.'
37 ))
38 self.hgConvertToLargefilesAct.setWhatsThis(self.tr(
39 """<b>Convert repository to largefiles</b>"""
40 """<p>This converts the repository of the project to a"""
41 """ largefiles repository. A new project is created. The"""
42 """ current one is kept as a backup.</p>"""
43 ))
44 self.hgConvertToLargefilesAct.triggered[()].connect(
45 lambda: self.__hgLfconvert("largefiles"))
46 self.actions.append(self.hgConvertToLargefilesAct)
47
48 self.hgConvertToNormalAct = E5Action(
49 self.tr('Convert repository to normal'),
50 self.tr('Convert repository to normal...'),
51 0, 0, self, 'mercurial_convert_to_normal')
52 self.hgConvertToNormalAct.setStatusTip(self.tr(
53 'Convert the repository of the project to a normal repository.'
54 ))
55 self.hgConvertToNormalAct.setWhatsThis(self.tr(
56 """<b>Convert repository to normal</b>"""
57 """<p>This converts the repository of the project to a"""
58 """ normal repository. A new project is created. The current"""
59 """ one is kept as a backup.</p>"""
60 ))
61 self.hgConvertToNormalAct.triggered[()].connect(
62 lambda: self.__hgLfconvert("normal"))
63 self.actions.append(self.hgConvertToNormalAct)
64
65 def initMenu(self, mainMenu):
66 """
67 Public method to generate the extension menu.
68
69 @param mainMenu reference to the main menu (QMenu)
70 @return populated menu (QMenu)
71 """
72 menu = QMenu(self.menuTitle(), mainMenu)
73 menu.setTearOffEnabled(True)
74
75 menu.addAction(self.hgConvertToLargefilesAct)
76 menu.addAction(self.hgConvertToNormalAct)
77
78 return menu
79
80 def menuTitle(self):
81 """
82 Public method to get the menu title.
83
84 @return title of the menu (string)
85 """
86 return self.tr("Large Files")
87
88 def __hgLfconvert(self, direction):
89 """
90 Private slot to convert the repository format of the current project.
91
92 @param direction direction of the conversion (string, one of
93 'largefiles' or 'normal')
94 """
95 assert direction in ["largefiles", "normal"]
96
97 self.vcs.getExtensionObject("largefiles").hgLfconvert(
98 direction, self.project.getProjectFile())

eric ide

mercurial