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