|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the queues extension project helper. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import QObject |
|
11 from PyQt4.QtGui import QMenu |
|
12 |
|
13 from E5Gui.E5Action import E5Action |
|
14 |
|
15 |
|
16 class QueuesProjectHelper(QObject): |
|
17 """ |
|
18 Class implementing the queues extension project helper. |
|
19 """ |
|
20 def __init__(self): |
|
21 """ |
|
22 Constructor |
|
23 """ |
|
24 QObject.__init__(self) |
|
25 |
|
26 self.actions = [] |
|
27 |
|
28 self.initActions() |
|
29 |
|
30 def setObjects(self, vcsObject, projectObject): |
|
31 """ |
|
32 Public method to set references to the vcs and project objects. |
|
33 |
|
34 @param vcsObject reference to the vcs object |
|
35 @param projectObject reference to the project object |
|
36 """ |
|
37 self.vcs = vcsObject |
|
38 self.project = projectObject |
|
39 |
|
40 def getActions(self): |
|
41 """ |
|
42 Public method to get a list of all actions. |
|
43 |
|
44 @return list of all actions (list of E5Action) |
|
45 """ |
|
46 return self.actions[:] |
|
47 |
|
48 def initActions(self): |
|
49 """ |
|
50 Public method to generate the action objects. |
|
51 """ |
|
52 self.hgQueueNewAct = E5Action(self.trUtf8('New Patch'), |
|
53 self.trUtf8('New Patch...'), |
|
54 0, 0, self, 'mercurial_queues_new') |
|
55 self.hgQueueNewAct.setStatusTip(self.trUtf8( |
|
56 'Create a new patch' |
|
57 )) |
|
58 self.hgQueueNewAct.setWhatsThis(self.trUtf8( |
|
59 """<b>New Patch</b>""" |
|
60 """<p>This creates a new named patch.</p>""" |
|
61 )) |
|
62 self.hgQueueNewAct.triggered[()].connect(self.__hgQueueNewPatch) |
|
63 self.actions.append(self.hgQueueNewAct) |
|
64 |
|
65 self.hgQueueRefreshAct = E5Action(self.trUtf8('Update Current Patch'), |
|
66 self.trUtf8('Update Current Patch'), |
|
67 0, 0, self, 'mercurial_queues_refresh') |
|
68 self.hgQueueRefreshAct.setStatusTip(self.trUtf8( |
|
69 'Update the current patch' |
|
70 )) |
|
71 self.hgQueueRefreshAct.setWhatsThis(self.trUtf8( |
|
72 """<b>Update Current Patch</b>""" |
|
73 """<p>This updates the current patch.</p>""" |
|
74 )) |
|
75 self.hgQueueRefreshAct.triggered[()].connect(self.__hgQueueRefreshPatch) |
|
76 self.actions.append(self.hgQueueRefreshAct) |
|
77 |
|
78 self.hgQueueDiffAct = E5Action(self.trUtf8('Show Current Patch'), |
|
79 self.trUtf8('Show Current Patch...'), |
|
80 0, 0, self, 'mercurial_queues_show') |
|
81 self.hgQueueDiffAct.setStatusTip(self.trUtf8( |
|
82 'Show the contents the current patch' |
|
83 )) |
|
84 self.hgQueueDiffAct.setWhatsThis(self.trUtf8( |
|
85 """<b>Show Current Patch</b>""" |
|
86 """<p>This shows the contents of the current patch including""" |
|
87 """ any changes which have been made in the working directory""" |
|
88 """ since the last refresh.</p>""" |
|
89 )) |
|
90 self.hgQueueDiffAct.triggered[()].connect(self.__hgQueueShowPatch) |
|
91 self.actions.append(self.hgQueueDiffAct) |
|
92 |
|
93 self.hgQueueListAct = E5Action(self.trUtf8('List Patches'), |
|
94 self.trUtf8('List Patches...'), |
|
95 0, 0, self, 'mercurial_queues_list') |
|
96 self.hgQueueListAct.setStatusTip(self.trUtf8( |
|
97 'List applied and unapplied patches' |
|
98 )) |
|
99 self.hgQueueListAct.setWhatsThis(self.trUtf8( |
|
100 """<b>List Patches</b>""" |
|
101 """<p>This list all applied and unapplied patches.</p>""" |
|
102 )) |
|
103 self.hgQueueListAct.triggered[()].connect(self.__hgQueueListPatches) |
|
104 self.actions.append(self.hgQueueListAct) |
|
105 |
|
106 self.hgQueueFinishAct = E5Action(self.trUtf8('Finish Applied Patches'), |
|
107 self.trUtf8('Finish Applied Patches'), |
|
108 0, 0, self, 'mercurial_queues_finish_applied') |
|
109 self.hgQueueFinishAct.setStatusTip(self.trUtf8( |
|
110 'Finish applied patches' |
|
111 )) |
|
112 self.hgQueueFinishAct.setWhatsThis(self.trUtf8( |
|
113 """<b>Finish Applied Patches</b>""" |
|
114 """<p>This finishes the applied patches) by moving them out of""" |
|
115 """ mq control into regular repository history.</p>""" |
|
116 )) |
|
117 self.hgQueueFinishAct.triggered[()].connect(self.__hgQueueFinishAppliedPatches) |
|
118 self.actions.append(self.hgQueueFinishAct) |
|
119 |
|
120 self.__initPushPopActions() |
|
121 self.__initPushPopForceActions() |
|
122 |
|
123 def __initPushPopActions(self): |
|
124 """ |
|
125 Public method to generate the push and pop action objects. |
|
126 """ |
|
127 self.hgQueuePushAct = E5Action(self.trUtf8('Push Next Patch'), |
|
128 self.trUtf8('Push Next Patch'), |
|
129 0, 0, self, 'mercurial_queues_push_next') |
|
130 self.hgQueuePushAct.setStatusTip(self.trUtf8( |
|
131 'Push the next patch onto the stack' |
|
132 )) |
|
133 self.hgQueuePushAct.setWhatsThis(self.trUtf8( |
|
134 """<b>Push Next Patch</b>""" |
|
135 """<p>This pushes the next patch onto the stack of applied patches.</p>""" |
|
136 )) |
|
137 self.hgQueuePushAct.triggered[()].connect(self.__hgQueuePushPatch) |
|
138 self.actions.append(self.hgQueuePushAct) |
|
139 |
|
140 self.hgQueuePushAllAct = E5Action(self.trUtf8('Push All Patches'), |
|
141 self.trUtf8('Push All Patches'), |
|
142 0, 0, self, 'mercurial_queues_push_all') |
|
143 self.hgQueuePushAllAct.setStatusTip(self.trUtf8( |
|
144 'Push all patches onto the stack' |
|
145 )) |
|
146 self.hgQueuePushAllAct.setWhatsThis(self.trUtf8( |
|
147 """<b>Push All Patches</b>""" |
|
148 """<p>This pushes all patches onto the stack of applied patches.</p>""" |
|
149 )) |
|
150 self.hgQueuePushAllAct.triggered[()].connect(self.__hgQueuePushAllPatches) |
|
151 self.actions.append(self.hgQueuePushAllAct) |
|
152 |
|
153 self.hgQueuePushUntilAct = E5Action(self.trUtf8('Push Patches'), |
|
154 self.trUtf8('Push Patches'), |
|
155 0, 0, self, 'mercurial_queues_push_until') |
|
156 self.hgQueuePushUntilAct.setStatusTip(self.trUtf8( |
|
157 'Push patches onto the stack' |
|
158 )) |
|
159 self.hgQueuePushUntilAct.setWhatsThis(self.trUtf8( |
|
160 """<b>Push Patches</b>""" |
|
161 """<p>This pushes patches onto the stack of applied patches until""" |
|
162 """ a named patch is at the top of the stack.</p>""" |
|
163 )) |
|
164 self.hgQueuePushUntilAct.triggered[()].connect(self.__hgQueuePushPatches) |
|
165 self.actions.append(self.hgQueuePushUntilAct) |
|
166 |
|
167 self.hgQueuePopAct = E5Action(self.trUtf8('Pop Current Patch'), |
|
168 self.trUtf8('Pop Current Patch'), |
|
169 0, 0, self, 'mercurial_queues_pop_current') |
|
170 self.hgQueuePopAct.setStatusTip(self.trUtf8( |
|
171 'Pop the current patch off the stack' |
|
172 )) |
|
173 self.hgQueuePopAct.setWhatsThis(self.trUtf8( |
|
174 """<b>Pop Current Patch</b>""" |
|
175 """<p>This pops the current patch off the stack of applied patches.</p>""" |
|
176 )) |
|
177 self.hgQueuePopAct.triggered[()].connect(self.__hgQueuePopPatch) |
|
178 self.actions.append(self.hgQueuePopAct) |
|
179 |
|
180 self.hgQueuePopAllAct = E5Action(self.trUtf8('Pop All Patches'), |
|
181 self.trUtf8('Pop All Patches'), |
|
182 0, 0, self, 'mercurial_queues_pop_all') |
|
183 self.hgQueuePopAllAct.setStatusTip(self.trUtf8( |
|
184 'Pop all patches off the stack' |
|
185 )) |
|
186 self.hgQueuePopAllAct.setWhatsThis(self.trUtf8( |
|
187 """<b>Pop All Patches</b>""" |
|
188 """<p>This pops all patches off the stack of applied patches.</p>""" |
|
189 )) |
|
190 self.hgQueuePopAllAct.triggered[()].connect(self.__hgQueuePopAllPatches) |
|
191 self.actions.append(self.hgQueuePopAllAct) |
|
192 |
|
193 self.hgQueuePopUntilAct = E5Action(self.trUtf8('Pop Patches'), |
|
194 self.trUtf8('Pop Patches'), |
|
195 0, 0, self, 'mercurial_queues_pop_until') |
|
196 self.hgQueuePopUntilAct.setStatusTip(self.trUtf8( |
|
197 'Pop patches off the stack' |
|
198 )) |
|
199 self.hgQueuePopUntilAct.setWhatsThis(self.trUtf8( |
|
200 """<b>Pop Patches</b>""" |
|
201 """<p>This pops patches off the stack of applied patches until a named""" |
|
202 """ patch is at the top of the stack.</p>""" |
|
203 )) |
|
204 self.hgQueuePopUntilAct.triggered[()].connect(self.__hgQueuePopPatches) |
|
205 self.actions.append(self.hgQueuePopUntilAct) |
|
206 |
|
207 def __initPushPopForceActions(self): |
|
208 """ |
|
209 Public method to generate the push and pop (force) action objects. |
|
210 """ |
|
211 self.hgQueuePushForceAct = E5Action(self.trUtf8('Push Next Patch'), |
|
212 self.trUtf8('Push Next Patch'), |
|
213 0, 0, self, 'mercurial_queues_push_next_force') |
|
214 self.hgQueuePushForceAct.setStatusTip(self.trUtf8( |
|
215 'Push the next patch onto the stack on top of local changes' |
|
216 )) |
|
217 self.hgQueuePushForceAct.setWhatsThis(self.trUtf8( |
|
218 """<b>Push Next Patch</b>""" |
|
219 """<p>This pushes the next patch onto the stack of applied patches""" |
|
220 """ on top of local changes.</p>""" |
|
221 )) |
|
222 self.hgQueuePushForceAct.triggered[()].connect(self.__hgQueuePushPatchForced) |
|
223 self.actions.append(self.hgQueuePushForceAct) |
|
224 |
|
225 self.hgQueuePushAllForceAct = E5Action(self.trUtf8('Push All Patches'), |
|
226 self.trUtf8('Push All Patches'), |
|
227 0, 0, self, 'mercurial_queues_push_all_force') |
|
228 self.hgQueuePushAllForceAct.setStatusTip(self.trUtf8( |
|
229 'Push all patches onto the stack on top of local changes' |
|
230 )) |
|
231 self.hgQueuePushAllForceAct.setWhatsThis(self.trUtf8( |
|
232 """<b>Push All Patches</b>""" |
|
233 """<p>This pushes all patches onto the stack of applied patches""" |
|
234 """ on top of local changes.</p>""" |
|
235 )) |
|
236 self.hgQueuePushAllForceAct.triggered[()].connect( |
|
237 self.__hgQueuePushAllPatchesForced) |
|
238 self.actions.append(self.hgQueuePushAllForceAct) |
|
239 |
|
240 self.hgQueuePushUntilForceAct = E5Action(self.trUtf8('Push Patches'), |
|
241 self.trUtf8('Push Patches'), |
|
242 0, 0, self, 'mercurial_queues_push_until_force') |
|
243 self.hgQueuePushUntilForceAct.setStatusTip(self.trUtf8( |
|
244 'Push patches onto the stack on top of local changes' |
|
245 )) |
|
246 self.hgQueuePushUntilForceAct.setWhatsThis(self.trUtf8( |
|
247 """<b>Push Patches</b>""" |
|
248 """<p>This pushes patches onto the stack of applied patches until""" |
|
249 """ a named patch is at the top of the stack on top of local changes.</p>""" |
|
250 )) |
|
251 self.hgQueuePushUntilForceAct.triggered[()].connect( |
|
252 self.__hgQueuePushPatchesForced) |
|
253 self.actions.append(self.hgQueuePushUntilForceAct) |
|
254 |
|
255 self.hgQueuePopForceAct = E5Action(self.trUtf8('Pop Current Patch'), |
|
256 self.trUtf8('Pop Current Patch'), |
|
257 0, 0, self, 'mercurial_queues_pop_current_force') |
|
258 self.hgQueuePopForceAct.setStatusTip(self.trUtf8( |
|
259 'Pop the current patch off the stack forgetting local changes' |
|
260 )) |
|
261 self.hgQueuePopForceAct.setWhatsThis(self.trUtf8( |
|
262 """<b>Pop Current Patch</b>""" |
|
263 """<p>This pops the current patch off the stack of applied patches""" |
|
264 """ forgetting local changes.</p>""" |
|
265 )) |
|
266 self.hgQueuePopForceAct.triggered[()].connect(self.__hgQueuePopPatchForced) |
|
267 self.actions.append(self.hgQueuePopForceAct) |
|
268 |
|
269 self.hgQueuePopAllForceAct = E5Action(self.trUtf8('Pop All Patches'), |
|
270 self.trUtf8('Pop All Patches'), |
|
271 0, 0, self, 'mercurial_queues_pop_all_force') |
|
272 self.hgQueuePopAllForceAct.setStatusTip(self.trUtf8( |
|
273 'Pop all patches off the stack forgetting local changes' |
|
274 )) |
|
275 self.hgQueuePopAllForceAct.setWhatsThis(self.trUtf8( |
|
276 """<b>Pop All Patches</b>""" |
|
277 """<p>This pops all patches off the stack of applied patches""" |
|
278 """ forgetting local changes.</p>""" |
|
279 )) |
|
280 self.hgQueuePopAllForceAct.triggered[()].connect( |
|
281 self.__hgQueuePopAllPatchesForced) |
|
282 self.actions.append(self.hgQueuePopAllForceAct) |
|
283 |
|
284 self.hgQueuePopUntilForceAct = E5Action(self.trUtf8('Pop Patches'), |
|
285 self.trUtf8('Pop Patches'), |
|
286 0, 0, self, 'mercurial_queues_pop_until_force') |
|
287 self.hgQueuePopUntilForceAct.setStatusTip(self.trUtf8( |
|
288 'Pop patches off the stack forgetting local changes' |
|
289 )) |
|
290 self.hgQueuePopUntilForceAct.setWhatsThis(self.trUtf8( |
|
291 """<b>Pop Patches</b>""" |
|
292 """<p>This pops patches off the stack of applied patches until a named""" |
|
293 """ patch is at the top of the stack forgetting local changes.</p>""" |
|
294 )) |
|
295 self.hgQueuePopUntilForceAct.triggered[()].connect(self.__hgQueuePopPatchesForced) |
|
296 self.actions.append(self.hgQueuePopUntilForceAct) |
|
297 |
|
298 def initMenu(self, mainMenu): |
|
299 """ |
|
300 Public method to generate the VCS menu. |
|
301 |
|
302 @param mainMenu reference to the main menu (QMenu) |
|
303 @return populated menu (QMenu) |
|
304 """ |
|
305 menu = QMenu(self.trUtf8("Queues"), mainMenu) |
|
306 |
|
307 pushPopMenu = QMenu(self.trUtf8("Push/Pop"), menu) |
|
308 pushPopMenu.addAction(self.hgQueuePushAct) |
|
309 pushPopMenu.addAction(self.hgQueuePushUntilAct) |
|
310 pushPopMenu.addAction(self.hgQueuePushAllAct) |
|
311 pushPopMenu.addAction(self.hgQueuePopAct) |
|
312 pushPopMenu.addAction(self.hgQueuePopUntilAct) |
|
313 pushPopMenu.addAction(self.hgQueuePopAllAct) |
|
314 |
|
315 pushPopForceMenu = QMenu(self.trUtf8("Push/Pop (force)"), menu) |
|
316 pushPopForceMenu.addAction(self.hgQueuePushForceAct) |
|
317 pushPopForceMenu.addAction(self.hgQueuePushUntilForceAct) |
|
318 pushPopForceMenu.addAction(self.hgQueuePushAllForceAct) |
|
319 pushPopForceMenu.addAction(self.hgQueuePopForceAct) |
|
320 pushPopForceMenu.addAction(self.hgQueuePopUntilForceAct) |
|
321 pushPopForceMenu.addAction(self.hgQueuePopAllForceAct) |
|
322 |
|
323 menu.addAction(self.hgQueueNewAct) |
|
324 menu.addAction(self.hgQueueRefreshAct) |
|
325 menu.addAction(self.hgQueueFinishAct) |
|
326 menu.addSeparator() |
|
327 menu.addAction(self.hgQueueDiffAct) |
|
328 menu.addSeparator() |
|
329 menu.addAction(self.hgQueueListAct) |
|
330 menu.addSeparator() |
|
331 menu.addMenu(pushPopMenu) |
|
332 menu.addMenu(pushPopForceMenu) |
|
333 |
|
334 return menu |
|
335 |
|
336 def __hgQueueNewPatch(self): |
|
337 """ |
|
338 Private slot used to create a new named patch. |
|
339 """ |
|
340 self.vcs.getExtensionObject("mq")\ |
|
341 .hgQueueNewPatch(self.project.getProjectPath()) |
|
342 |
|
343 def __hgQueueRefreshPatch(self): |
|
344 """ |
|
345 Private slot used to refresh the current patch. |
|
346 """ |
|
347 self.vcs.getExtensionObject("mq")\ |
|
348 .hgQueueRefreshPatch(self.project.getProjectPath()) |
|
349 |
|
350 def __hgQueueShowPatch(self): |
|
351 """ |
|
352 Private slot used to show the contents of the current patch. |
|
353 """ |
|
354 self.vcs.getExtensionObject("mq")\ |
|
355 .hgQueueShowPatch(self.project.getProjectPath()) |
|
356 |
|
357 def __hgQueuePushPatch(self): |
|
358 """ |
|
359 Private slot used to push the next patch onto the stack. |
|
360 """ |
|
361 self.vcs.getExtensionObject("mq")\ |
|
362 .hgQueuePushPopPatches(self.project.getProjectPath(), |
|
363 pop=False, all=False, named=False) |
|
364 |
|
365 def __hgQueuePushPatchForced(self): |
|
366 """ |
|
367 Private slot used to push the next patch onto the stack on top |
|
368 of local changes. |
|
369 """ |
|
370 self.vcs.getExtensionObject("mq")\ |
|
371 .hgQueuePushPopPatches(self.project.getProjectPath(), |
|
372 pop=False, all=False, named=False, force=True) |
|
373 |
|
374 def __hgQueuePushAllPatches(self): |
|
375 """ |
|
376 Private slot used to push all patches onto the stack. |
|
377 """ |
|
378 self.vcs.getExtensionObject("mq")\ |
|
379 .hgQueuePushPopPatches(self.project.getProjectPath(), |
|
380 pop=False, all=True, named=False) |
|
381 |
|
382 def __hgQueuePushAllPatchesForced(self): |
|
383 """ |
|
384 Private slot used to push all patches onto the stack on top |
|
385 of local changes. |
|
386 """ |
|
387 self.vcs.getExtensionObject("mq")\ |
|
388 .hgQueuePushPopPatches(self.project.getProjectPath(), |
|
389 pop=False, all=True, named=False, force=True) |
|
390 |
|
391 def __hgQueuePushPatches(self): |
|
392 """ |
|
393 Private slot used to push patches onto the stack until a named |
|
394 one is at the top. |
|
395 """ |
|
396 self.vcs.getExtensionObject("mq")\ |
|
397 .hgQueuePushPopPatches(self.project.getProjectPath(), |
|
398 pop=False, all=False, named=True) |
|
399 |
|
400 def __hgQueuePushPatchesForced(self): |
|
401 """ |
|
402 Private slot used to push patches onto the stack until a named |
|
403 one is at the top on top of local changes. |
|
404 """ |
|
405 self.vcs.getExtensionObject("mq")\ |
|
406 .hgQueuePushPopPatches(self.project.getProjectPath(), |
|
407 pop=False, all=False, named=True, force=True) |
|
408 |
|
409 def __hgQueuePopPatch(self): |
|
410 """ |
|
411 Private slot used to pop the current patch off the stack. |
|
412 """ |
|
413 self.vcs.getExtensionObject("mq")\ |
|
414 .hgQueuePushPopPatches(self.project.getProjectPath(), |
|
415 pop=True, all=False, named=False) |
|
416 |
|
417 def __hgQueuePopPatchForced(self): |
|
418 """ |
|
419 Private slot used to pop the current patch off the stack forgetting |
|
420 any local changes to patched files. |
|
421 """ |
|
422 self.vcs.getExtensionObject("mq")\ |
|
423 .hgQueuePushPopPatches(self.project.getProjectPath(), |
|
424 pop=True, all=False, named=False) |
|
425 |
|
426 def __hgQueuePopAllPatches(self): |
|
427 """ |
|
428 Private slot used to pop all patches off the stack. |
|
429 """ |
|
430 self.vcs.getExtensionObject("mq")\ |
|
431 .hgQueuePushPopPatches(self.project.getProjectPath(), |
|
432 pop=True, all=True, named=False) |
|
433 |
|
434 def __hgQueuePopAllPatchesForced(self): |
|
435 """ |
|
436 Private slot used to pop all patches off the stack forgetting |
|
437 any local changes to patched files. |
|
438 """ |
|
439 self.vcs.getExtensionObject("mq")\ |
|
440 .hgQueuePushPopPatches(self.project.getProjectPath(), |
|
441 pop=True, all=True, named=False, force=True) |
|
442 |
|
443 def __hgQueuePopPatches(self): |
|
444 """ |
|
445 Private slot used to pop patches off the stack until a named |
|
446 one is at the top. |
|
447 """ |
|
448 self.vcs.getExtensionObject("mq")\ |
|
449 .hgQueuePushPopPatches(self.project.getProjectPath(), |
|
450 pop=True, all=False, named=True) |
|
451 |
|
452 def __hgQueuePopPatchesForced(self): |
|
453 """ |
|
454 Private slot used to pop patches off the stack until a named |
|
455 one is at the top forgetting any local changes to patched files. |
|
456 """ |
|
457 self.vcs.getExtensionObject("mq")\ |
|
458 .hgQueuePushPopPatches(self.project.getProjectPath(), |
|
459 pop=True, all=False, named=True) |
|
460 |
|
461 def __hgQueueListPatches(self): |
|
462 """ |
|
463 Private slot used to show a list of applied and unapplied patches. |
|
464 """ |
|
465 self.vcs.getExtensionObject("mq")\ |
|
466 .hgQueueListPatches(self.project.getProjectPath()) |
|
467 |
|
468 def __hgQueueFinishAppliedPatches(self): |
|
469 """ |
|
470 Private slot used to finish all applied patches. |
|
471 """ |
|
472 self.vcs.getExtensionObject("mq")\ |
|
473 .hgQueueFinishAppliedPatches(self.project.getProjectPath()) |