|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the rebase extension project helper. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtGui import QMenu |
|
11 |
|
12 from E5Gui.E5Action import E5Action |
|
13 from E5Gui import E5MessageBox |
|
14 |
|
15 from ..HgExtensionProjectHelper import HgExtensionProjectHelper |
|
16 |
|
17 import UI.PixmapCache |
|
18 |
|
19 |
|
20 class RebaseProjectHelper(HgExtensionProjectHelper): |
|
21 """ |
|
22 Class implementing the rebase extension project helper. |
|
23 """ |
|
24 def __init__(self): |
|
25 """ |
|
26 Constructor |
|
27 """ |
|
28 super().__init__() |
|
29 |
|
30 def initActions(self): |
|
31 """ |
|
32 Public method to generate the action objects. |
|
33 """ |
|
34 self.hgRebaseAct = E5Action(self.trUtf8('Rebase Changesets'), |
|
35 UI.PixmapCache.getIcon("vcsRebase.png"), |
|
36 self.trUtf8('Rebase Changesets'), |
|
37 0, 0, self, 'mercurial_rebase') |
|
38 self.hgRebaseAct.setStatusTip(self.trUtf8( |
|
39 'Rebase changesets to another branch' |
|
40 )) |
|
41 self.hgRebaseAct.setWhatsThis(self.trUtf8( |
|
42 """<b>Rebase Changesets</b>""" |
|
43 """<p>This rebases changesets to another branch.</p>""" |
|
44 )) |
|
45 self.hgRebaseAct.triggered[()].connect(self.__hgRebase) |
|
46 self.actions.append(self.hgRebaseAct) |
|
47 |
|
48 self.hgRebaseContinueAct = E5Action( |
|
49 self.trUtf8('Continue Rebase Session'), |
|
50 self.trUtf8('Continue Rebase Session'), |
|
51 0, 0, self, 'mercurial_rebase_continue') |
|
52 self.hgRebaseContinueAct.setStatusTip(self.trUtf8( |
|
53 'Continue the last rebase session after repair' |
|
54 )) |
|
55 self.hgRebaseContinueAct.setWhatsThis(self.trUtf8( |
|
56 """<b>Continue Rebase Session</b>""" |
|
57 """<p>This continues the last rebase session after repair.</p>""" |
|
58 )) |
|
59 self.hgRebaseContinueAct.triggered[()].connect(self.__hgRebaseContinue) |
|
60 self.actions.append(self.hgRebaseContinueAct) |
|
61 |
|
62 self.hgRebaseAbortAct = E5Action( |
|
63 self.trUtf8('Abort Rebase Session'), |
|
64 self.trUtf8('Abort Rebase Session'), |
|
65 0, 0, self, 'mercurial_rebase_abort') |
|
66 self.hgRebaseAbortAct.setStatusTip(self.trUtf8( |
|
67 'Abort the last rebase session' |
|
68 )) |
|
69 self.hgRebaseAbortAct.setWhatsThis(self.trUtf8( |
|
70 """<b>Abort Rebase Session</b>""" |
|
71 """<p>This aborts the last rebase session.</p>""" |
|
72 )) |
|
73 self.hgRebaseAbortAct.triggered[()].connect(self.__hgRebaseAbort) |
|
74 self.actions.append(self.hgRebaseAbortAct) |
|
75 |
|
76 def initMenu(self, mainMenu): |
|
77 """ |
|
78 Public method to generate the extension menu. |
|
79 |
|
80 @param mainMenu reference to the main menu (QMenu) |
|
81 @return populated menu (QMenu) |
|
82 """ |
|
83 menu = QMenu(self.menuTitle(), mainMenu) |
|
84 menu.setTearOffEnabled(True) |
|
85 |
|
86 menu.addAction(self.hgRebaseAct) |
|
87 menu.addAction(self.hgRebaseContinueAct) |
|
88 menu.addAction(self.hgRebaseAbortAct) |
|
89 |
|
90 return menu |
|
91 |
|
92 def menuTitle(self): |
|
93 """ |
|
94 Public method to get the menu title. |
|
95 |
|
96 @return title of the menu (string) |
|
97 """ |
|
98 return self.trUtf8("Rebase") |
|
99 |
|
100 def __hgRebase(self): |
|
101 """ |
|
102 Private slot used to rebase changesets to another branch. |
|
103 """ |
|
104 shouldReopen = self.vcs.getExtensionObject("rebase")\ |
|
105 .hgRebase(self.project.getProjectPath()) |
|
106 if shouldReopen: |
|
107 res = E5MessageBox.yesNo(None, |
|
108 self.trUtf8("Rebase Changesets"), |
|
109 self.trUtf8("""The project should be reread. Do this now?"""), |
|
110 yesDefault=True) |
|
111 if res: |
|
112 self.project.reopenProject() |
|
113 |
|
114 def __hgRebaseContinue(self): |
|
115 """ |
|
116 Private slot used to continue the last rebase session after repair. |
|
117 """ |
|
118 shouldReopen = self.vcs.getExtensionObject("rebase")\ |
|
119 .hgRebaseContinue(self.project.getProjectPath()) |
|
120 if shouldReopen: |
|
121 res = E5MessageBox.yesNo(None, |
|
122 self.trUtf8("Rebase Changesets (Continue)"), |
|
123 self.trUtf8("""The project should be reread. Do this now?"""), |
|
124 yesDefault=True) |
|
125 if res: |
|
126 self.project.reopenProject() |
|
127 |
|
128 def __hgRebaseAbort(self): |
|
129 """ |
|
130 Private slot used to abort the last rebase session. |
|
131 """ |
|
132 shouldReopen = self.vcs.getExtensionObject("rebase")\ |
|
133 .hgRebaseAbort(self.project.getProjectPath()) |
|
134 if shouldReopen: |
|
135 res = E5MessageBox.yesNo(None, |
|
136 self.trUtf8("Rebase Changesets (Abort)"), |
|
137 self.trUtf8("""The project should be reread. Do this now?"""), |
|
138 yesDefault=True) |
|
139 if res: |
|
140 self.project.reopenProject() |