Plugins/VcsPlugins/vcsMercurial/HgAnnotateDialog.py

changeset 1241
09c6155ee612
parent 1131
7781e396c903
child 1242
dfb9609caf51
equal deleted inserted replaced
1240:4d5fc346bd3b 1241:09c6155ee612
36 self.setupUi(self) 36 self.setupUi(self)
37 37
38 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 38 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
39 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 39 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
40 40
41 self.process = QProcess()
42 self.vcs = vcs 41 self.vcs = vcs
42 self.__hgClient = vcs.getClient()
43 43
44 self.annotateList.headerItem().setText(self.annotateList.columnCount(), "") 44 self.annotateList.headerItem().setText(self.annotateList.columnCount(), "")
45 font = QFont(self.annotateList.font()) 45 font = QFont(self.annotateList.font())
46 if Utilities.isWindowsPlatform(): 46 if Utilities.isWindowsPlatform():
47 font.setFamily("Lucida Console") 47 font.setFamily("Lucida Console")
49 font.setFamily("Monospace") 49 font.setFamily("Monospace")
50 self.annotateList.setFont(font) 50 self.annotateList.setFont(font)
51 51
52 self.__ioEncoding = Preferences.getSystem("IOEncoding") 52 self.__ioEncoding = Preferences.getSystem("IOEncoding")
53 53
54 self.process.finished.connect(self.__procFinished) 54 if self.__hgClient:
55 self.process.readyReadStandardOutput.connect(self.__readStdout) 55 self.process = None
56 self.process.readyReadStandardError.connect(self.__readStderr) 56 else:
57 self.process = QProcess()
58 self.process.finished.connect(self.__procFinished)
59 self.process.readyReadStandardOutput.connect(self.__readStdout)
60 self.process.readyReadStandardError.connect(self.__readStderr)
57 61
58 def closeEvent(self, e): 62 def closeEvent(self, e):
59 """ 63 """
60 Private slot implementing a close event handler. 64 Private slot implementing a close event handler.
61 65
97 args.append('--number') 101 args.append('--number')
98 args.append('--changeset') 102 args.append('--changeset')
99 args.append('--quiet') 103 args.append('--quiet')
100 args.append(fn) 104 args.append(fn)
101 105
102 self.process.kill() 106 if self.__hgClient:
103 self.process.setWorkingDirectory(repodir)
104
105 self.process.start('hg', args)
106 procStarted = self.process.waitForStarted()
107 if not procStarted:
108 self.inputGroup.setEnabled(False) 107 self.inputGroup.setEnabled(False)
109 self.inputGroup.hide() 108 self.inputGroup.hide()
110 E5MessageBox.critical(self, 109
111 self.trUtf8('Process Generation Error'), 110 out, err = self.__hgClient.runcommand(args)
112 self.trUtf8( 111 if err:
113 'The process {0} could not be started. ' 112 self.__showError(err)
114 'Ensure, that it is in the search path.' 113 if out:
115 ).format('hg')) 114 for line in out.splitlines():
116 else: 115 self.__processOutputLine(line)
117 self.inputGroup.setEnabled(True) 116 self.__finish()
118 self.inputGroup.show() 117 else:
118 self.process.kill()
119 self.process.setWorkingDirectory(repodir)
120
121 self.process.start('hg', args)
122 procStarted = self.process.waitForStarted()
123 if not procStarted:
124 self.inputGroup.setEnabled(False)
125 self.inputGroup.hide()
126 E5MessageBox.critical(self,
127 self.trUtf8('Process Generation Error'),
128 self.trUtf8(
129 'The process {0} could not be started. '
130 'Ensure, that it is in the search path.'
131 ).format('hg'))
132 else:
133 self.inputGroup.setEnabled(True)
134 self.inputGroup.show()
119 135
120 def __finish(self): 136 def __finish(self):
121 """ 137 """
122 Private slot called when the process finished or the user pressed the button. 138 Private slot called when the process finished or the user pressed the button.
123 """ 139 """
191 """ 207 """
192 self.process.setReadChannel(QProcess.StandardOutput) 208 self.process.setReadChannel(QProcess.StandardOutput)
193 209
194 while self.process.canReadLine(): 210 while self.process.canReadLine():
195 s = str(self.process.readLine(), self.__ioEncoding, 'replace').strip() 211 s = str(self.process.readLine(), self.__ioEncoding, 'replace').strip()
196 try: 212 self.__processOutputLine(s)
197 info, text = s.split(": ", 1) 213
198 except ValueError: 214 def __processOutputLine(self, line):
199 info = s[:-2] 215 """
200 text = "" 216 Private method to process the lines of output.
201 author, rev, changeset, date, file = info.split() 217
202 self.__generateItem(rev, changeset, author, date, text) 218 @param line output line to be processed (string)
219 """
220 try:
221 info, text = line.split(": ", 1)
222 except ValueError:
223 info = line[:-2]
224 text = ""
225 author, rev, changeset, date, file = info.split()
226 self.__generateItem(rev, changeset, author, date, text)
203 227
204 def __readStderr(self): 228 def __readStderr(self):
205 """ 229 """
206 Private slot to handle the readyReadStderr signal. 230 Private slot to handle the readyReadStderr signal.
207 231
211 if self.process is not None: 235 if self.process is not None:
212 self.errorGroup.show() 236 self.errorGroup.show()
213 s = str(self.process.readAllStandardError(), 237 s = str(self.process.readAllStandardError(),
214 Preferences.getSystem("IOEncoding"), 238 Preferences.getSystem("IOEncoding"),
215 'replace') 239 'replace')
216 self.errors.insertPlainText(s) 240 self.__showError(s)
217 self.errors.ensureCursorVisible() 241
242 def __showError(self, out):
243 """
244 Private slot to show some error.
245
246 @param out error to be shown (string)
247 """
248 self.errorGroup.show()
249 self.errors.insertPlainText(out)
250 self.errors.ensureCursorVisible()
218 251
219 def on_passwordCheckBox_toggled(self, isOn): 252 def on_passwordCheckBox_toggled(self, isOn):
220 """ 253 """
221 Private slot to handle the password checkbox toggled. 254 Private slot to handle the password checkbox toggled.
222 255

eric ide

mercurial