Plugins/VcsPlugins/vcsSubversion/SvnDiffDialog.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3190
a9a94491c4fd
child 3591
2f2a4a76dd22
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
8 process. 8 process.
9 """ 9 """
10 10
11 from __future__ import unicode_literals 11 from __future__ import unicode_literals
12 try: 12 try:
13 str = unicode # __IGNORE_WARNING__ 13 str = unicode
14 except (NameError): 14 except NameError:
15 pass 15 pass
16 16
17 import os 17 import os
18 18
19 from PyQt4.QtCore import QTimer, QFileInfo, QProcess, pyqtSlot, Qt 19 from PyQt4.QtCore import QTimer, QFileInfo, QProcess, pyqtSlot, Qt
180 if not procStarted: 180 if not procStarted:
181 self.inputGroup.setEnabled(False) 181 self.inputGroup.setEnabled(False)
182 self.inputGroup.hide() 182 self.inputGroup.hide()
183 E5MessageBox.critical( 183 E5MessageBox.critical(
184 self, 184 self,
185 self.trUtf8('Process Generation Error'), 185 self.tr('Process Generation Error'),
186 self.trUtf8( 186 self.tr(
187 'The process {0} could not be started. ' 187 'The process {0} could not be started. '
188 'Ensure, that it is in the search path.' 188 'Ensure, that it is in the search path.'
189 ).format('svn')) 189 ).format('svn'))
190 190
191 def __procFinished(self, exitCode, exitStatus): 191 def __procFinished(self, exitCode, exitStatus):
198 self.inputGroup.setEnabled(False) 198 self.inputGroup.setEnabled(False)
199 self.inputGroup.hide() 199 self.inputGroup.hide()
200 200
201 if self.paras == 0: 201 if self.paras == 0:
202 self.contents.insertPlainText( 202 self.contents.insertPlainText(
203 self.trUtf8('There is no difference.')) 203 self.tr('There is no difference.'))
204 return 204 return
205 205
206 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(True) 206 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(True)
207 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 207 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
208 self.buttonBox.button(QDialogButtonBox.Close).setFocus( 208 self.buttonBox.button(QDialogButtonBox.Close).setFocus(
211 tc = self.contents.textCursor() 211 tc = self.contents.textCursor()
212 tc.movePosition(QTextCursor.Start) 212 tc.movePosition(QTextCursor.Start)
213 self.contents.setTextCursor(tc) 213 self.contents.setTextCursor(tc)
214 self.contents.ensureCursorVisible() 214 self.contents.ensureCursorVisible()
215 215
216 self.filesCombo.addItem(self.trUtf8("<Start>"), 0) 216 self.filesCombo.addItem(self.tr("<Start>"), 0)
217 self.filesCombo.addItem(self.trUtf8("<End>"), -1) 217 self.filesCombo.addItem(self.tr("<End>"), -1)
218 for oldFile, newFile, pos in sorted(self.__fileSeparators): 218 for oldFile, newFile, pos in sorted(self.__fileSeparators):
219 if oldFile != newFile: 219 if oldFile != newFile:
220 self.filesCombo.addItem( 220 self.filesCombo.addItem(
221 "{0}\n{1}".format(oldFile, newFile), pos) 221 "{0}\n{1}".format(oldFile, newFile), pos)
222 else: 222 else:
370 else: 370 else:
371 fname = self.vcs.splitPath(self.filename)[0] 371 fname = self.vcs.splitPath(self.filename)[0]
372 372
373 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( 373 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
374 self, 374 self,
375 self.trUtf8("Save Diff"), 375 self.tr("Save Diff"),
376 fname, 376 fname,
377 self.trUtf8("Patch Files (*.diff)"), 377 self.tr("Patch Files (*.diff)"),
378 None, 378 None,
379 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) 379 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
380 380
381 if not fname: 381 if not fname:
382 return # user aborted 382 return # user aborted
387 if ex: 387 if ex:
388 fname += ex 388 fname += ex
389 if QFileInfo(fname).exists(): 389 if QFileInfo(fname).exists():
390 res = E5MessageBox.yesNo( 390 res = E5MessageBox.yesNo(
391 self, 391 self,
392 self.trUtf8("Save Diff"), 392 self.tr("Save Diff"),
393 self.trUtf8("<p>The patch file <b>{0}</b> already exists." 393 self.tr("<p>The patch file <b>{0}</b> already exists."
394 " Overwrite it?</p>").format(fname), 394 " Overwrite it?</p>").format(fname),
395 icon=E5MessageBox.Warning) 395 icon=E5MessageBox.Warning)
396 if not res: 396 if not res:
397 return 397 return
398 fname = Utilities.toNativeSeparators(fname) 398 fname = Utilities.toNativeSeparators(fname)
399 399
402 f = open(fname, "w", encoding="utf-8", newline="") 402 f = open(fname, "w", encoding="utf-8", newline="")
403 f.write(eol.join(self.contents.toPlainText().splitlines())) 403 f.write(eol.join(self.contents.toPlainText().splitlines()))
404 f.close() 404 f.close()
405 except IOError as why: 405 except IOError as why:
406 E5MessageBox.critical( 406 E5MessageBox.critical(
407 self, self.trUtf8('Save Diff'), 407 self, self.tr('Save Diff'),
408 self.trUtf8( 408 self.tr(
409 '<p>The patch file <b>{0}</b> could not be saved.' 409 '<p>The patch file <b>{0}</b> could not be saved.'
410 '<br>Reason: {1}</p>') 410 '<br>Reason: {1}</p>')
411 .format(fname, str(why))) 411 .format(fname, str(why)))
412 412
413 def on_passwordCheckBox_toggled(self, isOn): 413 def on_passwordCheckBox_toggled(self, isOn):

eric ide

mercurial