Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesDefineGuardsDialog.py

changeset 1047
b41a36b201e4
parent 1046
5dd14be5d6a1
child 1053
c54aa980ea8e
equal deleted inserted replaced
1046:5dd14be5d6a1 1047:b41a36b201e4
22 22
23 class HgQueuesDefineGuardsDialog(QDialog, Ui_HgQueuesDefineGuardsDialog): 23 class HgQueuesDefineGuardsDialog(QDialog, Ui_HgQueuesDefineGuardsDialog):
24 """ 24 """
25 Class implementing a dialog to define guards for patches. 25 Class implementing a dialog to define guards for patches.
26 """ 26 """
27 def __init__(self, vcs, patchesList, parent=None): 27 def __init__(self, vcs, extension, patchesList, parent=None):
28 """ 28 """
29 Constructor 29 Constructor
30 30
31 @param vcs reference to the vcs object 31 @param vcs reference to the vcs object
32 @param extension reference to the extension module (Queues)
32 @param patchesList list of patches (list of strings) 33 @param patchesList list of patches (list of strings)
33 @param parent reference to the parent widget (QWidget) 34 @param parent reference to the parent widget (QWidget)
34 """ 35 """
35 QDialog.__init__(self, parent) 36 QDialog.__init__(self, parent)
36 self.setupUi(self) 37 self.setupUi(self)
37 38
38 self.process = QProcess() 39 self.process = QProcess()
39 self.vcs = vcs 40 self.vcs = vcs
41 self.extension = extension
40 42
41 self.__patches = patchesList[:] 43 self.__patches = patchesList[:]
42 self.patchSelector.addItems([""] + self.__patches) 44 self.patchSelector.addItems([""] + self.__patches)
43 45
44 self.plusButton.setIcon(UI.PixmapCache.getIcon("plus.png")) 46 self.plusButton.setIcon(UI.PixmapCache.getIcon("plus.png"))
91 return 93 return
92 94
93 self.__repodir = repodir 95 self.__repodir = repodir
94 self.on_patchSelector_activated("") 96 self.on_patchSelector_activated("")
95 97
96 def __getGuards(self):
97 """
98 Private method to get a list of all guards defined.
99
100 @return list of guards (list of strings)
101 """
102 guardsList = []
103
104 ioEncoding = Preferences.getSystem("IOEncoding")
105 process = QProcess()
106 args = []
107 args.append("qselect")
108 args.append("--series")
109
110 process.setWorkingDirectory(self.__repodir)
111 process.start('hg', args)
112 procStarted = process.waitForStarted()
113 if procStarted:
114 finished = process.waitForFinished(30000)
115 if finished and process.exitCode() == 0:
116 output = \
117 str(process.readAllStandardOutput(), ioEncoding, 'replace')
118 for guard in output.splitlines():
119 guard = guard.strip()[1:]
120 if guard not in guardsList:
121 guardsList.append(guard)
122
123 return sorted(guardsList)
124
125 @pyqtSlot(str) 98 @pyqtSlot(str)
126 def on_patchSelector_activated(self, patch): 99 def on_patchSelector_activated(self, patch):
127 """ 100 """
128 Private slot to get the list of guards defined for the given patch name. 101 Private slot to get the list of guards defined for the given patch name.
129 102
145 118
146 self.guardsList.clear() 119 self.guardsList.clear()
147 self.patchNameLabel.setText("") 120 self.patchNameLabel.setText("")
148 121
149 self.guardCombo.clear() 122 self.guardCombo.clear()
150 guardsList = self.__getGuards() 123 guardsList = self.extension.getGuardsList(self.__repodir)
151 self.guardCombo.addItems(guardsList) 124 self.guardCombo.addItems(guardsList)
152 self.guardCombo.setEditText("") 125 self.guardCombo.setEditText("")
153 126
154 ioEncoding = Preferences.getSystem("IOEncoding") 127 ioEncoding = Preferences.getSystem("IOEncoding")
155 process = QProcess() 128 process = QProcess()

eric ide

mercurial