eric6/Plugins/VcsPlugins/vcsMercurial/HgBundleDialog.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2010 - 2019 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 __future__ import unicode_literals
11
12 from PyQt5.QtCore import pyqtSlot
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
14
15 from .Ui_HgBundleDialog import Ui_HgBundleDialog
16
17
18 class HgBundleDialog(QDialog, Ui_HgBundleDialog):
19 """
20 Class implementing a dialog to enter the data for a bundle operation.
21 """
22 def __init__(self, tagsList, branchesList, bookmarksList=None,
23 version=(0, 0, 0), parent=None):
24 """
25 Constructor
26
27 @param tagsList list of tags
28 @type list of str
29 @param branchesList list of branches
30 @type list of str
31 @param bookmarksList list of bookmarks
32 @type list of str
33 @param version Mercurial version info
34 @type tuple of three integers
35 @param parent parent widget
36 @type QWidget
37 """
38 super(HgBundleDialog, self).__init__(parent)
39 self.setupUi(self)
40
41 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
42
43 self.__version = version
44
45 bundleTypes = ["", "bzip2", "gzip", "none"]
46 if version >= (4, 1, 0):
47 bundleTypes.insert(-1, "zstd")
48 self.compressionCombo.addItems(bundleTypes)
49 self.tagCombo.addItems(sorted(tagsList))
50 self.branchCombo.addItems(["default"] + sorted(branchesList))
51 if bookmarksList is not None:
52 self.bookmarkCombo.addItems(sorted(bookmarksList))
53 else:
54 self.bookmarkButton.setHidden(True)
55 self.bookmarkCombo.setHidden(True)
56
57 def __updateOK(self):
58 """
59 Private slot to update the OK button.
60 """
61 enabled = True
62 if self.multipleButton.isChecked():
63 enabled = self.multipleEdit.toPlainText() != ""
64 elif self.tagButton.isChecked():
65 enabled = self.tagCombo.currentText() != ""
66 elif self.branchButton.isChecked():
67 enabled = self.branchCombo.currentText() != ""
68 elif self.bookmarkButton.isChecked():
69 enabled = self.bookmarkCombo.currentText() != ""
70
71 self.buttonBox.button(QDialogButtonBox.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