17 |
17 |
18 class GitMergeDialog(QDialog, Ui_GitMergeDialog): |
18 class GitMergeDialog(QDialog, Ui_GitMergeDialog): |
19 """ |
19 """ |
20 Class implementing a dialog to enter the merge data. |
20 Class implementing a dialog to enter the merge data. |
21 """ |
21 """ |
22 def __init__(self, tagsList, branchesList, currentBranch, |
22 |
23 remoteBranchesList, parent=None): |
23 def __init__( |
|
24 self, tagsList, branchesList, currentBranch, remoteBranchesList, parent=None |
|
25 ): |
24 """ |
26 """ |
25 Constructor |
27 Constructor |
26 |
28 |
27 @param tagsList list of tags (list of strings) |
29 @param tagsList list of tags (list of strings) |
28 @param branchesList list of branches (list of strings) |
30 @param branchesList list of branches (list of strings) |
29 @param currentBranch name of the current branch (string) |
31 @param currentBranch name of the current branch (string) |
30 @param remoteBranchesList list of remote branches (list of strings) |
32 @param remoteBranchesList list of remote branches (list of strings) |
31 @param parent reference to the parent widget (QWidget) |
33 @param parent reference to the parent widget (QWidget) |
32 """ |
34 """ |
33 super().__init__(parent) |
35 super().__init__(parent) |
34 self.setupUi(self) |
36 self.setupUi(self) |
35 |
37 |
36 self.buttonBox.button( |
38 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
37 QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
39 |
38 |
|
39 project = ericApp().getObject("Project") |
40 project = ericApp().getObject("Project") |
40 pwl, pel = project.getProjectDictionaries() |
41 pwl, pel = project.getProjectDictionaries() |
41 language = project.getProjectSpellLanguage() |
42 language = project.getProjectSpellLanguage() |
42 self.commitMessageEdit.setLanguageWithPWL( |
43 self.commitMessageEdit.setLanguageWithPWL(language, pwl or None, pel or None) |
43 language, pwl or None, pel or None) |
44 |
44 |
|
45 self.__currentBranch = currentBranch |
45 self.__currentBranch = currentBranch |
46 |
46 |
47 self.tagCombo.addItems(sorted(tagsList)) |
47 self.tagCombo.addItems(sorted(tagsList)) |
48 if currentBranch in branchesList: |
48 if currentBranch in branchesList: |
49 branchesList.remove(currentBranch) |
49 branchesList.remove(currentBranch) |
50 self.branchCombo.addItems(sorted(branchesList)) |
50 self.branchCombo.addItems(sorted(branchesList)) |
51 self.remoteBranchCombo.addItems(sorted(remoteBranchesList)) |
51 self.remoteBranchCombo.addItems(sorted(remoteBranchesList)) |
52 |
52 |
53 msh = self.minimumSizeHint() |
53 msh = self.minimumSizeHint() |
54 self.resize(max(self.width(), msh.width()), msh.height()) |
54 self.resize(max(self.width(), msh.width()), msh.height()) |
55 |
55 |
56 def __updateOK(self): |
56 def __updateOK(self): |
57 """ |
57 """ |
58 Private slot to update the OK button. |
58 Private slot to update the OK button. |
59 """ |
59 """ |
60 enabled = True |
60 enabled = True |
64 enabled = self.tagCombo.currentText() != "" |
64 enabled = self.tagCombo.currentText() != "" |
65 elif self.branchButton.isChecked(): |
65 elif self.branchButton.isChecked(): |
66 enabled = self.branchCombo.currentText() != "" |
66 enabled = self.branchCombo.currentText() != "" |
67 elif self.remoteBranchButton.isChecked(): |
67 elif self.remoteBranchButton.isChecked(): |
68 enabled = self.remoteBranchCombo.currentText() != "" |
68 enabled = self.remoteBranchCombo.currentText() != "" |
69 |
69 |
70 enabled &= (self.commitGroupBox.isChecked() and |
70 enabled &= ( |
71 self.commitMessageEdit.toPlainText() != "") |
71 self.commitGroupBox.isChecked() |
72 |
72 and self.commitMessageEdit.toPlainText() != "" |
73 self.buttonBox.button( |
73 ) |
74 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) |
74 |
75 |
75 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) |
|
76 |
76 def __generateDefaultCommitMessage(self): |
77 def __generateDefaultCommitMessage(self): |
77 """ |
78 """ |
78 Private slot to generate a default commit message based on the |
79 Private slot to generate a default commit message based on the |
79 data entered. |
80 data entered. |
80 """ |
81 """ |
81 if self.commitGroupBox.isChecked(): |
82 if self.commitGroupBox.isChecked(): |
82 if self.idButton.isChecked(): |
83 if self.idButton.isChecked(): |
83 msg = "Merged commit {0} into {1}.".format( |
84 msg = "Merged commit {0} into {1}.".format( |
84 self.idEdit.text(), self.__currentBranch) |
85 self.idEdit.text(), self.__currentBranch |
|
86 ) |
85 elif self.tagButton.isChecked(): |
87 elif self.tagButton.isChecked(): |
86 msg = "Merged tag {0} into {1}.".format( |
88 msg = "Merged tag {0} into {1}.".format( |
87 self.tagCombo.currentText(), self.__currentBranch) |
89 self.tagCombo.currentText(), self.__currentBranch |
|
90 ) |
88 elif self.branchButton.isChecked(): |
91 elif self.branchButton.isChecked(): |
89 msg = "Merged branch {0} into {1}.".format( |
92 msg = "Merged branch {0} into {1}.".format( |
90 self.branchCombo.currentText(), self.__currentBranch) |
93 self.branchCombo.currentText(), self.__currentBranch |
|
94 ) |
91 elif self.remoteBranchButton.isChecked(): |
95 elif self.remoteBranchButton.isChecked(): |
92 msg = "Merged remote branch {0} into {1}.".format( |
96 msg = "Merged remote branch {0} into {1}.".format( |
93 self.remoteBranchCombo.currentText(), self.__currentBranch) |
97 self.remoteBranchCombo.currentText(), self.__currentBranch |
|
98 ) |
94 else: |
99 else: |
95 msg = "Merged into {0}.".format(self.__currentBranch) |
100 msg = "Merged into {0}.".format(self.__currentBranch) |
96 self.commitMessageEdit.setPlainText(msg) |
101 self.commitMessageEdit.setPlainText(msg) |
97 else: |
102 else: |
98 self.commitMessageEdit.clear() |
103 self.commitMessageEdit.clear() |
99 |
104 |
100 @pyqtSlot(bool) |
105 @pyqtSlot(bool) |
101 def on_idButton_toggled(self, checked): |
106 def on_idButton_toggled(self, checked): |
102 """ |
107 """ |
103 Private slot to handle changes of the ID select button. |
108 Private slot to handle changes of the ID select button. |
104 |
109 |
105 @param checked state of the button (boolean) |
110 @param checked state of the button (boolean) |
106 """ |
111 """ |
107 self.__generateDefaultCommitMessage() |
112 self.__generateDefaultCommitMessage() |
108 self.__updateOK() |
113 self.__updateOK() |
109 |
114 |
110 @pyqtSlot(bool) |
115 @pyqtSlot(bool) |
111 def on_tagButton_toggled(self, checked): |
116 def on_tagButton_toggled(self, checked): |
112 """ |
117 """ |
113 Private slot to handle changes of the Tag select button. |
118 Private slot to handle changes of the Tag select button. |
114 |
119 |
115 @param checked state of the button (boolean) |
120 @param checked state of the button (boolean) |
116 """ |
121 """ |
117 self.__generateDefaultCommitMessage() |
122 self.__generateDefaultCommitMessage() |
118 self.__updateOK() |
123 self.__updateOK() |
119 |
124 |
120 @pyqtSlot(bool) |
125 @pyqtSlot(bool) |
121 def on_branchButton_toggled(self, checked): |
126 def on_branchButton_toggled(self, checked): |
122 """ |
127 """ |
123 Private slot to handle changes of the Branch select button. |
128 Private slot to handle changes of the Branch select button. |
124 |
129 |
125 @param checked state of the button (boolean) |
130 @param checked state of the button (boolean) |
126 """ |
131 """ |
127 self.__generateDefaultCommitMessage() |
132 self.__generateDefaultCommitMessage() |
128 self.__updateOK() |
133 self.__updateOK() |
129 |
134 |
130 @pyqtSlot(bool) |
135 @pyqtSlot(bool) |
131 def on_remoteBranchButton_toggled(self, checked): |
136 def on_remoteBranchButton_toggled(self, checked): |
132 """ |
137 """ |
133 Private slot to handle changes of the Remote Branch select button. |
138 Private slot to handle changes of the Remote Branch select button. |
134 |
139 |
135 @param checked state of the button (boolean) |
140 @param checked state of the button (boolean) |
136 """ |
141 """ |
137 self.__generateDefaultCommitMessage() |
142 self.__generateDefaultCommitMessage() |
138 self.__updateOK() |
143 self.__updateOK() |
139 |
144 |
140 @pyqtSlot(bool) |
145 @pyqtSlot(bool) |
141 def on_noneButton_toggled(self, checked): |
146 def on_noneButton_toggled(self, checked): |
142 """ |
147 """ |
143 Private slot to handle changes of the None select button. |
148 Private slot to handle changes of the None select button. |
144 |
149 |
145 @param checked state of the button (boolean) |
150 @param checked state of the button (boolean) |
146 """ |
151 """ |
147 self.__generateDefaultCommitMessage() |
152 self.__generateDefaultCommitMessage() |
148 |
153 |
149 @pyqtSlot(str) |
154 @pyqtSlot(str) |
150 def on_idEdit_textChanged(self, txt): |
155 def on_idEdit_textChanged(self, txt): |
151 """ |
156 """ |
152 Private slot to handle changes of the Commit edit. |
157 Private slot to handle changes of the Commit edit. |
153 |
158 |
154 @param txt text of the edit (string) |
159 @param txt text of the edit (string) |
155 """ |
160 """ |
156 self.__generateDefaultCommitMessage() |
161 self.__generateDefaultCommitMessage() |
157 self.__updateOK() |
162 self.__updateOK() |
158 |
163 |
159 @pyqtSlot(str) |
164 @pyqtSlot(str) |
160 def on_tagCombo_editTextChanged(self, txt): |
165 def on_tagCombo_editTextChanged(self, txt): |
161 """ |
166 """ |
162 Private slot to handle changes of the Tag combo. |
167 Private slot to handle changes of the Tag combo. |
163 |
168 |
164 @param txt text of the combo (string) |
169 @param txt text of the combo (string) |
165 """ |
170 """ |
166 self.__generateDefaultCommitMessage() |
171 self.__generateDefaultCommitMessage() |
167 self.__updateOK() |
172 self.__updateOK() |
168 |
173 |
169 @pyqtSlot(str) |
174 @pyqtSlot(str) |
170 def on_branchCombo_editTextChanged(self, txt): |
175 def on_branchCombo_editTextChanged(self, txt): |
171 """ |
176 """ |
172 Private slot to handle changes of the Branch combo. |
177 Private slot to handle changes of the Branch combo. |
173 |
178 |
174 @param txt text of the combo (string) |
179 @param txt text of the combo (string) |
175 """ |
180 """ |
176 self.__generateDefaultCommitMessage() |
181 self.__generateDefaultCommitMessage() |
177 self.__updateOK() |
182 self.__updateOK() |
178 |
183 |
179 @pyqtSlot(str) |
184 @pyqtSlot(str) |
180 def on_remoteBranchCombo_editTextChanged(self, txt): |
185 def on_remoteBranchCombo_editTextChanged(self, txt): |
181 """ |
186 """ |
182 Private slot to handle changes of the Remote Branch combo. |
187 Private slot to handle changes of the Remote Branch combo. |
183 |
188 |
184 @param txt text of the combo (string) |
189 @param txt text of the combo (string) |
185 """ |
190 """ |
186 self.__generateDefaultCommitMessage() |
191 self.__generateDefaultCommitMessage() |
187 self.__updateOK() |
192 self.__updateOK() |
188 |
193 |
189 @pyqtSlot(bool) |
194 @pyqtSlot(bool) |
190 def on_commitGroupBox_toggled(self, checked): |
195 def on_commitGroupBox_toggled(self, checked): |
191 """ |
196 """ |
192 Private slot to handle changes of the Commit select group. |
197 Private slot to handle changes of the Commit select group. |
193 |
198 |
194 @param checked state of the group (boolean) |
199 @param checked state of the group (boolean) |
195 """ |
200 """ |
196 self.__generateDefaultCommitMessage() |
201 self.__generateDefaultCommitMessage() |
197 self.__updateOK() |
202 self.__updateOK() |
198 |
203 |
199 @pyqtSlot() |
204 @pyqtSlot() |
200 def on_commitMessageEdit_textChanged(self): |
205 def on_commitMessageEdit_textChanged(self): |
201 """ |
206 """ |
202 Private slot to handle changes of the commit message edit. |
207 Private slot to handle changes of the commit message edit. |
203 """ |
208 """ |
204 self.__updateOK() |
209 self.__updateOK() |
205 |
210 |
206 def getParameters(self): |
211 def getParameters(self): |
207 """ |
212 """ |
208 Public method to retrieve the merge data. |
213 Public method to retrieve the merge data. |
209 |
214 |
210 @return tuple naming the revision, a flag indicating that the merge |
215 @return tuple naming the revision, a flag indicating that the merge |
211 shall be committed, the commit message, a flag indicating that a |
216 shall be committed, the commit message, a flag indicating that a |
212 log summary shall be appended and a flag indicating to show diff |
217 log summary shall be appended and a flag indicating to show diff |
213 statistics at the end of the merge (string, boolean, string, |
218 statistics at the end of the merge (string, boolean, string, |
214 boolean, boolean) |
219 boolean, boolean) |