Plugins/VcsPlugins/vcsMercurial/HgLogDialog.py

changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1019
d8a9697f78d1
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
20 from .HgDiffDialog import HgDiffDialog 20 from .HgDiffDialog import HgDiffDialog
21 21
22 import Utilities 22 import Utilities
23 import Preferences 23 import Preferences
24 24
25
25 class HgLogDialog(QWidget, Ui_HgLogDialog): 26 class HgLogDialog(QWidget, Ui_HgLogDialog):
26 """ 27 """
27 Class implementing a dialog to show the output of the hg log command process. 28 Class implementing a dialog to show the output of the hg log command process.
28 29
29 The dialog is nonmodal. Clicking a link in the upper text pane shows 30 The dialog is nonmodal. Clicking a link in the upper text pane shows
30 a diff of the revisions. 31 a diff of the revisions.
31 """ 32 """
32 def __init__(self, vcs, mode = "log", bundle = None, parent = None): 33 def __init__(self, vcs, mode="log", bundle=None, parent=None):
33 """ 34 """
34 Constructor 35 Constructor
35 36
36 @param vcs reference to the vcs object 37 @param vcs reference to the vcs object
37 @param mode mode of the dialog (string; one of log, incoming, outgoing) 38 @param mode mode of the dialog (string; one of log, incoming, outgoing)
84 QTimer.singleShot(2000, self.process.kill) 85 QTimer.singleShot(2000, self.process.kill)
85 self.process.waitForFinished(3000) 86 self.process.waitForFinished(3000)
86 87
87 e.accept() 88 e.accept()
88 89
89 def start(self, fn, noEntries = 0): 90 def start(self, fn, noEntries=0):
90 """ 91 """
91 Public slot to start the hg log command. 92 Public slot to start the hg log command.
92 93
93 @param fn filename to show the log for (string) 94 @param fn filename to show the log for (string)
94 @param noEntries number of entries to show (integer) 95 @param noEntries number of entries to show (integer)
184 procStarted = process.waitForStarted() 185 procStarted = process.waitForStarted()
185 if procStarted: 186 if procStarted:
186 finished = process.waitForFinished(30000) 187 finished = process.waitForFinished(30000)
187 if finished and process.exitCode() == 0: 188 if finished and process.exitCode() == 0:
188 output = \ 189 output = \
189 str(process.readAllStandardOutput(), 190 str(process.readAllStandardOutput(),
190 Preferences.getSystem("IOEncoding"), 191 Preferences.getSystem("IOEncoding"),
191 'replace') 192 'replace')
192 parents = [p for p in output.strip().splitlines()] 193 parents = [p for p in output.strip().splitlines()]
193 else: 194 else:
194 if not finished: 195 if not finished:
195 errMsg = self.trUtf8("The hg process did not finish within 30s.") 196 errMsg = self.trUtf8("The hg process did not finish within 30s.")
248 url.setPath(self.filename) 249 url.setPath(self.filename)
249 query = QByteArray() 250 query = QByteArray()
250 query.append(parent.split(":")[0]).append('_').append(rev) 251 query.append(parent.split(":")[0]).append('_').append(rev)
251 url.setEncodedQuery(query) 252 url.setEncodedQuery(query)
252 dstr += ' [<a href="{0}" name="{1}" id="{1}">{2}</a>]'.format( 253 dstr += ' [<a href="{0}" name="{1}" id="{1}">{2}</a>]'.format(
253 url.toString(), 254 url.toString(),
254 str(query, encoding="ascii"), 255 str(query, encoding="ascii"),
255 self.trUtf8('diff to {0}').format(parent), 256 self.trUtf8('diff to {0}').format(parent),
256 ) 257 )
257 dstr += '<br />\n' 258 dstr += '<br />\n'
258 html += dstr 259 html += dstr
259 260
260 html += self.trUtf8("Branches: {0}<br />\n").format(entry["branches"]) 261 html += self.trUtf8("Branches: {0}<br />\n").format(entry["branches"])
275 if entry["file_adds"]: 276 if entry["file_adds"]:
276 html += '<br />\n' 277 html += '<br />\n'
277 for f in entry["file_adds"].strip().split(", "): 278 for f in entry["file_adds"].strip().split(", "):
278 if f in fileCopies: 279 if f in fileCopies:
279 html += self.trUtf8('Added {0} (copied from {1})<br />\n')\ 280 html += self.trUtf8('Added {0} (copied from {1})<br />\n')\
280 .format(Utilities.html_encode(f), 281 .format(Utilities.html_encode(f),
281 Utilities.html_encode(fileCopies[f])) 282 Utilities.html_encode(fileCopies[f]))
282 else: 283 else:
283 html += self.trUtf8('Added {0}<br />\n')\ 284 html += self.trUtf8('Added {0}<br />\n')\
284 .format(Utilities.html_encode(f)) 285 .format(Utilities.html_encode(f))
285 286
303 self.contents.setTextCursor(tc) 304 self.contents.setTextCursor(tc)
304 self.contents.ensureCursorVisible() 305 self.contents.ensureCursorVisible()
305 306
306 def __readStdout(self): 307 def __readStdout(self):
307 """ 308 """
308 Private slot to handle the readyReadStandardOutput signal. 309 Private slot to handle the readyReadStandardOutput signal.
309 310
310 It reads the output of the process and inserts it into a buffer. 311 It reads the output of the process and inserts it into a buffer.
311 """ 312 """
312 self.process.setReadChannel(QProcess.StandardOutput) 313 self.process.setReadChannel(QProcess.StandardOutput)
313 314
314 while self.process.canReadLine(): 315 while self.process.canReadLine():
315 s = str(self.process.readLine(), 316 s = str(self.process.readLine(),
316 Preferences.getSystem("IOEncoding"), 317 Preferences.getSystem("IOEncoding"),
317 'replace') 318 'replace')
318 319
319 if s == "@@@\n": 320 if s == "@@@\n":
320 self.logEntries.append(self.lastLogEntry) 321 self.logEntries.append(self.lastLogEntry)
321 self.lastLogEntry = {} 322 self.lastLogEntry = {}
347 It reads the error output of the process and inserts it into the 348 It reads the error output of the process and inserts it into the
348 error pane. 349 error pane.
349 """ 350 """
350 if self.process is not None: 351 if self.process is not None:
351 self.errorGroup.show() 352 self.errorGroup.show()
352 s = str(self.process.readAllStandardError(), 353 s = str(self.process.readAllStandardError(),
353 Preferences.getSystem("IOEncoding"), 354 Preferences.getSystem("IOEncoding"),
354 'replace') 355 'replace')
355 self.errors.insertPlainText(s) 356 self.errors.insertPlainText(s)
356 self.errors.ensureCursorVisible() 357 self.errors.ensureCursorVisible()
357 358
358 def __sourceChanged(self, url): 359 def __sourceChanged(self, url):

eric ide

mercurial