14 from PyQt4.QtCore import * |
14 from PyQt4.QtCore import * |
15 from PyQt4.QtGui import * |
15 from PyQt4.QtGui import * |
16 |
16 |
17 from E4Gui.E4Application import e4App |
17 from E4Gui.E4Application import e4App |
18 |
18 |
19 from Ui_SvnDiffDialog import Ui_SvnDiffDialog |
19 from .Ui_SvnDiffDialog import Ui_SvnDiffDialog |
20 |
20 |
21 import Utilities |
21 import Utilities |
|
22 import Preferences |
22 |
23 |
23 class SvnDiffDialog(QWidget, Ui_SvnDiffDialog): |
24 class SvnDiffDialog(QWidget, Ui_SvnDiffDialog): |
24 """ |
25 """ |
25 Class implementing a dialog to show the output of the svn diff command process. |
26 Class implementing a dialog to show the output of the svn diff command process. |
26 """ |
27 """ |
135 if summary: |
136 if summary: |
136 args.append("--summarize") |
137 args.append("--summarize") |
137 self.summaryPath = urls[0] |
138 self.summaryPath = urls[0] |
138 args.append("--old=%s" % urls[0]) |
139 args.append("--old=%s" % urls[0]) |
139 args.append("--new=%s" % urls[1]) |
140 args.append("--new=%s" % urls[1]) |
140 if type(fn) is types.ListType: |
141 if isinstance(fn, list): |
141 dname, fnames = self.vcs.splitPathList(fn) |
142 dname, fnames = self.vcs.splitPathList(fn) |
142 else: |
143 else: |
143 dname, fname = self.vcs.splitPath(fn) |
144 dname, fname = self.vcs.splitPath(fn) |
144 fnames = [fname] |
145 fnames = [fname] |
145 ppath = e4App().getObject('Project').getProjectPath() |
146 ppath = e4App().getObject('Project').getProjectPath() |
150 if path: |
151 if path: |
151 path += "/" |
152 path += "/" |
152 for fname in fnames: |
153 for fname in fnames: |
153 args.append(path + fname) |
154 args.append(path + fname) |
154 else: |
155 else: |
155 if type(fn) is types.ListType: |
156 if isinstance(fn, list): |
156 dname, fnames = self.vcs.splitPathList(fn) |
157 dname, fnames = self.vcs.splitPathList(fn) |
157 self.vcs.addArguments(args, fnames) |
158 self.vcs.addArguments(args, fnames) |
158 else: |
159 else: |
159 dname, fname = self.vcs.splitPath(fn) |
160 dname, fname = self.vcs.splitPath(fn) |
160 args.append(fname) |
161 args.append(fname) |
213 the contents pane. |
214 the contents pane. |
214 """ |
215 """ |
215 self.process.setReadChannel(QProcess.StandardOutput) |
216 self.process.setReadChannel(QProcess.StandardOutput) |
216 |
217 |
217 while self.process.canReadLine(): |
218 while self.process.canReadLine(): |
218 line = unicode(self.process.readLine()) |
219 line = str(self.process.readLine(), |
|
220 Preferences.getSystem("IOEncoding"), |
|
221 'replace') |
219 if self.summaryPath: |
222 if self.summaryPath: |
220 line = line.replace(self.summaryPath + '/', '') |
223 line = line.replace(self.summaryPath + '/', '') |
221 line = " ".join(line.split()) |
224 line = " ".join(line.split()) |
222 if line.startswith('+') or line.startswith('>') or line.startswith('A '): |
225 if line.startswith('+') or line.startswith('>') or line.startswith('A '): |
223 format = self.cAddedFormat |
226 format = self.cAddedFormat |
237 It reads the error output of the process and inserts it into the |
240 It reads the error output of the process and inserts it into the |
238 error pane. |
241 error pane. |
239 """ |
242 """ |
240 if self.process is not None: |
243 if self.process is not None: |
241 self.errorGroup.show() |
244 self.errorGroup.show() |
242 s = unicode(self.process.readAllStandardError()) |
245 s = str(self.process.readAllStandardError(), |
|
246 Preferences.getSystem("IOEncoding"), |
|
247 'replace') |
243 self.errors.insertPlainText(s) |
248 self.errors.insertPlainText(s) |
244 self.errors.ensureCursorVisible() |
249 self.errors.ensureCursorVisible() |
245 |
250 |
246 def on_buttonBox_clicked(self, button): |
251 def on_buttonBox_clicked(self, button): |
247 """ |
252 """ |
258 Private slot to handle the Save button press. |
263 Private slot to handle the Save button press. |
259 |
264 |
260 It saves the diff shown in the dialog to a file in the local |
265 It saves the diff shown in the dialog to a file in the local |
261 filesystem. |
266 filesystem. |
262 """ |
267 """ |
263 if type(self.filename) is types.ListType: |
268 if isinstance(self.filename, list): |
264 if len(self.filename) > 1: |
269 if len(self.filename) > 1: |
265 fname = self.vcs.splitPathList(self.filename)[0] |
270 fname = self.vcs.splitPathList(self.filename)[0] |
266 else: |
271 else: |
267 dname, fname = self.vcs.splitPath(self.filename[0]) |
272 dname, fname = self.vcs.splitPath(self.filename[0]) |
268 if fname != '.': |
273 if fname != '.': |
300 if res != QMessageBox.Save: |
305 if res != QMessageBox.Save: |
301 return |
306 return |
302 fname = Utilities.toNativeSeparators(fname) |
307 fname = Utilities.toNativeSeparators(fname) |
303 |
308 |
304 try: |
309 try: |
305 f = open(fname, "wb") |
310 f = open(fname, "w") |
306 f.write(self.contents.toPlainText()) |
311 f.write(self.contents.toPlainText()) |
307 f.close() |
312 f.close() |
308 except IOError, why: |
313 except IOError as why: |
309 QMessageBox.critical(self, self.trUtf8('Save Diff'), |
314 QMessageBox.critical(self, self.trUtf8('Save Diff'), |
310 self.trUtf8('<p>The patch file <b>{0}</b> could not be saved.' |
315 self.trUtf8('<p>The patch file <b>{0}</b> could not be saved.' |
311 '<br>Reason: {1}</p>') |
316 '<br>Reason: {1}</p>') |
312 .format(fname, unicode(why))) |
317 .format(fname, str(why))) |
313 |
318 |
314 def on_passwordCheckBox_toggled(self, isOn): |
319 def on_passwordCheckBox_toggled(self, isOn): |
315 """ |
320 """ |
316 Private slot to handle the password checkbox toggled. |
321 Private slot to handle the password checkbox toggled. |
317 |
322 |