7 Module implementing a dialog to show the commit message of the current patch. |
7 Module implementing a dialog to show the commit message of the current patch. |
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 QProcess, QTimer, Qt, QCoreApplication |
18 from PyQt4.QtCore import QProcess, QTimer, Qt, QCoreApplication |
19 from PyQt4.QtGui import QDialog, QDialogButtonBox |
19 from PyQt4.QtGui import QDialog, QDialogButtonBox |
20 |
20 |
21 from E5Gui import E5MessageBox |
21 from E5Gui import E5MessageBox |
22 |
22 |
23 from .Ui_HgQueuesHeaderDialog import Ui_HgQueuesHeaderDialog |
23 from .Ui_HgQueuesHeaderDialog import Ui_HgQueuesHeaderDialog |
24 |
|
25 import Preferences |
|
26 |
24 |
27 |
25 |
28 class HgQueuesHeaderDialog(QDialog, Ui_HgQueuesHeaderDialog): |
26 class HgQueuesHeaderDialog(QDialog, Ui_HgQueuesHeaderDialog): |
29 """ |
27 """ |
30 Class implementing a dialog to show the commit message of the current |
28 Class implementing a dialog to show the commit message of the current |
87 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
85 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
88 repodir = os.path.dirname(repodir) |
86 repodir = os.path.dirname(repodir) |
89 if os.path.splitdrive(repodir)[1] == os.sep: |
87 if os.path.splitdrive(repodir)[1] == os.sep: |
90 return |
88 return |
91 |
89 |
92 args = [] |
90 args = self.vcs.initCommand("qheader") |
93 args.append('qheader') |
|
94 |
91 |
95 if self.__hgClient: |
92 if self.__hgClient: |
96 self.inputGroup.setEnabled(False) |
|
97 self.inputGroup.hide() |
|
98 |
|
99 out, err = self.__hgClient.runcommand( |
93 out, err = self.__hgClient.runcommand( |
100 args, output=self.__showOutput, error=self.__showError) |
94 args, output=self.__showOutput, error=self.__showError) |
101 if err: |
95 if err: |
102 self.__showError(err) |
96 self.__showError(err) |
103 if out: |
97 if out: |
110 self.process.start('hg', args) |
104 self.process.start('hg', args) |
111 procStarted = self.process.waitForStarted(5000) |
105 procStarted = self.process.waitForStarted(5000) |
112 if not procStarted: |
106 if not procStarted: |
113 E5MessageBox.critical( |
107 E5MessageBox.critical( |
114 self, |
108 self, |
115 self.trUtf8('Process Generation Error'), |
109 self.tr('Process Generation Error'), |
116 self.trUtf8( |
110 self.tr( |
117 'The process {0} could not be started. ' |
111 'The process {0} could not be started. ' |
118 'Ensure, that it is in the search path.' |
112 'Ensure, that it is in the search path.' |
119 ).format('hg')) |
113 ).format('hg')) |
120 |
114 |
121 def __finish(self): |
115 def __finish(self): |
167 It reads the output of the process, formats it and inserts it into |
161 It reads the output of the process, formats it and inserts it into |
168 the contents pane. |
162 the contents pane. |
169 """ |
163 """ |
170 if self.process is not None: |
164 if self.process is not None: |
171 s = str(self.process.readAllStandardOutput(), |
165 s = str(self.process.readAllStandardOutput(), |
172 Preferences.getSystem("IOEncoding"), |
166 self.vcs.getEncoding(), 'replace') |
173 'replace') |
|
174 self.__showOutput(s) |
167 self.__showOutput(s) |
175 |
168 |
176 def __showOutput(self, out): |
169 def __showOutput(self, out): |
177 """ |
170 """ |
178 Private slot to show some output. |
171 Private slot to show some output. |
188 It reads the error output of the process and inserts it into the |
181 It reads the error output of the process and inserts it into the |
189 error pane. |
182 error pane. |
190 """ |
183 """ |
191 if self.process is not None: |
184 if self.process is not None: |
192 s = str(self.process.readAllStandardError(), |
185 s = str(self.process.readAllStandardError(), |
193 Preferences.getSystem("IOEncoding"), |
186 self.vcs.getEncoding(), 'replace') |
194 'replace') |
|
195 self.__showError(s) |
187 self.__showError(s) |
196 |
188 |
197 def __showError(self, out): |
189 def __showError(self, out): |
198 """ |
190 """ |
199 Private slot to show some error. |
191 Private slot to show some error. |
200 |
192 |
201 @param out error to be shown (string) |
193 @param out error to be shown (string) |
202 """ |
194 """ |
203 self.messageEdit.appendPlainText(self.trUtf8("Error: ")) |
195 self.messageEdit.appendPlainText(self.tr("Error: ")) |
204 self.messageEdit.appendPlainText(out) |
196 self.messageEdit.appendPlainText(out) |