7 Module implementing a dialog to show the output of the hg annotate command. |
7 Module implementing a dialog to show the output of the hg annotate command. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 try: |
11 try: |
12 str = unicode # __IGNORE_WARNING__ |
12 str = unicode |
13 except (NameError): |
13 except NameError: |
14 pass |
14 pass |
15 |
15 |
16 import os |
16 import os |
17 |
17 |
18 from PyQt4.QtCore import pyqtSlot, QProcess, QTimer, Qt, QCoreApplication |
18 from PyQt4.QtCore import pyqtSlot, QProcess, QTimer, Qt, QCoreApplication |
19 from PyQt4.QtGui import QDialog, QDialogButtonBox, QFont, QHeaderView, \ |
19 from PyQt4.QtGui import QDialog, QDialogButtonBox, QHeaderView, QLineEdit, \ |
20 QTreeWidgetItem, QLineEdit |
20 QTreeWidgetItem |
21 |
21 |
22 from E5Gui import E5MessageBox |
22 from E5Gui import E5MessageBox |
23 |
23 |
24 from .Ui_HgAnnotateDialog import Ui_HgAnnotateDialog |
24 from .Ui_HgAnnotateDialog import Ui_HgAnnotateDialog |
25 |
25 |
26 import Preferences |
26 import Preferences |
27 import Utilities |
|
28 |
27 |
29 |
28 |
30 class HgAnnotateDialog(QDialog, Ui_HgAnnotateDialog): |
29 class HgAnnotateDialog(QDialog, Ui_HgAnnotateDialog): |
31 """ |
30 """ |
32 Class implementing a dialog to show the output of the hg annotate command. |
31 Class implementing a dialog to show the output of the hg annotate command. |
47 self.vcs = vcs |
46 self.vcs = vcs |
48 self.__hgClient = vcs.getClient() |
47 self.__hgClient = vcs.getClient() |
49 |
48 |
50 self.annotateList.headerItem().setText( |
49 self.annotateList.headerItem().setText( |
51 self.annotateList.columnCount(), "") |
50 self.annotateList.columnCount(), "") |
52 font = QFont(self.annotateList.font()) |
51 font = Preferences.getEditorOtherFonts("MonospacedFont") |
53 if Utilities.isWindowsPlatform(): |
|
54 font.setFamily("Lucida Console") |
|
55 else: |
|
56 font.setFamily("Monospace") |
|
57 self.annotateList.setFont(font) |
52 self.annotateList.setFont(font) |
58 |
|
59 self.__ioEncoding = Preferences.getSystem("IOEncoding") |
|
60 |
53 |
61 if self.__hgClient: |
54 if self.__hgClient: |
62 self.process = None |
55 self.process = None |
63 else: |
56 else: |
64 self.process = QProcess() |
57 self.process = QProcess() |
105 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
98 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
106 repodir = os.path.dirname(repodir) |
99 repodir = os.path.dirname(repodir) |
107 if os.path.splitdrive(repodir)[1] == os.sep: |
100 if os.path.splitdrive(repodir)[1] == os.sep: |
108 return |
101 return |
109 |
102 |
110 args = [] |
103 args = self.vcs.initCommand("annotate") |
111 args.append('annotate') |
|
112 args.append('--follow') |
104 args.append('--follow') |
113 args.append('--user') |
105 args.append('--user') |
114 args.append('--date') |
106 args.append('--date') |
115 args.append('--number') |
107 args.append('--number') |
116 args.append('--changeset') |
108 args.append('--changeset') |
139 if not procStarted: |
131 if not procStarted: |
140 self.inputGroup.setEnabled(False) |
132 self.inputGroup.setEnabled(False) |
141 self.inputGroup.hide() |
133 self.inputGroup.hide() |
142 E5MessageBox.critical( |
134 E5MessageBox.critical( |
143 self, |
135 self, |
144 self.trUtf8('Process Generation Error'), |
136 self.tr('Process Generation Error'), |
145 self.trUtf8( |
137 self.tr( |
146 'The process {0} could not be started. ' |
138 'The process {0} could not be started. ' |
147 'Ensure, that it is in the search path.' |
139 'Ensure, that it is in the search path.' |
148 ).format('hg')) |
140 ).format('hg')) |
149 else: |
141 else: |
150 self.inputGroup.setEnabled(True) |
142 self.inputGroup.setEnabled(True) |
229 the annotation list. |
221 the annotation list. |
230 """ |
222 """ |
231 self.process.setReadChannel(QProcess.StandardOutput) |
223 self.process.setReadChannel(QProcess.StandardOutput) |
232 |
224 |
233 while self.process.canReadLine(): |
225 while self.process.canReadLine(): |
234 s = str(self.process.readLine(), self.__ioEncoding, 'replace')\ |
226 s = str(self.process.readLine(), self.vcs.getEncoding(), |
235 .strip() |
227 'replace').strip() |
236 self.__processOutputLine(s) |
228 self.__processOutputLine(s) |
237 |
229 |
238 def __processOutputLine(self, line): |
230 def __processOutputLine(self, line): |
239 """ |
231 """ |
240 Private method to process the lines of output. |
232 Private method to process the lines of output. |
256 It reads the error output of the process and inserts it into the |
248 It reads the error output of the process and inserts it into the |
257 error pane. |
249 error pane. |
258 """ |
250 """ |
259 if self.process is not None: |
251 if self.process is not None: |
260 s = str(self.process.readAllStandardError(), |
252 s = str(self.process.readAllStandardError(), |
261 Preferences.getSystem("IOEncoding"), |
253 self.vcs.getEncoding(), 'replace') |
262 'replace') |
|
263 self.__showError(s) |
254 self.__showError(s) |
264 |
255 |
265 def __showError(self, out): |
256 def __showError(self, out): |
266 """ |
257 """ |
267 Private slot to show some error. |
258 Private slot to show some error. |