src/eric7/Plugins/VcsPlugins/vcsMercurial/CloseheadExtension/HgCloseHeadSelectionDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
17 17
18 class HgCloseHeadSelectionDialog(QDialog, Ui_HgCloseHeadSelectionDialog): 18 class HgCloseHeadSelectionDialog(QDialog, Ui_HgCloseHeadSelectionDialog):
19 """ 19 """
20 Class implementing a dialog to select the heads to be closed. 20 Class implementing a dialog to select the heads to be closed.
21 """ 21 """
22
22 def __init__(self, vcs, parent=None): 23 def __init__(self, vcs, parent=None):
23 """ 24 """
24 Constructor 25 Constructor
25 26
26 @param vcs reference to the VCS object 27 @param vcs reference to the VCS object
27 @type Hg 28 @type Hg
28 @param parent reference to the parent widget 29 @param parent reference to the parent widget
29 @type QWidget 30 @type QWidget
30 """ 31 """
31 super().__init__(parent) 32 super().__init__(parent)
32 self.setupUi(self) 33 self.setupUi(self)
33 34
34 self.buttonBox.button( 35 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True)
35 QDialogButtonBox.StandardButton.Cancel).setDefault(True) 36 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
36 self.buttonBox.button( 37
37 QDialogButtonBox.StandardButton.Ok).setEnabled(False)
38
39 project = ericApp().getObject("Project") 38 project = ericApp().getObject("Project")
40 pwl, pel = project.getProjectDictionaries() 39 pwl, pel = project.getProjectDictionaries()
41 language = project.getProjectSpellLanguage() 40 language = project.getProjectSpellLanguage()
42 self.logEdit.setLanguageWithPWL(language, pwl or None, pel or None) 41 self.logEdit.setLanguageWithPWL(language, pwl or None, pel or None)
43 42
44 heads = self.__getHeads(vcs) 43 heads = self.__getHeads(vcs)
45 for revision, branch in heads: 44 for revision, branch in heads:
46 QTreeWidgetItem(self.headsList, [revision, branch]) 45 QTreeWidgetItem(self.headsList, [revision, branch])
47 46
48 def __getHeads(self, vcs): 47 def __getHeads(self, vcs):
49 """ 48 """
50 Private method to get the open heads. 49 Private method to get the open heads.
51 50
52 @param vcs reference to the VCS object 51 @param vcs reference to the VCS object
53 @type Hg 52 @type Hg
54 @return list of tuples containing the revision and the corresponding 53 @return list of tuples containing the revision and the corresponding
55 branch name 54 branch name
56 @rtype list of tuples of (str, str) 55 @rtype list of tuples of (str, str)
57 """ 56 """
58 args = vcs.initCommand("heads") 57 args = vcs.initCommand("heads")
59 args.append('--template') 58 args.append("--template")
60 args.append('{node|short}@@@{branches}\n') 59 args.append("{node|short}@@@{branches}\n")
61 60
62 output = "" 61 output = ""
63 client = vcs.getClient() 62 client = vcs.getClient()
64 output, error = client.runcommand(args) 63 output, error = client.runcommand(args)
65 64
66 heads = [] 65 heads = []
67 if output: 66 if output:
68 for line in output.splitlines(): 67 for line in output.splitlines():
69 line = line.strip() 68 line = line.strip()
70 if line: 69 if line:
71 revision, branch = line.split("@@@") 70 revision, branch = line.split("@@@")
72 heads.append((revision, branch)) 71 heads.append((revision, branch))
73 72
74 return heads 73 return heads
75 74
76 @pyqtSlot() 75 @pyqtSlot()
77 def on_headsList_itemSelectionChanged(self): 76 def on_headsList_itemSelectionChanged(self):
78 """ 77 """
79 Private slot handling changes of the selection. 78 Private slot handling changes of the selection.
80 """ 79 """
81 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( 80 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
82 len(self.headsList.selectedItems()) > 0 81 len(self.headsList.selectedItems()) > 0
83 ) 82 )
84 83
85 def getData(self): 84 def getData(self):
86 """ 85 """
87 Public method to retrieve the entered data. 86 Public method to retrieve the entered data.
88 87
89 @return tuple containing a list of selected revisions and the commit 88 @return tuple containing a list of selected revisions and the commit
90 message 89 message
91 @rtype tuple of (list of str, str) 90 @rtype tuple of (list of str, str)
92 """ 91 """
93 revisions = [itm.text(0) for itm in self.headsList.selectedItems()] 92 revisions = [itm.text(0) for itm in self.headsList.selectedItems()]
94 message = self.logEdit.toPlainText().strip() 93 message = self.logEdit.toPlainText().strip()
95 94
96 return revisions, message 95 return revisions, message

eric ide

mercurial