17 |
17 |
18 from .Ui_SvnDiffDialog import Ui_SvnDiffDialog |
18 from .Ui_SvnDiffDialog import Ui_SvnDiffDialog |
19 |
19 |
20 import Utilities |
20 import Utilities |
21 import Preferences |
21 import Preferences |
|
22 |
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 """ |
27 def __init__(self, vcs, parent = None): |
28 def __init__(self, vcs, parent=None): |
28 """ |
29 """ |
29 Constructor |
30 Constructor |
30 |
31 |
31 @param vcs reference to the vcs object |
32 @param vcs reference to the vcs object |
32 @param parent parent widget (QWidget) |
33 @param parent parent widget (QWidget) |
81 if version == "WORKING": |
82 if version == "WORKING": |
82 return None |
83 return None |
83 else: |
84 else: |
84 return str(version) |
85 return str(version) |
85 |
86 |
86 def start(self, fn, versions = None, urls = None, summary = False): |
87 def start(self, fn, versions=None, urls=None, summary=False): |
87 """ |
88 """ |
88 Public slot to start the svn diff command. |
89 Public slot to start the svn diff command. |
89 |
90 |
90 @param fn filename to be diffed (string) |
91 @param fn filename to be diffed (string) |
91 @param versions list of versions to be diffed (list of up to 2 strings or None) |
92 @param versions list of versions to be diffed (list of up to 2 strings or None) |
92 @keyparam urls list of repository URLs (list of 2 strings) |
93 @keyparam urls list of repository URLs (list of 2 strings) |
93 @keyparam summary flag indicating a summarizing diff |
94 @keyparam summary flag indicating a summarizing diff |
94 (only valid for URL diffs) (boolean) |
95 (only valid for URL diffs) (boolean) |
95 """ |
96 """ |
96 self.errorGroup.hide() |
97 self.errorGroup.hide() |
97 self.intercept = False |
98 self.intercept = False |
98 self.filename = fn |
99 self.filename = fn |
202 self.contents.setCurrentCharFormat(format) |
203 self.contents.setCurrentCharFormat(format) |
203 self.contents.insertPlainText(txt) |
204 self.contents.insertPlainText(txt) |
204 |
205 |
205 def __readStdout(self): |
206 def __readStdout(self): |
206 """ |
207 """ |
207 Private slot to handle the readyReadStandardOutput signal. |
208 Private slot to handle the readyReadStandardOutput signal. |
208 |
209 |
209 It reads the output of the process, formats it and inserts it into |
210 It reads the output of the process, formats it and inserts it into |
210 the contents pane. |
211 the contents pane. |
211 """ |
212 """ |
212 self.process.setReadChannel(QProcess.StandardOutput) |
213 self.process.setReadChannel(QProcess.StandardOutput) |
213 |
214 |
214 while self.process.canReadLine(): |
215 while self.process.canReadLine(): |
215 line = str(self.process.readLine(), |
216 line = str(self.process.readLine(), |
216 Preferences.getSystem("IOEncoding"), |
217 Preferences.getSystem("IOEncoding"), |
217 'replace') |
218 'replace') |
218 if self.summaryPath: |
219 if self.summaryPath: |
219 line = line.replace(self.summaryPath + '/', '') |
220 line = line.replace(self.summaryPath + '/', '') |
220 line = " ".join(line.split()) |
221 line = " ".join(line.split()) |
221 if line.startswith('+') or line.startswith('>') or line.startswith('A '): |
222 if line.startswith('+') or line.startswith('>') or line.startswith('A '): |
236 It reads the error output of the process and inserts it into the |
237 It reads the error output of the process and inserts it into the |
237 error pane. |
238 error pane. |
238 """ |
239 """ |
239 if self.process is not None: |
240 if self.process is not None: |
240 self.errorGroup.show() |
241 self.errorGroup.show() |
241 s = str(self.process.readAllStandardError(), |
242 s = str(self.process.readAllStandardError(), |
242 Preferences.getSystem("IOEncoding"), |
243 Preferences.getSystem("IOEncoding"), |
243 'replace') |
244 'replace') |
244 self.errors.insertPlainText(s) |
245 self.errors.insertPlainText(s) |
245 self.errors.ensureCursorVisible() |
246 self.errors.ensureCursorVisible() |
246 |
247 |
247 def on_buttonBox_clicked(self, button): |
248 def on_buttonBox_clicked(self, button): |
292 if QFileInfo(fname).exists(): |
293 if QFileInfo(fname).exists(): |
293 res = E5MessageBox.yesNo(self, |
294 res = E5MessageBox.yesNo(self, |
294 self.trUtf8("Save Diff"), |
295 self.trUtf8("Save Diff"), |
295 self.trUtf8("<p>The patch file <b>{0}</b> already exists." |
296 self.trUtf8("<p>The patch file <b>{0}</b> already exists." |
296 " Overwrite it?</p>").format(fname), |
297 " Overwrite it?</p>").format(fname), |
297 icon = E5MessageBox.Warning) |
298 icon=E5MessageBox.Warning) |
298 if not res: |
299 if not res: |
299 return |
300 return |
300 fname = Utilities.toNativeSeparators(fname) |
301 fname = Utilities.toNativeSeparators(fname) |
301 |
302 |
302 try: |
303 try: |
303 f = open(fname, "w", encoding = "utf-8") |
304 f = open(fname, "w", encoding="utf-8") |
304 f.write(self.contents.toPlainText()) |
305 f.write(self.contents.toPlainText()) |
305 f.close() |
306 f.close() |
306 except IOError as why: |
307 except IOError as why: |
307 E5MessageBox.critical(self, self.trUtf8('Save Diff'), |
308 E5MessageBox.critical(self, self.trUtf8('Save Diff'), |
308 self.trUtf8('<p>The patch file <b>{0}</b> could not be saved.' |
309 self.trUtf8('<p>The patch file <b>{0}</b> could not be saved.' |