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

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
18 18
19 class LargefilesProjectHelper(HgExtensionProjectHelper): 19 class LargefilesProjectHelper(HgExtensionProjectHelper):
20 """ 20 """
21 Class implementing the queues extension project helper. 21 Class implementing the queues extension project helper.
22 """ 22 """
23
23 def __init__(self): 24 def __init__(self):
24 """ 25 """
25 Constructor 26 Constructor
26 """ 27 """
27 super().__init__() 28 super().__init__()
28 29
29 def initActions(self): 30 def initActions(self):
30 """ 31 """
31 Public method to generate the action objects. 32 Public method to generate the action objects.
32 """ 33 """
33 self.hgConvertToLargefilesAct = EricAction( 34 self.hgConvertToLargefilesAct = EricAction(
34 self.tr('Convert repository to largefiles'), 35 self.tr("Convert repository to largefiles"),
35 self.tr('Convert repository to largefiles...'), 36 self.tr("Convert repository to largefiles..."),
36 0, 0, self, 'mercurial_convert_to_largefiles') 37 0,
37 self.hgConvertToLargefilesAct.setStatusTip(self.tr( 38 0,
38 'Convert the repository of the project to a largefiles repository.' 39 self,
39 )) 40 "mercurial_convert_to_largefiles",
40 self.hgConvertToLargefilesAct.setWhatsThis(self.tr( 41 )
41 """<b>Convert repository to largefiles</b>""" 42 self.hgConvertToLargefilesAct.setStatusTip(
42 """<p>This converts the repository of the project to a""" 43 self.tr("Convert the repository of the project to a largefiles repository.")
43 """ largefiles repository. A new project is created. The""" 44 )
44 """ current one is kept as a backup.</p>""" 45 self.hgConvertToLargefilesAct.setWhatsThis(
45 )) 46 self.tr(
47 """<b>Convert repository to largefiles</b>"""
48 """<p>This converts the repository of the project to a"""
49 """ largefiles repository. A new project is created. The"""
50 """ current one is kept as a backup.</p>"""
51 )
52 )
46 self.hgConvertToLargefilesAct.triggered.connect( 53 self.hgConvertToLargefilesAct.triggered.connect(
47 lambda: self.__hgLfconvert("largefiles")) 54 lambda: self.__hgLfconvert("largefiles")
55 )
48 self.actions.append(self.hgConvertToLargefilesAct) 56 self.actions.append(self.hgConvertToLargefilesAct)
49 57
50 self.hgConvertToNormalAct = EricAction( 58 self.hgConvertToNormalAct = EricAction(
51 self.tr('Convert repository to normal'), 59 self.tr("Convert repository to normal"),
52 self.tr('Convert repository to normal...'), 60 self.tr("Convert repository to normal..."),
53 0, 0, self, 'mercurial_convert_to_normal') 61 0,
54 self.hgConvertToNormalAct.setStatusTip(self.tr( 62 0,
55 'Convert the repository of the project to a normal repository.' 63 self,
56 )) 64 "mercurial_convert_to_normal",
57 self.hgConvertToNormalAct.setWhatsThis(self.tr( 65 )
58 """<b>Convert repository to normal</b>""" 66 self.hgConvertToNormalAct.setStatusTip(
59 """<p>This converts the repository of the project to a""" 67 self.tr("Convert the repository of the project to a normal repository.")
60 """ normal repository. A new project is created. The current""" 68 )
61 """ one is kept as a backup.</p>""" 69 self.hgConvertToNormalAct.setWhatsThis(
62 )) 70 self.tr(
71 """<b>Convert repository to normal</b>"""
72 """<p>This converts the repository of the project to a"""
73 """ normal repository. A new project is created. The current"""
74 """ one is kept as a backup.</p>"""
75 )
76 )
63 self.hgConvertToNormalAct.triggered.connect( 77 self.hgConvertToNormalAct.triggered.connect(
64 lambda: self.__hgLfconvert("normal")) 78 lambda: self.__hgLfconvert("normal")
79 )
65 self.actions.append(self.hgConvertToNormalAct) 80 self.actions.append(self.hgConvertToNormalAct)
66 81
67 self.hgLfPullAct = EricAction( 82 self.hgLfPullAct = EricAction(
68 self.tr('Pull Large Files'), 83 self.tr("Pull Large Files"),
69 UI.PixmapCache.getIcon("vcsUpdate"), 84 UI.PixmapCache.getIcon("vcsUpdate"),
70 self.tr('Pull Large Files'), 85 self.tr("Pull Large Files"),
71 0, 0, self, 'mercurial_pull_largefiles') 86 0,
72 self.hgLfPullAct.setStatusTip(self.tr( 87 0,
73 'Pull large files from a remote repository' 88 self,
74 )) 89 "mercurial_pull_largefiles",
75 self.hgLfPullAct.setWhatsThis(self.tr( 90 )
76 """<b>Pull Large Files</b>""" 91 self.hgLfPullAct.setStatusTip(
77 """<p>This pulls missing large files from a remote repository""" 92 self.tr("Pull large files from a remote repository")
78 """ into the local repository.</p>""" 93 )
79 )) 94 self.hgLfPullAct.setWhatsThis(
95 self.tr(
96 """<b>Pull Large Files</b>"""
97 """<p>This pulls missing large files from a remote repository"""
98 """ into the local repository.</p>"""
99 )
100 )
80 self.hgLfPullAct.triggered.connect(self.__hgLfPull) 101 self.hgLfPullAct.triggered.connect(self.__hgLfPull)
81 self.actions.append(self.hgLfPullAct) 102 self.actions.append(self.hgLfPullAct)
82 103
83 self.hgLfSummaryAct = EricAction( 104 self.hgLfSummaryAct = EricAction(
84 self.tr('Show Summary'), 105 self.tr("Show Summary"),
85 UI.PixmapCache.getIcon("vcsSummary"), 106 UI.PixmapCache.getIcon("vcsSummary"),
86 self.tr('Show summary...'), 107 self.tr("Show summary..."),
87 0, 0, self, 'mercurial_summary_largefiles') 108 0,
88 self.hgLfSummaryAct.setStatusTip(self.tr( 109 0,
89 'Show summary information of the working directory status' 110 self,
90 )) 111 "mercurial_summary_largefiles",
91 self.hgLfSummaryAct.setWhatsThis(self.tr( 112 )
92 """<b>Show summary</b>""" 113 self.hgLfSummaryAct.setStatusTip(
93 """<p>This shows some summary information of the working""" 114 self.tr("Show summary information of the working directory status")
94 """ directory status.</p>""" 115 )
95 )) 116 self.hgLfSummaryAct.setWhatsThis(
117 self.tr(
118 """<b>Show summary</b>"""
119 """<p>This shows some summary information of the working"""
120 """ directory status.</p>"""
121 )
122 )
96 self.hgLfSummaryAct.triggered.connect(self.__hgLfSummary) 123 self.hgLfSummaryAct.triggered.connect(self.__hgLfSummary)
97 self.actions.append(self.hgLfSummaryAct) 124 self.actions.append(self.hgLfSummaryAct)
98 125
99 self.hgVerifyLargeAct = EricAction( 126 self.hgVerifyLargeAct = EricAction(
100 self.tr('Verify large files of current revision'), 127 self.tr("Verify large files of current revision"),
101 self.tr('Verify large files of current revision...'), 128 self.tr("Verify large files of current revision..."),
102 0, 0, self, 'mercurial_verify_large') 129 0,
103 self.hgVerifyLargeAct.setStatusTip(self.tr( 130 0,
104 'Verify that all large files in the current revision exist' 131 self,
105 )) 132 "mercurial_verify_large",
106 self.hgVerifyLargeAct.setWhatsThis(self.tr( 133 )
107 """<b>Verify large files of current revision</b>""" 134 self.hgVerifyLargeAct.setStatusTip(
108 """<p>This verifies that all large files in the current""" 135 self.tr("Verify that all large files in the current revision exist")
109 """ revision exist.</p>""" 136 )
110 )) 137 self.hgVerifyLargeAct.setWhatsThis(
111 self.hgVerifyLargeAct.triggered.connect( 138 self.tr(
112 lambda: self.__hgLfVerify("large")) 139 """<b>Verify large files of current revision</b>"""
140 """<p>This verifies that all large files in the current"""
141 """ revision exist.</p>"""
142 )
143 )
144 self.hgVerifyLargeAct.triggered.connect(lambda: self.__hgLfVerify("large"))
113 self.actions.append(self.hgVerifyLargeAct) 145 self.actions.append(self.hgVerifyLargeAct)
114 146
115 self.hgVerifyLfaAct = EricAction( 147 self.hgVerifyLfaAct = EricAction(
116 self.tr('Verify large files of all revision'), 148 self.tr("Verify large files of all revision"),
117 self.tr('Verify large files of all revision...'), 149 self.tr("Verify large files of all revision..."),
118 0, 0, self, 'mercurial_verify_lfa') 150 0,
119 self.hgVerifyLfaAct.setStatusTip(self.tr( 151 0,
120 'Verify that all large files in all revisions exist' 152 self,
121 )) 153 "mercurial_verify_lfa",
122 self.hgVerifyLfaAct.setWhatsThis(self.tr( 154 )
123 """<b>Verify large files of all revision</b>""" 155 self.hgVerifyLfaAct.setStatusTip(
124 """<p>This verifies that all large files in all""" 156 self.tr("Verify that all large files in all revisions exist")
125 """ revisions exist.</p>""" 157 )
126 )) 158 self.hgVerifyLfaAct.setWhatsThis(
127 self.hgVerifyLfaAct.triggered.connect( 159 self.tr(
128 lambda: self.__hgLfVerify("lfa")) 160 """<b>Verify large files of all revision</b>"""
161 """<p>This verifies that all large files in all"""
162 """ revisions exist.</p>"""
163 )
164 )
165 self.hgVerifyLfaAct.triggered.connect(lambda: self.__hgLfVerify("lfa"))
129 self.actions.append(self.hgVerifyLfaAct) 166 self.actions.append(self.hgVerifyLfaAct)
130 167
131 self.hgVerifyLfcAct = EricAction( 168 self.hgVerifyLfcAct = EricAction(
132 self.tr('Verify large files contents'), 169 self.tr("Verify large files contents"),
133 self.tr('Verify large files contents...'), 170 self.tr("Verify large files contents..."),
134 0, 0, self, 'mercurial_verify_lfc') 171 0,
135 self.hgVerifyLfcAct.setStatusTip(self.tr( 172 0,
136 'Verify the contents of all large files' 173 self,
137 )) 174 "mercurial_verify_lfc",
138 self.hgVerifyLfcAct.setWhatsThis(self.tr( 175 )
139 """<b>Verify large files contents</b>""" 176 self.hgVerifyLfcAct.setStatusTip(
140 """<p>This verifies the contents of all large files.</p>""" 177 self.tr("Verify the contents of all large files")
141 )) 178 )
142 self.hgVerifyLfcAct.triggered.connect( 179 self.hgVerifyLfcAct.setWhatsThis(
143 lambda: self.__hgLfVerify("lfc")) 180 self.tr(
181 """<b>Verify large files contents</b>"""
182 """<p>This verifies the contents of all large files.</p>"""
183 )
184 )
185 self.hgVerifyLfcAct.triggered.connect(lambda: self.__hgLfVerify("lfc"))
144 self.actions.append(self.hgVerifyLfcAct) 186 self.actions.append(self.hgVerifyLfcAct)
145 187
146 def initMenu(self, mainMenu): 188 def initMenu(self, mainMenu):
147 """ 189 """
148 Public method to generate the extension menu. 190 Public method to generate the extension menu.
149 191
150 @param mainMenu reference to the main menu (QMenu) 192 @param mainMenu reference to the main menu (QMenu)
151 @return populated menu (QMenu) 193 @return populated menu (QMenu)
152 """ 194 """
153 menu = QMenu(self.menuTitle(), mainMenu) 195 menu = QMenu(self.menuTitle(), mainMenu)
154 menu.setTearOffEnabled(True) 196 menu.setTearOffEnabled(True)
155 197
156 self.__adminMenu = QMenu(self.tr("Administration"), menu) 198 self.__adminMenu = QMenu(self.tr("Administration"), menu)
157 self.__adminMenu.setTearOffEnabled(True) 199 self.__adminMenu.setTearOffEnabled(True)
158 self.__adminMenu.addAction(self.hgVerifyLargeAct) 200 self.__adminMenu.addAction(self.hgVerifyLargeAct)
159 self.__adminMenu.addAction(self.hgVerifyLfaAct) 201 self.__adminMenu.addAction(self.hgVerifyLfaAct)
160 self.__adminMenu.addAction(self.hgVerifyLfcAct) 202 self.__adminMenu.addAction(self.hgVerifyLfcAct)
161 203
162 menu.addAction(self.hgConvertToLargefilesAct) 204 menu.addAction(self.hgConvertToLargefilesAct)
163 menu.addAction(self.hgConvertToNormalAct) 205 menu.addAction(self.hgConvertToNormalAct)
164 menu.addSeparator() 206 menu.addSeparator()
165 menu.addAction(self.hgLfPullAct) 207 menu.addAction(self.hgLfPullAct)
166 menu.addSeparator() 208 menu.addSeparator()
167 menu.addAction(self.hgLfSummaryAct) 209 menu.addAction(self.hgLfSummaryAct)
168 menu.addSeparator() 210 menu.addSeparator()
169 menu.addMenu(self.__adminMenu) 211 menu.addMenu(self.__adminMenu)
170 212
171 return menu 213 return menu
172 214
173 def menuTitle(self): 215 def menuTitle(self):
174 """ 216 """
175 Public method to get the menu title. 217 Public method to get the menu title.
176 218
177 @return title of the menu (string) 219 @return title of the menu (string)
178 """ 220 """
179 return self.tr("Large Files") 221 return self.tr("Large Files")
180 222
181 def shutdown(self): 223 def shutdown(self):
182 """ 224 """
183 Public method to perform shutdown actions. 225 Public method to perform shutdown actions.
184 226
185 Note: Derived class may implement this method if needed. 227 Note: Derived class may implement this method if needed.
186 """ 228 """
187 if self.__adminMenu.isTearOffMenuVisible(): 229 if self.__adminMenu.isTearOffMenuVisible():
188 self.__adminMenu.hideTearOffMenu() 230 self.__adminMenu.hideTearOffMenu()
189 231
190 def __hgLfconvert(self, direction): 232 def __hgLfconvert(self, direction):
191 """ 233 """
192 Private slot to convert the repository format of the current project. 234 Private slot to convert the repository format of the current project.
193 235
194 @param direction direction of the conversion (string; one of 236 @param direction direction of the conversion (string; one of
195 'largefiles' or 'normal') 237 'largefiles' or 'normal')
196 @exception ValueError raised to indicate a bad value for the 238 @exception ValueError raised to indicate a bad value for the
197 'direction' parameter. 239 'direction' parameter.
198 """ 240 """
199 if direction not in ["largefiles", "normal"]: 241 if direction not in ["largefiles", "normal"]:
200 raise ValueError("Bad value for 'direction' parameter.") 242 raise ValueError("Bad value for 'direction' parameter.")
201 243
202 self.vcs.getExtensionObject("largefiles").hgLfconvert( 244 self.vcs.getExtensionObject("largefiles").hgLfconvert(
203 direction, self.project.getProjectFile()) 245 direction, self.project.getProjectFile()
204 246 )
247
205 def __hgLfPull(self): 248 def __hgLfPull(self):
206 """ 249 """
207 Private slot to pull missing large files into the local repository. 250 Private slot to pull missing large files into the local repository.
208 """ 251 """
209 self.vcs.getExtensionObject("largefiles").hgLfPull() 252 self.vcs.getExtensionObject("largefiles").hgLfPull()
210 253
211 def __hgLfSummary(self): 254 def __hgLfSummary(self):
212 """ 255 """
213 Private slot to show a working directory summary. 256 Private slot to show a working directory summary.
214 """ 257 """
215 self.vcs.hgSummary(largefiles=True) 258 self.vcs.hgSummary(largefiles=True)
216 259
217 def __hgLfVerify(self, mode): 260 def __hgLfVerify(self, mode):
218 """ 261 """
219 Private slot to verify large files integrity. 262 Private slot to verify large files integrity.
220 263
221 @param mode verify mode (string; one of 'large', 'lfa' or 'lfc') 264 @param mode verify mode (string; one of 'large', 'lfa' or 'lfc')
222 @exception ValueError raised to indicate a bad value for the 265 @exception ValueError raised to indicate a bad value for the
223 'mode' parameter. 266 'mode' parameter.
224 """ 267 """
225 if mode not in ['large', 'lfa', 'lfc']: 268 if mode not in ["large", "lfa", "lfc"]:
226 raise ValueError("Bad value for 'mode' parameter.") 269 raise ValueError("Bad value for 'mode' parameter.")
227 270
228 self.vcs.getExtensionObject("largefiles").hgLfVerify(mode) 271 self.vcs.getExtensionObject("largefiles").hgLfVerify(mode)

eric ide

mercurial