eric7/Plugins/VcsPlugins/vcsMercurial/HgBackoutDialog.py

branch
eric7
changeset 8312
800c432b34c8
parent 8259
2bbec88047dd
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2010 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the data for a backout operation.
8 """
9
10 from PyQt5.QtCore import pyqtSlot, QDateTime
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
12
13 from .Ui_HgBackoutDialog import Ui_HgBackoutDialog
14
15
16 class HgBackoutDialog(QDialog, Ui_HgBackoutDialog):
17 """
18 Class implementing a dialog to enter the data for a backout operation.
19 """
20 def __init__(self, tagsList, branchesList, bookmarksList=None,
21 parent=None):
22 """
23 Constructor
24
25 @param tagsList list of tags (list of strings)
26 @param branchesList list of branches (list of strings)
27 @param bookmarksList list of bookmarks (list of strings)
28 @param parent parent widget (QWidget)
29 """
30 super().__init__(parent)
31 self.setupUi(self)
32
33 self.buttonBox.button(
34 QDialogButtonBox.StandardButton.Ok).setEnabled(False)
35
36 self.tagCombo.addItems(sorted(tagsList))
37 self.branchCombo.addItems(["default"] + sorted(branchesList))
38 if bookmarksList is not None:
39 self.bookmarkCombo.addItems(sorted(bookmarksList))
40 else:
41 self.bookmarkButton.setHidden(True)
42 self.bookmarkCombo.setHidden(True)
43
44 self.__initDateTime = QDateTime.currentDateTime()
45 self.dateEdit.setDateTime(self.__initDateTime)
46
47 def __updateOK(self):
48 """
49 Private slot to update the OK button.
50 """
51 enabled = True
52 if self.noneButton.isChecked():
53 enabled = False
54 elif self.idButton.isChecked():
55 enabled = self.idEdit.text() != ""
56 elif self.tagButton.isChecked():
57 enabled = self.tagCombo.currentText() != ""
58 elif self.branchButton.isChecked():
59 enabled = self.branchCombo.currentText() != ""
60 elif self.bookmarkButton.isChecked():
61 enabled = self.bookmarkCombo.currentText() != ""
62
63 self.buttonBox.button(
64 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled)
65
66 @pyqtSlot(bool)
67 def on_idButton_toggled(self, checked):
68 """
69 Private slot to handle changes of the ID select button.
70
71 @param checked state of the button (boolean)
72 """
73 self.__updateOK()
74
75 @pyqtSlot(bool)
76 def on_tagButton_toggled(self, checked):
77 """
78 Private slot to handle changes of the Tag select button.
79
80 @param checked state of the button (boolean)
81 """
82 self.__updateOK()
83
84 @pyqtSlot(bool)
85 def on_branchButton_toggled(self, checked):
86 """
87 Private slot to handle changes of the Branch select button.
88
89 @param checked state of the button (boolean)
90 """
91 self.__updateOK()
92
93 @pyqtSlot(bool)
94 def on_bookmarkButton_toggled(self, checked):
95 """
96 Private slot to handle changes of the Bookmark select button.
97
98 @param checked state of the button (boolean)
99 """
100 self.__updateOK()
101
102 @pyqtSlot(bool)
103 def on_noneButton_toggled(self, checked):
104 """
105 Private slot to handle the toggling of the None revision button.
106
107 @param checked flag indicating the checked state (boolean)
108 """
109 self.__updateOK()
110
111 @pyqtSlot(str)
112 def on_idEdit_textChanged(self, txt):
113 """
114 Private slot to handle changes of the ID edit.
115
116 @param txt text of the edit (string)
117 """
118 self.__updateOK()
119
120 @pyqtSlot(str)
121 def on_tagCombo_editTextChanged(self, txt):
122 """
123 Private slot to handle changes of the Tag combo.
124
125 @param txt text of the combo (string)
126 """
127 self.__updateOK()
128
129 @pyqtSlot(str)
130 def on_branchCombo_editTextChanged(self, txt):
131 """
132 Private slot to handle changes of the Branch combo.
133
134 @param txt text of the combo (string)
135 """
136 self.__updateOK()
137
138 @pyqtSlot(str)
139 def on_bookmarkCombo_editTextChanged(self, txt):
140 """
141 Private slot to handle changes of the Bookmark combo.
142
143 @param txt text of the combo (string)
144 """
145 self.__updateOK()
146
147 def getParameters(self):
148 """
149 Public method to retrieve the backout data.
150
151 @return tuple naming the revision, a flag indicating a
152 merge, the commit date, the commit user and a commit message
153 (string, boolean, string, string, string)
154 """
155 if self.numberButton.isChecked():
156 rev = "rev({0})".format(self.numberSpinBox.value())
157 elif self.idButton.isChecked():
158 rev = "id({0})".format(self.idEdit.text())
159 elif self.tagButton.isChecked():
160 rev = self.tagCombo.currentText()
161 elif self.branchButton.isChecked():
162 rev = self.branchCombo.currentText()
163 elif self.bookmarkButton.isChecked():
164 rev = self.bookmarkCombo.currentText()
165 else:
166 rev = ""
167
168 date = (
169 self.dateEdit.dateTime().toString("yyyy-MM-dd hh:mm")
170 if self.dateEdit.dateTime() != self.__initDateTime else
171 ""
172 )
173
174 msg = (
175 self.messageEdit.toPlainText()
176 if self.messageEdit.toPlainText() else
177 self.tr("Backed out changeset <{0}>.").format(rev)
178 )
179
180 return (rev,
181 self.mergeCheckBox.isChecked,
182 date,
183 self.userEdit.text(),
184 msg
185 )

eric ide

mercurial