16 from PyQt4.QtCore import * |
16 from PyQt4.QtCore import * |
17 from PyQt4.QtGui import * |
17 from PyQt4.QtGui import * |
18 |
18 |
19 from E4Gui.E4Application import e4App |
19 from E4Gui.E4Application import e4App |
20 |
20 |
21 from SvnDialogMixin import SvnDialogMixin |
21 from .SvnDialogMixin import SvnDialogMixin |
22 from Ui_SvnDiffDialog import Ui_SvnDiffDialog |
22 from .Ui_SvnDiffDialog import Ui_SvnDiffDialog |
23 |
23 |
24 import Utilities |
24 import Utilities |
25 |
25 |
26 class SvnDiffDialog(QWidget, SvnDialogMixin, Ui_SvnDiffDialog): |
26 class SvnDiffDialog(QWidget, SvnDialogMixin, Ui_SvnDiffDialog): |
27 """ |
27 """ |
70 Private method to get a pysvn revision object for the given version number. |
70 Private method to get a pysvn revision object for the given version number. |
71 |
71 |
72 @param version revision (integer or string) |
72 @param version revision (integer or string) |
73 @return revision object (pysvn.Revision) |
73 @return revision object (pysvn.Revision) |
74 """ |
74 """ |
75 if type(version) == type(1) or type(version) == type(1L): |
75 if isinstance(version, int): |
76 return pysvn.Revision(pysvn.opt_revision_kind.number, version) |
76 return pysvn.Revision(pysvn.opt_revision_kind.number, version) |
77 elif version.startswith("{"): |
77 elif version.startswith("{"): |
78 dateStr = version[1:-1] |
78 dateStr = version[1:-1] |
79 secs = QDateTime.fromString(dateStr, Qt.ISODate).toTime_t() |
79 secs = QDateTime.fromString(dateStr, Qt.ISODate).toTime_t() |
80 return pysvn.Revision(pysvn.opt_revision_kind.date, secs) |
80 return pysvn.Revision(pysvn.opt_revision_kind.date, secs) |
174 |
174 |
175 if urls is not None: |
175 if urls is not None: |
176 rev1 = self.__getVersionArg("HEAD") |
176 rev1 = self.__getVersionArg("HEAD") |
177 rev2 = self.__getVersionArg("HEAD") |
177 rev2 = self.__getVersionArg("HEAD") |
178 |
178 |
179 if type(fn) is types.ListType: |
179 if isinstance(fn, list): |
180 dname, fnames = self.vcs.splitPathList(fn) |
180 dname, fnames = self.vcs.splitPathList(fn) |
181 else: |
181 else: |
182 dname, fname = self.vcs.splitPath(fn) |
182 dname, fname = self.vcs.splitPath(fn) |
183 fnames = [fname] |
183 fnames = [fname] |
184 |
184 |
301 Private slot to handle the Save button press. |
301 Private slot to handle the Save button press. |
302 |
302 |
303 It saves the diff shown in the dialog to a file in the local |
303 It saves the diff shown in the dialog to a file in the local |
304 filesystem. |
304 filesystem. |
305 """ |
305 """ |
306 if type(self.filename) is types.ListType: |
306 if isinstance(self.filename, list): |
307 if len(self.filename) > 1: |
307 if len(self.filename) > 1: |
308 fname = self.vcs.splitPathList(self.filename)[0] |
308 fname = self.vcs.splitPathList(self.filename)[0] |
309 else: |
309 else: |
310 dname, fname = self.vcs.splitPath(self.filename[0]) |
310 dname, fname = self.vcs.splitPath(self.filename[0]) |
311 if fname != '.': |
311 if fname != '.': |
343 if res != QMessageBox.Save: |
343 if res != QMessageBox.Save: |
344 return |
344 return |
345 fname = Utilities.toNativeSeparators(fname) |
345 fname = Utilities.toNativeSeparators(fname) |
346 |
346 |
347 try: |
347 try: |
348 f = open(fname, "wb") |
348 f = open(fname, "w") |
349 f.write(self.contents.toPlainText()) |
349 f.write(self.contents.toPlainText()) |
350 f.close() |
350 f.close() |
351 except IOError, why: |
351 except IOError as why: |
352 QMessageBox.critical(self, self.trUtf8('Save Diff'), |
352 QMessageBox.critical(self, self.trUtf8('Save Diff'), |
353 self.trUtf8('<p>The patch file <b>{0}</b> could not be saved.' |
353 self.trUtf8('<p>The patch file <b>{0}</b> could not be saved.' |
354 '<br>Reason: {1}</p>') |
354 '<br>Reason: {1}</p>') |
355 .format(fname, unicode(why))) |
355 .format(fname, str(why))) |
356 |
356 |
357 def __showError(self, msg): |
357 def __showError(self, msg): |
358 """ |
358 """ |
359 Private slot to show an error message. |
359 Private slot to show an error message. |
360 |
360 |