Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/HgBookmarksInOutDialog.py

changeset 1251
d40491ba96ce
parent 1131
7781e396c903
child 1256
885706dbb69f
equal deleted inserted replaced
1250:dafdd7d97a9f 1251:d40491ba96ce
50 self.setWindowTitle(self.trUtf8("Mercurial Outgoing Bookmarks")) 50 self.setWindowTitle(self.trUtf8("Mercurial Outgoing Bookmarks"))
51 51
52 self.process = QProcess() 52 self.process = QProcess()
53 self.vcs = vcs 53 self.vcs = vcs
54 self.mode = mode 54 self.mode = mode
55 self.__hgClient = vcs.getClient()
55 56
56 self.bookmarksList.headerItem().setText(self.bookmarksList.columnCount(), "") 57 self.bookmarksList.headerItem().setText(self.bookmarksList.columnCount(), "")
57 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder) 58 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder)
58 59
59 self.process.finished.connect(self.__procFinished) 60 self.process.finished.connect(self.__procFinished)
101 args.append('outgoing') 102 args.append('outgoing')
102 else: 103 else:
103 raise ValueError("Bad value for mode") 104 raise ValueError("Bad value for mode")
104 args.append('--bookmarks') 105 args.append('--bookmarks')
105 106
106 self.process.kill() 107 if self.__hgClient:
107 self.process.setWorkingDirectory(repodir)
108
109 self.process.start('hg', args)
110 procStarted = self.process.waitForStarted()
111 if not procStarted:
112 self.inputGroup.setEnabled(False) 108 self.inputGroup.setEnabled(False)
113 self.inputGroup.hide() 109 self.inputGroup.hide()
114 E5MessageBox.critical(self, 110
115 self.trUtf8('Process Generation Error'), 111 out, err = self.__hgClient.runcommand(args)
116 self.trUtf8( 112 if err:
117 'The process {0} could not be started. ' 113 self.__showError(err)
118 'Ensure, that it is in the search path.' 114 if out:
119 ).format('hg')) 115 for line in out.splitlines():
116 self.__processOutputLine(line)
117 self.__finish()
120 else: 118 else:
121 self.inputGroup.setEnabled(True) 119 self.process.kill()
122 self.inputGroup.show() 120 self.process.setWorkingDirectory(repodir)
121
122 self.process.start('hg', args)
123 procStarted = self.process.waitForStarted()
124 if not procStarted:
125 self.inputGroup.setEnabled(False)
126 self.inputGroup.hide()
127 E5MessageBox.critical(self,
128 self.trUtf8('Process Generation Error'),
129 self.trUtf8(
130 'The process {0} could not be started. '
131 'Ensure, that it is in the search path.'
132 ).format('hg'))
133 else:
134 self.inputGroup.setEnabled(True)
135 self.inputGroup.show()
123 136
124 def __finish(self): 137 def __finish(self):
125 """ 138 """
126 Private slot called when the process finished or the user pressed the button. 139 Private slot called when the process finished or the user pressed the button.
127 """ 140 """
155 @param button button that was clicked (QAbstractButton) 168 @param button button that was clicked (QAbstractButton)
156 """ 169 """
157 if button == self.buttonBox.button(QDialogButtonBox.Close): 170 if button == self.buttonBox.button(QDialogButtonBox.Close):
158 self.close() 171 self.close()
159 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): 172 elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
160 self.__finish() 173 if self.__hgClient:
174 self.__hgClient.cancel()
175 else:
176 self.__finish()
161 177
162 def __procFinished(self, exitCode, exitStatus): 178 def __procFinished(self, exitCode, exitStatus):
163 """ 179 """
164 Private slot connected to the finished signal. 180 Private slot connected to the finished signal.
165 181
187 Private method to generate a bookmark item in the bookmarks list. 203 Private method to generate a bookmark item in the bookmarks list.
188 204
189 @param changeset changeset of the bookmark (string) 205 @param changeset changeset of the bookmark (string)
190 @param name name of the bookmark (string) 206 @param name name of the bookmark (string)
191 """ 207 """
192 itm = QTreeWidgetItem(self.bookmarksList, [ 208 QTreeWidgetItem(self.bookmarksList, [
193 name, 209 name,
194 changeset]) 210 changeset])
195 itm.setTextAlignment(1, Qt.AlignRight)
196 211
197 def __readStdout(self): 212 def __readStdout(self):
198 """ 213 """
199 Private slot to handle the readyReadStdout signal. 214 Private slot to handle the readyReadStdout signal.
200 215
205 220
206 while self.process.canReadLine(): 221 while self.process.canReadLine():
207 s = str(self.process.readLine(), 222 s = str(self.process.readLine(),
208 Preferences.getSystem("IOEncoding"), 223 Preferences.getSystem("IOEncoding"),
209 'replace') 224 'replace')
210 if s.startswith(" "): 225 self.__processOutputLine(s)
211 l = s.strip().split() 226
212 changeset = l[-1] 227 def __processOutputLine(self, line):
213 del l[-1] 228 """
214 name = " ".join(l) 229 Private method to process the lines of output.
215 self.__generateItem(changeset, name) 230
231 @param line output line to be processed (string)
232 """
233 if line.startswith(" "):
234 l = line.strip().split()
235 changeset = l[-1]
236 del l[-1]
237 name = " ".join(l)
238 self.__generateItem(changeset, name)
216 239
217 def __readStderr(self): 240 def __readStderr(self):
218 """ 241 """
219 Private slot to handle the readyReadStderr signal. 242 Private slot to handle the readyReadStderr signal.
220 243
221 It reads the error output of the process and inserts it into the 244 It reads the error output of the process and inserts it into the
222 error pane. 245 error pane.
223 """ 246 """
224 if self.process is not None: 247 if self.process is not None:
225 self.errorGroup.show()
226 s = str(self.process.readAllStandardError(), 248 s = str(self.process.readAllStandardError(),
227 Preferences.getSystem("IOEncoding"), 249 Preferences.getSystem("IOEncoding"),
228 'replace') 250 'replace')
229 self.errors.insertPlainText(s) 251 self.__showError(s)
230 self.errors.ensureCursorVisible() 252
253 def __showError(self, out):
254 """
255 Private slot to show some error.
256
257 @param out error to be shown (string)
258 """
259 self.errorGroup.show()
260 self.errors.insertPlainText(out)
261 self.errors.ensureCursorVisible()
231 262
232 def on_passwordCheckBox_toggled(self, isOn): 263 def on_passwordCheckBox_toggled(self, isOn):
233 """ 264 """
234 Private slot to handle the password checkbox toggled. 265 Private slot to handle the password checkbox toggled.
235 266

eric ide

mercurial