eric7/Plugins/VcsPlugins/vcsMercurial/HgBundleDialog.py

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

eric ide

mercurial