|
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 __future__ import unicode_literals |
|
11 |
|
12 from PyQt4.QtGui import QMenu |
|
13 |
|
14 from E5Gui.E5Action import E5Action |
|
15 |
|
16 from ..HgExtensionProjectHelper import HgExtensionProjectHelper |
|
17 |
|
18 import UI.PixmapCache |
|
19 |
|
20 |
|
21 class LargefilesProjectHelper(HgExtensionProjectHelper): |
|
22 """ |
|
23 Class implementing the queues extension project helper. |
|
24 """ |
|
25 def __init__(self): |
|
26 """ |
|
27 Constructor |
|
28 """ |
|
29 super(LargefilesProjectHelper, self).__init__() |
|
30 |
|
31 def initActions(self): |
|
32 """ |
|
33 Public method to generate the action objects. |
|
34 """ |
|
35 self.hgConvertToLargefilesAct = E5Action( |
|
36 self.tr('Convert repository to largefiles'), |
|
37 self.tr('Convert repository to largefiles...'), |
|
38 0, 0, self, 'mercurial_convert_to_largefiles') |
|
39 self.hgConvertToLargefilesAct.setStatusTip(self.tr( |
|
40 'Convert the repository of the project to a largefiles repository.' |
|
41 )) |
|
42 self.hgConvertToLargefilesAct.setWhatsThis(self.tr( |
|
43 """<b>Convert repository to largefiles</b>""" |
|
44 """<p>This converts the repository of the project to a""" |
|
45 """ largefiles repository. A new project is created. The""" |
|
46 """ current one is kept as a backup.</p>""" |
|
47 )) |
|
48 self.hgConvertToLargefilesAct.triggered.connect( |
|
49 lambda: self.__hgLfconvert("largefiles")) |
|
50 self.actions.append(self.hgConvertToLargefilesAct) |
|
51 |
|
52 self.hgConvertToNormalAct = E5Action( |
|
53 self.tr('Convert repository to normal'), |
|
54 self.tr('Convert repository to normal...'), |
|
55 0, 0, self, 'mercurial_convert_to_normal') |
|
56 self.hgConvertToNormalAct.setStatusTip(self.tr( |
|
57 'Convert the repository of the project to a normal repository.' |
|
58 )) |
|
59 self.hgConvertToNormalAct.setWhatsThis(self.tr( |
|
60 """<b>Convert repository to normal</b>""" |
|
61 """<p>This converts the repository of the project to a""" |
|
62 """ normal repository. A new project is created. The current""" |
|
63 """ one is kept as a backup.</p>""" |
|
64 )) |
|
65 self.hgConvertToNormalAct.triggered.connect( |
|
66 lambda: self.__hgLfconvert("normal")) |
|
67 self.actions.append(self.hgConvertToNormalAct) |
|
68 |
|
69 self.hgLfPullAct = E5Action( |
|
70 self.tr('Pull Large Files'), |
|
71 UI.PixmapCache.getIcon("vcsUpdate.png"), |
|
72 self.tr('Pull Large Files'), |
|
73 0, 0, self, 'mercurial_pull_largefiles') |
|
74 self.hgLfPullAct.setStatusTip(self.tr( |
|
75 'Pull large files from a remote repository' |
|
76 )) |
|
77 self.hgLfPullAct.setWhatsThis(self.tr( |
|
78 """<b>Pull Large Files</b>""" |
|
79 """<p>This pulls missing large files from a remote repository""" |
|
80 """ into the local repository.</p>""" |
|
81 )) |
|
82 self.hgLfPullAct.triggered.connect(self.__hgLfPull) |
|
83 self.actions.append(self.hgLfPullAct) |
|
84 |
|
85 self.hgLfSummaryAct = E5Action( |
|
86 self.tr('Show Summary'), |
|
87 UI.PixmapCache.getIcon("vcsSummary.png"), |
|
88 self.tr('Show summary...'), |
|
89 0, 0, self, 'mercurial_summary_largefiles') |
|
90 self.hgLfSummaryAct.setStatusTip(self.tr( |
|
91 'Show summary information of the working directory status' |
|
92 )) |
|
93 self.hgLfSummaryAct.setWhatsThis(self.tr( |
|
94 """<b>Show summary</b>""" |
|
95 """<p>This shows some summary information of the working""" |
|
96 """ directory status.</p>""" |
|
97 )) |
|
98 self.hgLfSummaryAct.triggered.connect(self.__hgLfSummary) |
|
99 self.actions.append(self.hgLfSummaryAct) |
|
100 |
|
101 self.hgVerifyLargeAct = E5Action( |
|
102 self.tr('Verify large files of current revision'), |
|
103 self.tr('Verify large files of current revision...'), |
|
104 0, 0, self, 'mercurial_verify_large') |
|
105 self.hgVerifyLargeAct.setStatusTip(self.tr( |
|
106 'Verify that all large files in the current revision exist' |
|
107 )) |
|
108 self.hgVerifyLargeAct.setWhatsThis(self.tr( |
|
109 """<b>Verify large files of current revision</b>""" |
|
110 """<p>This verifies that all large files in the current""" |
|
111 """ revision exist.</p>""" |
|
112 )) |
|
113 self.hgVerifyLargeAct.triggered.connect( |
|
114 lambda: self.__hgLfVerify("large")) |
|
115 self.actions.append(self.hgVerifyLargeAct) |
|
116 |
|
117 self.hgVerifyLfaAct = E5Action( |
|
118 self.tr('Verify large files of all revision'), |
|
119 self.tr('Verify large files of all revision...'), |
|
120 0, 0, self, 'mercurial_verify_lfa') |
|
121 self.hgVerifyLfaAct.setStatusTip(self.tr( |
|
122 'Verify that all large files in all revisions exist' |
|
123 )) |
|
124 self.hgVerifyLfaAct.setWhatsThis(self.tr( |
|
125 """<b>Verify large files of all revision</b>""" |
|
126 """<p>This verifies that all large files in all""" |
|
127 """ revisions exist.</p>""" |
|
128 )) |
|
129 self.hgVerifyLfaAct.triggered.connect( |
|
130 lambda: self.__hgLfVerify("lfa")) |
|
131 self.actions.append(self.hgVerifyLfaAct) |
|
132 |
|
133 self.hgVerifyLfcAct = E5Action( |
|
134 self.tr('Verify large files contents'), |
|
135 self.tr('Verify large files contents...'), |
|
136 0, 0, self, 'mercurial_verify_lfc') |
|
137 self.hgVerifyLfcAct.setStatusTip(self.tr( |
|
138 'Verify the contents of all large files' |
|
139 )) |
|
140 self.hgVerifyLfcAct.setWhatsThis(self.tr( |
|
141 """<b>Verify large files contents</b>""" |
|
142 """<p>This verifies the contents of all large files.</p>""" |
|
143 )) |
|
144 self.hgVerifyLfcAct.triggered.connect( |
|
145 lambda: self.__hgLfVerify("lfc")) |
|
146 self.actions.append(self.hgVerifyLfcAct) |
|
147 |
|
148 def initMenu(self, mainMenu): |
|
149 """ |
|
150 Public method to generate the extension menu. |
|
151 |
|
152 @param mainMenu reference to the main menu (QMenu) |
|
153 @return populated menu (QMenu) |
|
154 """ |
|
155 menu = QMenu(self.menuTitle(), mainMenu) |
|
156 menu.setTearOffEnabled(True) |
|
157 |
|
158 self.__adminMenu = QMenu(self.tr("Administration"), menu) |
|
159 self.__adminMenu.setTearOffEnabled(True) |
|
160 self.__adminMenu.addAction(self.hgVerifyLargeAct) |
|
161 self.__adminMenu.addAction(self.hgVerifyLfaAct) |
|
162 self.__adminMenu.addAction(self.hgVerifyLfcAct) |
|
163 |
|
164 menu.addAction(self.hgConvertToLargefilesAct) |
|
165 menu.addAction(self.hgConvertToNormalAct) |
|
166 menu.addSeparator() |
|
167 menu.addAction(self.hgLfPullAct) |
|
168 menu.addSeparator() |
|
169 menu.addAction(self.hgLfSummaryAct) |
|
170 menu.addSeparator() |
|
171 menu.addMenu(self.__adminMenu) |
|
172 |
|
173 return menu |
|
174 |
|
175 def menuTitle(self): |
|
176 """ |
|
177 Public method to get the menu title. |
|
178 |
|
179 @return title of the menu (string) |
|
180 """ |
|
181 return self.tr("Large Files") |
|
182 |
|
183 def shutdown(self): |
|
184 """ |
|
185 Public method to perform shutdown actions. |
|
186 |
|
187 Note: Derived class may implement this method if needed. |
|
188 """ |
|
189 if self.__adminMenu.isTearOffMenuVisible(): |
|
190 self.__adminMenu.hideTearOffMenu() |
|
191 |
|
192 def __hgLfconvert(self, direction): |
|
193 """ |
|
194 Private slot to convert the repository format of the current project. |
|
195 |
|
196 @param direction direction of the conversion (string; one of |
|
197 'largefiles' or 'normal') |
|
198 """ |
|
199 assert direction in ["largefiles", "normal"] |
|
200 |
|
201 self.vcs.getExtensionObject("largefiles").hgLfconvert( |
|
202 direction, self.project.getProjectFile()) |
|
203 |
|
204 def __hgLfPull(self): |
|
205 """ |
|
206 Private slot to pull missing large files into the local repository. |
|
207 """ |
|
208 self.vcs.getExtensionObject("largefiles").hgLfPull( |
|
209 self.project.getProjectPath()) |
|
210 |
|
211 def __hgLfSummary(self): |
|
212 """ |
|
213 Private slot to show a working directory summary. |
|
214 """ |
|
215 self.vcs.hgSummary(largefiles=True) |
|
216 |
|
217 def __hgLfVerify(self, mode): |
|
218 """ |
|
219 Private slot to verify large files integrity. |
|
220 |
|
221 @param mode verify mode (string; one of 'large', 'lfa' or 'lfc') |
|
222 """ |
|
223 assert mode in ['large', 'lfa', 'lfc'] |
|
224 |
|
225 self.vcs.getExtensionObject("largefiles").hgLfVerify( |
|
226 self.project.getProjectPath(), mode) |