src/eric7/Plugins/VcsPlugins/vcsMercurial/HgBundleDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9653
e67609152c5e
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
15 15
16 class HgBundleDialog(QDialog, Ui_HgBundleDialog): 16 class HgBundleDialog(QDialog, Ui_HgBundleDialog):
17 """ 17 """
18 Class implementing a dialog to enter the data for a bundle operation. 18 Class implementing a dialog to enter the data for a bundle operation.
19 """ 19 """
20 def __init__(self, tagsList, branchesList, bookmarksList=None, 20
21 version=(0, 0, 0), parent=None): 21 def __init__(
22 self, tagsList, branchesList, bookmarksList=None, version=(0, 0, 0), parent=None
23 ):
22 """ 24 """
23 Constructor 25 Constructor
24 26
25 @param tagsList list of tags 27 @param tagsList list of tags
26 @type list of str 28 @type list of str
27 @param branchesList list of branches 29 @param branchesList list of branches
28 @type list of str 30 @type list of str
29 @param bookmarksList list of bookmarks 31 @param bookmarksList list of bookmarks
33 @param parent parent widget 35 @param parent parent widget
34 @type QWidget 36 @type QWidget
35 """ 37 """
36 super().__init__(parent) 38 super().__init__(parent)
37 self.setupUi(self) 39 self.setupUi(self)
38 40
39 self.buttonBox.button( 41 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
40 QDialogButtonBox.StandardButton.Ok).setEnabled(False) 42
41
42 self.__version = version 43 self.__version = version
43 44
44 bundleTypes = ["", "bzip2", "gzip", "none"] 45 bundleTypes = ["", "bzip2", "gzip", "none"]
45 if version >= (4, 1, 0): 46 if version >= (4, 1, 0):
46 bundleTypes.insert(-1, "zstd") 47 bundleTypes.insert(-1, "zstd")
47 self.compressionCombo.addItems(bundleTypes) 48 self.compressionCombo.addItems(bundleTypes)
48 self.tagCombo.addItems(sorted(tagsList)) 49 self.tagCombo.addItems(sorted(tagsList))
50 if bookmarksList is not None: 51 if bookmarksList is not None:
51 self.bookmarkCombo.addItems(sorted(bookmarksList)) 52 self.bookmarkCombo.addItems(sorted(bookmarksList))
52 else: 53 else:
53 self.bookmarkButton.setHidden(True) 54 self.bookmarkButton.setHidden(True)
54 self.bookmarkCombo.setHidden(True) 55 self.bookmarkCombo.setHidden(True)
55 56
56 def __updateOK(self): 57 def __updateOK(self):
57 """ 58 """
58 Private slot to update the OK button. 59 Private slot to update the OK button.
59 """ 60 """
60 enabled = True 61 enabled = True
64 enabled = self.tagCombo.currentText() != "" 65 enabled = self.tagCombo.currentText() != ""
65 elif self.branchButton.isChecked(): 66 elif self.branchButton.isChecked():
66 enabled = self.branchCombo.currentText() != "" 67 enabled = self.branchCombo.currentText() != ""
67 elif self.bookmarkButton.isChecked(): 68 elif self.bookmarkButton.isChecked():
68 enabled = self.bookmarkCombo.currentText() != "" 69 enabled = self.bookmarkCombo.currentText() != ""
69 70
70 self.buttonBox.button( 71 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enabled)
71 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) 72
72
73 @pyqtSlot(bool) 73 @pyqtSlot(bool)
74 def on_multipleButton_toggled(self, checked): 74 def on_multipleButton_toggled(self, checked):
75 """ 75 """
76 Private slot to handle changes of the Multiple select button. 76 Private slot to handle changes of the Multiple select button.
77 77
78 @param checked state of the button (boolean) 78 @param checked state of the button (boolean)
79 """ 79 """
80 self.__updateOK() 80 self.__updateOK()
81 81
82 @pyqtSlot(bool) 82 @pyqtSlot(bool)
83 def on_tagButton_toggled(self, checked): 83 def on_tagButton_toggled(self, checked):
84 """ 84 """
85 Private slot to handle changes of the Tag select button. 85 Private slot to handle changes of the Tag select button.
86 86
87 @param checked state of the button (boolean) 87 @param checked state of the button (boolean)
88 """ 88 """
89 self.__updateOK() 89 self.__updateOK()
90 90
91 @pyqtSlot(bool) 91 @pyqtSlot(bool)
92 def on_branchButton_toggled(self, checked): 92 def on_branchButton_toggled(self, checked):
93 """ 93 """
94 Private slot to handle changes of the Branch select button. 94 Private slot to handle changes of the Branch select button.
95 95
96 @param checked state of the button (boolean) 96 @param checked state of the button (boolean)
97 """ 97 """
98 self.__updateOK() 98 self.__updateOK()
99 99
100 @pyqtSlot(bool) 100 @pyqtSlot(bool)
101 def on_bookmarkButton_toggled(self, checked): 101 def on_bookmarkButton_toggled(self, checked):
102 """ 102 """
103 Private slot to handle changes of the Bookmark select button. 103 Private slot to handle changes of the Bookmark select button.
104 104
105 @param checked state of the button (boolean) 105 @param checked state of the button (boolean)
106 """ 106 """
107 self.__updateOK() 107 self.__updateOK()
108 108
109 @pyqtSlot() 109 @pyqtSlot()
110 def on_multipleEdit_textChanged(self): 110 def on_multipleEdit_textChanged(self):
111 """ 111 """
112 Private slot to handle changes of the Multiple edit. 112 Private slot to handle changes of the Multiple edit.
113 """ 113 """
114 self.__updateOK() 114 self.__updateOK()
115 115
116 @pyqtSlot(str) 116 @pyqtSlot(str)
117 def on_tagCombo_editTextChanged(self, txt): 117 def on_tagCombo_editTextChanged(self, txt):
118 """ 118 """
119 Private slot to handle changes of the Tag combo. 119 Private slot to handle changes of the Tag combo.
120 120
121 @param txt text of the combo (string) 121 @param txt text of the combo (string)
122 """ 122 """
123 self.__updateOK() 123 self.__updateOK()
124 124
125 @pyqtSlot(str) 125 @pyqtSlot(str)
126 def on_branchCombo_editTextChanged(self, txt): 126 def on_branchCombo_editTextChanged(self, txt):
127 """ 127 """
128 Private slot to handle changes of the Branch combo. 128 Private slot to handle changes of the Branch combo.
129 129
130 @param txt text of the combo (string) 130 @param txt text of the combo (string)
131 """ 131 """
132 self.__updateOK() 132 self.__updateOK()
133 133
134 @pyqtSlot(str) 134 @pyqtSlot(str)
135 def on_bookmarkCombo_editTextChanged(self, txt): 135 def on_bookmarkCombo_editTextChanged(self, txt):
136 """ 136 """
137 Private slot to handle changes of the Bookmark combo. 137 Private slot to handle changes of the Bookmark combo.
138 138
139 @param txt text of the combo (string) 139 @param txt text of the combo (string)
140 """ 140 """
141 self.__updateOK() 141 self.__updateOK()
142 142
143 def getParameters(self): 143 def getParameters(self):
144 """ 144 """
145 Public method to retrieve the bundle data. 145 Public method to retrieve the bundle data.
146 146
147 @return tuple naming the revisions, base revisions, the compression 147 @return tuple naming the revisions, base revisions, the compression
148 type and a flag indicating to bundle all changesets (string, 148 type and a flag indicating to bundle all changesets (string,
149 string, boolean) 149 string, boolean)
150 """ 150 """
151 if self.multipleButton.isChecked(): 151 if self.multipleButton.isChecked():
152 revs = [rev.strip() for rev in 152 revs = [
153 self.multipleEdit.toPlainText().strip().splitlines() 153 rev.strip()
154 if rev.strip()] 154 for rev in self.multipleEdit.toPlainText().strip().splitlines()
155 if rev.strip()
156 ]
155 elif self.tagButton.isChecked(): 157 elif self.tagButton.isChecked():
156 revs = [self.tagCombo.currentText()] 158 revs = [self.tagCombo.currentText()]
157 elif self.branchButton.isChecked(): 159 elif self.branchButton.isChecked():
158 revs = [self.branchCombo.currentText()] 160 revs = [self.branchCombo.currentText()]
159 elif self.bookmarkButton.isChecked(): 161 elif self.bookmarkButton.isChecked():
160 revs = [self.bookmarkCombo.currentText()] 162 revs = [self.bookmarkCombo.currentText()]
161 else: 163 else:
162 revs = [] 164 revs = []
163 165
164 baseRevs = [rev.strip() for rev in 166 baseRevs = [
165 self.baseRevisionsEdit.toPlainText().strip().splitlines() 167 rev.strip()
166 if rev.strip()] 168 for rev in self.baseRevisionsEdit.toPlainText().strip().splitlines()
167 169 if rev.strip()
170 ]
171
168 bundleType = self.compressionCombo.currentText() 172 bundleType = self.compressionCombo.currentText()
169 if bundleType == "zstd": 173 if bundleType == "zstd":
170 bundleType += "-v2" 174 bundleType += "-v2"
171 175
172 return (revs, baseRevs, bundleType, self.allCheckBox.isChecked()) 176 return (revs, baseRevs, bundleType, self.allCheckBox.isChecked())

eric ide

mercurial