7 Module implementing a dialog to show a list of incoming or outgoing bookmarks. |
7 Module implementing a dialog to show a list of incoming or outgoing bookmarks. |
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, Qt, QTimer, QCoreApplication |
18 from PyQt4.QtCore import pyqtSlot, QProcess, Qt, QTimer, QCoreApplication |
20 QTreeWidgetItem, QLineEdit |
20 QTreeWidgetItem, QLineEdit |
21 |
21 |
22 from E5Gui import E5MessageBox |
22 from E5Gui import E5MessageBox |
23 |
23 |
24 from .Ui_HgBookmarksInOutDialog import Ui_HgBookmarksInOutDialog |
24 from .Ui_HgBookmarksInOutDialog import Ui_HgBookmarksInOutDialog |
25 |
|
26 import Preferences |
|
27 |
25 |
28 |
26 |
29 class HgBookmarksInOutDialog(QDialog, Ui_HgBookmarksInOutDialog): |
27 class HgBookmarksInOutDialog(QDialog, Ui_HgBookmarksInOutDialog): |
30 """ |
28 """ |
31 Class implementing a dialog to show a list of incoming or outgoing |
29 Class implementing a dialog to show a list of incoming or outgoing |
51 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
49 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
52 |
50 |
53 if mode not in [self.INCOMING, self.OUTGOING]: |
51 if mode not in [self.INCOMING, self.OUTGOING]: |
54 raise ValueError("Bad value for mode") |
52 raise ValueError("Bad value for mode") |
55 if mode == self.INCOMING: |
53 if mode == self.INCOMING: |
56 self.setWindowTitle(self.trUtf8("Mercurial Incoming Bookmarks")) |
54 self.setWindowTitle(self.tr("Mercurial Incoming Bookmarks")) |
57 elif mode == self.OUTGOING: |
55 elif mode == self.OUTGOING: |
58 self.setWindowTitle(self.trUtf8("Mercurial Outgoing Bookmarks")) |
56 self.setWindowTitle(self.tr("Mercurial Outgoing Bookmarks")) |
59 |
57 |
60 self.process = QProcess() |
58 self.process = QProcess() |
61 self.vcs = vcs |
59 self.vcs = vcs |
62 self.mode = mode |
60 self.mode = mode |
63 self.__hgClient = vcs.getClient() |
61 self.__hgClient = vcs.getClient() |
110 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
108 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
111 repodir = os.path.dirname(repodir) |
109 repodir = os.path.dirname(repodir) |
112 if os.path.splitdrive(repodir)[1] == os.sep: |
110 if os.path.splitdrive(repodir)[1] == os.sep: |
113 return |
111 return |
114 |
112 |
115 args = [] |
|
116 if self.mode == self.INCOMING: |
113 if self.mode == self.INCOMING: |
117 args.append('incoming') |
114 args = self.vcs.initCommand("incoming") |
118 elif self.mode == self.OUTGOING: |
115 elif self.mode == self.OUTGOING: |
119 args.append('outgoing') |
116 args = self.vcs.initCommand("outgoing") |
120 else: |
117 else: |
121 raise ValueError("Bad value for mode") |
118 raise ValueError("Bad value for mode") |
122 args.append('--bookmarks') |
119 args.append('--bookmarks') |
123 |
120 |
124 if self.__hgClient: |
121 if self.__hgClient: |
143 if not procStarted: |
140 if not procStarted: |
144 self.inputGroup.setEnabled(False) |
141 self.inputGroup.setEnabled(False) |
145 self.inputGroup.hide() |
142 self.inputGroup.hide() |
146 E5MessageBox.critical( |
143 E5MessageBox.critical( |
147 self, |
144 self, |
148 self.trUtf8('Process Generation Error'), |
145 self.tr('Process Generation Error'), |
149 self.trUtf8( |
146 self.tr( |
150 'The process {0} could not be started. ' |
147 'The process {0} could not be started. ' |
151 'Ensure, that it is in the search path.' |
148 'Ensure, that it is in the search path.' |
152 ).format('hg')) |
149 ).format('hg')) |
153 else: |
150 else: |
154 self.inputGroup.setEnabled(True) |
151 self.inputGroup.setEnabled(True) |
176 |
173 |
177 self.process = None |
174 self.process = None |
178 |
175 |
179 if self.bookmarksList.topLevelItemCount() == 0: |
176 if self.bookmarksList.topLevelItemCount() == 0: |
180 # no bookmarks defined |
177 # no bookmarks defined |
181 self.__generateItem(self.trUtf8("no bookmarks found"), "") |
178 self.__generateItem(self.tr("no bookmarks found"), "") |
182 self.__resizeColumns() |
179 self.__resizeColumns() |
183 self.__resort() |
180 self.__resort() |
184 |
181 |
185 def on_buttonBox_clicked(self, button): |
182 def on_buttonBox_clicked(self, button): |
186 """ |
183 """ |
240 the contents pane. |
237 the contents pane. |
241 """ |
238 """ |
242 self.process.setReadChannel(QProcess.StandardOutput) |
239 self.process.setReadChannel(QProcess.StandardOutput) |
243 |
240 |
244 while self.process.canReadLine(): |
241 while self.process.canReadLine(): |
245 s = str(self.process.readLine(), |
242 s = str(self.process.readLine(), self.vcs.getEncoding(), 'replace') |
246 Preferences.getSystem("IOEncoding"), |
|
247 'replace') |
|
248 self.__processOutputLine(s) |
243 self.__processOutputLine(s) |
249 |
244 |
250 def __processOutputLine(self, line): |
245 def __processOutputLine(self, line): |
251 """ |
246 """ |
252 Private method to process the lines of output. |
247 Private method to process the lines of output. |
267 It reads the error output of the process and inserts it into the |
262 It reads the error output of the process and inserts it into the |
268 error pane. |
263 error pane. |
269 """ |
264 """ |
270 if self.process is not None: |
265 if self.process is not None: |
271 s = str(self.process.readAllStandardError(), |
266 s = str(self.process.readAllStandardError(), |
272 Preferences.getSystem("IOEncoding"), |
267 self.vcs.getEncoding(), 'replace') |
273 'replace') |
|
274 self.__showError(s) |
268 self.__showError(s) |
275 |
269 |
276 def __showError(self, out): |
270 def __showError(self, out): |
277 """ |
271 """ |
278 Private slot to show some error. |
272 Private slot to show some error. |