Plugins/VcsPlugins/vcsMercurial/HgRevisionsSelectionDialog.py

changeset 178
dd9f0bca5e2f
child 738
170c7b28ba3f
equal deleted inserted replaced
177:c822ccc4d138 178:dd9f0bca5e2f
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2010 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the revisions for the hg diff command.
8 """
9
10 from PyQt4.QtGui import QDialog
11
12 from .Ui_HgRevisionsSelectionDialog import Ui_HgRevisionsSelectionDialog
13
14 class HgRevisionsSelectionDialog(QDialog, Ui_HgRevisionsSelectionDialog):
15 """
16 Class implementing a dialog to enter the revisions for the hg diff command.
17 """
18 def __init__(self, tagsList, branchesList, parent = None):
19 """
20 Constructor
21
22 @param tagsList list of tags (list of strings)
23 @param branchesList list of branches (list of strings)
24 @param parent parent widget of the dialog (QWidget)
25 """
26 QDialog.__init__(self, parent)
27 self.setupUi(self)
28
29 self.tag1Combo.addItems(list(sorted(tagsList)))
30 self.tag2Combo.addItems(list(sorted(tagsList)))
31 self.branch1Combo.addItems(list(sorted(["default"] + branchesList)))
32 self.branch2Combo.addItems(list(sorted(["default"] + branchesList)))
33
34 def __getRevision(self, no):
35 """
36 Private method to generate the revision.
37
38 @param no revision number to generate (1 or 2)
39 @return revision (string)
40 """
41 if no == 1:
42 numberButton = self.number1Button
43 numberSpinBox = self.number1SpinBox
44 idButton = self.id1Button
45 idEdit = self.id1Edit
46 tagButton = self.tag1Button
47 tagCombo = self.tag1Combo
48 branchButton = self.branch1Button
49 branchCombo = self.branch1Combo
50 tipButton = self.tip1Button
51 prevButton = self.prev1Button
52 else:
53 numberButton = self.number2Button
54 numberSpinBox = self.number2SpinBox
55 idButton = self.id2Button
56 idEdit = self.id2Edit
57 tagButton = self.tag2Button
58 tagCombo = self.tag2Combo
59 branchButton = self.branch2Button
60 branchCombo = self.branch2Combo
61 tipButton = self.tip2Button
62 prevButton = self.prev2Button
63
64 if numberButton.isChecked():
65 return str(numberSpinBox.value())
66 elif idButton.isChecked():
67 return idEdit.text()
68 elif tagButton.isChecked():
69 return tagCombo.currentText()
70 elif branchButton.isChecked():
71 return branchCombo.currentText()
72 elif tipButton.isChecked():
73 return "tip"
74 elif prevButton.isChecked():
75 return "."
76
77 def getRevisions(self):
78 """
79 Public method to get the revisions.
80
81 @return list two strings
82 """
83 rev1 = self.__getRevision(1)
84 rev2 = self.__getRevision(2)
85
86 return [rev1, rev2]

eric ide

mercurial