Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesListDialog.py

changeset 1055
885c8d93e6f9
parent 1039
dc91f24e307d
child 1062
941a53b019c3
equal deleted inserted replaced
1054:6365b1466615 1055:885c8d93e6f9
43 self.patchesList.header().setSortIndicator(0, Qt.AscendingOrder) 43 self.patchesList.header().setSortIndicator(0, Qt.AscendingOrder)
44 44
45 self.process.finished.connect(self.__procFinished) 45 self.process.finished.connect(self.__procFinished)
46 self.process.readyReadStandardOutput.connect(self.__readStdout) 46 self.process.readyReadStandardOutput.connect(self.__readStdout)
47 self.process.readyReadStandardError.connect(self.__readStderr) 47 self.process.readyReadStandardError.connect(self.__readStderr)
48
49 self.__statusDict = {
50 "A": self.trUtf8("applied"),
51 "U": self.trUtf8("not applied"),
52 "G": self.trUtf8("guarded"),
53 "D": self.trUtf8("missing"),
54 }
48 55
49 def closeEvent(self, e): 56 def closeEvent(self, e):
50 """ 57 """
51 Private slot implementing a close event handler. 58 Private slot implementing a close event handler.
52 59
79 repodir = os.path.dirname(repodir) 86 repodir = os.path.dirname(repodir)
80 if repodir == os.sep: 87 if repodir == os.sep:
81 return 88 return
82 89
83 self.__repodir = repodir 90 self.__repodir = repodir
84 self.__patchesCount = 0 91 self.__getSeries()
85 self.__getApplied() 92
86 93 def __getSeries(self, missing=False):
87 def __getApplied(self): 94 """
88 """ 95 Private slot to get the list of applied, unapplied and guarded patches and
89 Private slot to get the list of applied patches. 96 patches missing in the series file.
90 """ 97
91 self.__mode = "qapplied" 98 @param missing flag indicating to get the patches missing in the series file
99 (boolean)
100 """
101 if missing:
102 self.__mode = "missing"
103 else:
104 self.__mode = "qseries"
92 105
93 args = [] 106 args = []
94 args.append('qapplied') 107 args.append('qseries')
95 args.append('--summary') 108 args.append('--summary')
109 args.append('--verbose')
110 if missing:
111 args.append('--missing')
96 112
97 self.process.kill() 113 self.process.kill()
98 self.process.setWorkingDirectory(self.__repodir) 114 self.process.setWorkingDirectory(self.__repodir)
99 115
100 self.process.start('hg', args) 116 self.process.start('hg', args)
110 ).format('hg')) 126 ).format('hg'))
111 else: 127 else:
112 self.inputGroup.setEnabled(True) 128 self.inputGroup.setEnabled(True)
113 self.inputGroup.show() 129 self.inputGroup.show()
114 130
115 def __getUnapplied(self): 131 def __getTop(self):
116 """ 132 """
117 Private slot to get the list of unapplied patches. 133 Private slot to get patch at the top of the stack.
118 """ 134 """
119 self.__mode = "qunapplied" 135 self.__mode = "qtop"
120 136
121 args = [] 137 args = []
122 args.append('qunapplied') 138 args.append('qtop')
123 args.append('--summary')
124 139
125 self.process.kill() 140 self.process.kill()
126 self.process.setWorkingDirectory(self.__repodir) 141 self.process.setWorkingDirectory(self.__repodir)
127 142
128 self.process.start('hg', args) 143 self.process.start('hg', args)
138 ).format('hg')) 153 ).format('hg'))
139 else: 154 else:
140 self.inputGroup.setEnabled(True) 155 self.inputGroup.setEnabled(True)
141 self.inputGroup.show() 156 self.inputGroup.show()
142 157
143 def __getTop(self):
144 """
145 Private slot to get patch at the top of the stack.
146 """
147 self.__mode = "qtop"
148
149 args = []
150 args.append('qtop')
151
152 self.process.kill()
153 self.process.setWorkingDirectory(self.__repodir)
154
155 self.process.start('hg', args)
156 procStarted = self.process.waitForStarted()
157 if not procStarted:
158 self.inputGroup.setEnabled(False)
159 self.inputGroup.hide()
160 E5MessageBox.critical(self,
161 self.trUtf8('Process Generation Error'),
162 self.trUtf8(
163 'The process {0} could not be started. '
164 'Ensure, that it is in the search path.'
165 ).format('hg'))
166 else:
167 self.inputGroup.setEnabled(True)
168 self.inputGroup.show()
169
170 def __finish(self): 158 def __finish(self):
171 """ 159 """
172 Private slot called when the process finished or the user pressed the button. 160 Private slot called when the process finished or the user pressed the button.
173 """ 161 """
174 if self.process is not None and \ 162 if self.process is not None and \
186 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason) 174 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason)
187 175
188 self.process = None 176 self.process = None
189 177
190 if self.patchesList.topLevelItemCount() == 0: 178 if self.patchesList.topLevelItemCount() == 0:
191 # no bookmarks defined 179 # no patches present
192 self.__generateItem(self.trUtf8("no patches found"), "", True) 180 self.__generateItem(self.trUtf8("no patches found"), "", True)
193 self.patchesList.doItemsLayout() 181 self.patchesList.doItemsLayout()
194 self.__resizeColumns() 182 self.__resizeColumns()
195 self.__resort() 183 self.__resort()
196 184
210 Private slot connected to the finished signal. 198 Private slot connected to the finished signal.
211 199
212 @param exitCode exit code of the process (integer) 200 @param exitCode exit code of the process (integer)
213 @param exitStatus exit status of the process (QProcess.ExitStatus) 201 @param exitStatus exit status of the process (QProcess.ExitStatus)
214 """ 202 """
215 if self.__mode == "qapplied": 203 if self.__mode == "qseries":
216 self.__getUnapplied() 204 self.__getSeries(True)
217 elif self.__mode == "qunapplied": 205 elif self.__mode == "missing":
218 self.__getTop() 206 self.__getTop()
219 else: 207 else:
220 self.__finish() 208 self.__finish()
221 209
222 def __resort(self): 210 def __resort(self):
231 Private method to resize the list columns. 219 Private method to resize the list columns.
232 """ 220 """
233 self.patchesList.header().resizeSections(QHeaderView.ResizeToContents) 221 self.patchesList.header().resizeSections(QHeaderView.ResizeToContents)
234 self.patchesList.header().setStretchLastSection(True) 222 self.patchesList.header().setStretchLastSection(True)
235 223
236 def __generateItem(self, name, summary, error=False): 224 def __generateItem(self, index, status, name, summary, error=False):
237 """ 225 """
238 Private method to generate a patch item in the list of patches. 226 Private method to generate a patch item in the list of patches.
239 227
228 @param index index of the patch (integer, -1 for missing)
229 @param status status of the patch (string)
240 @param name name of the patch (string) 230 @param name name of the patch (string)
241 @param summary first line of the patch header (string) 231 @param summary first line of the patch header (string)
242 @param error flag indicating an error entry (boolean) 232 @param error flag indicating an error entry (boolean)
243 """ 233 """
244 if error: 234 if error:
247 name, 237 name,
248 "", 238 "",
249 summary 239 summary
250 ]) 240 ])
251 else: 241 else:
252 self.__patchesCount += 1 242 if index == -1:
243 indexStr = ""
244 else:
245 indexStr = "{0:>7}".format(index)
246 try:
247 statusStr = self.__statusDict[status]
248 except KeyError:
249 statusStr = self.trUtf8("unknown")
253 itm = QTreeWidgetItem(self.patchesList, [ 250 itm = QTreeWidgetItem(self.patchesList, [
254 "{0:>7}".format(self.__patchesCount), 251 indexStr,
255 name, 252 name,
256 self.__mode == "qapplied" and \ 253 statusStr,
257 self.trUtf8("applied") or \
258 self.trUtf8("not applied"),
259 summary 254 summary
260 ]) 255 ])
256 if status == "A":
257 # applied
258 for column in range(itm.columnCount()):
259 itm.setForeground(column, Qt.blue)
260 elif status == "D":
261 # missing
262 for column in range(itm.columnCount()):
263 itm.setForeground(column, Qt.red)
264
261 itm.setTextAlignment(0, Qt.AlignRight) 265 itm.setTextAlignment(0, Qt.AlignRight)
262 itm.setTextAlignment(2, Qt.AlignHCenter) 266 itm.setTextAlignment(2, Qt.AlignHCenter)
263 267
264 def __markTopItem(self, name): 268 def __markTopItem(self, name):
265 """ 269 """
291 if self.__mode == "qtop": 295 if self.__mode == "qtop":
292 self.__markTopItem(s) 296 self.__markTopItem(s)
293 else: 297 else:
294 l = s.split(": ", 1) 298 l = s.split(": ", 1)
295 if len(l) == 1: 299 if len(l) == 1:
296 name, summary = l[0][:-1], "" 300 data, summary = l[0][:-1], ""
297 else: 301 else:
298 name, summary = l[0], l[1] 302 data, summary = l[0], l[1]
299 self.__generateItem(name, summary) 303 l = data.split(None, 2)
304 if len(l) == 2:
305 # missing entry
306 index, status, name = -1, l[0], l[1]
307 elif len(l) == 3:
308 index, status, name = l[:3]
309 else:
310 continue
311 self.__generateItem(index, status, name, summary)
300 312
301 def __readStderr(self): 313 def __readStderr(self):
302 """ 314 """
303 Private slot to handle the readyReadStderr signal. 315 Private slot to handle the readyReadStderr signal.
304 316

eric ide

mercurial