Plugins/VcsPlugins/vcsSubversion/SvnDiffDialog.py

Sat, 17 Jan 2015 14:34:26 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 17 Jan 2015 14:34:26 +0100
changeset 4052
17d8069de085
parent 4037
beb0e092738d
child 4065
8e81259fb739
permissions
-rw-r--r--

Added capability to search in the output of Diff dialogs of the various VCS interfaces.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
4021
195a471c327b Updated copyright for 2015.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
3 # Copyright (c) 2003 - 2015 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
3009
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
7 Module implementing a dialog to show the output of the svn diff command
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
8 process.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
11 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
12 try:
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3178 3190
diff changeset
13 str = unicode
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3178 3190
diff changeset
14 except NameError:
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
15 pass
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
16
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import os
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
19 from PyQt5.QtCore import QTimer, QFileInfo, QProcess, pyqtSlot, Qt
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
20 from PyQt5.QtGui import QColor, QBrush, QTextCursor
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
21 from PyQt5.QtWidgets import QWidget, QLineEdit, QDialogButtonBox
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
23 from E5Gui.E5Application import e5App
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
24 from E5Gui import E5MessageBox, E5FileDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
26 from .Ui_SvnDiffDialog import Ui_SvnDiffDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 import Utilities
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
29 import Preferences
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
31
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 class SvnDiffDialog(QWidget, Ui_SvnDiffDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
3009
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
34 Class implementing a dialog to show the output of the svn diff command
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
35 process.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
37 def __init__(self, vcs, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 @param vcs reference to the vcs object
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 @param parent parent widget (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
44 super(SvnDiffDialog, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
4052
17d8069de085 Added capability to search in the output of Diff dialogs of the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4037
diff changeset
50 self.searchWidget.attachTextEdit(self.contents)
17d8069de085 Added capability to search in the output of Diff dialogs of the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4037
diff changeset
51
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.process = QProcess()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.vcs = vcs
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
2580
7403bc14ea26 Changed the various diff dialogs to use the mono spaced font selected for the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
55 font = Preferences.getEditorOtherFonts("MonospacedFont")
7403bc14ea26 Changed the various diff dialogs to use the mono spaced font selected for the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
56 self.contents.setFontFamily(font.family())
7403bc14ea26 Changed the various diff dialogs to use the mono spaced font selected for the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
57 self.contents.setFontPointSize(font.pointSize())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.cNormalFormat = self.contents.currentCharFormat()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.cAddedFormat = self.contents.currentCharFormat()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.cAddedFormat.setBackground(QBrush(QColor(190, 237, 190)))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.cRemovedFormat = self.contents.currentCharFormat()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.cRemovedFormat.setBackground(QBrush(QColor(237, 190, 190)))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.cLineNoFormat = self.contents.currentCharFormat()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.cLineNoFormat.setBackground(QBrush(QColor(255, 220, 168)))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
464
a2b1d1770ef0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 425
diff changeset
67 self.process.finished.connect(self.__procFinished)
a2b1d1770ef0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 425
diff changeset
68 self.process.readyReadStandardOutput.connect(self.__readStdout)
470
99d8c50ba42f Fixed some bugs introduced by signal/slot API conversion.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 464
diff changeset
69 self.process.readyReadStandardError.connect(self.__readStderr)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 def closeEvent(self, e):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
73 Protected slot implementing a close event handler.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 @param e close event (QCloseEvent)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 if self.process is not None and \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.process.state() != QProcess.NotRunning:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.process.terminate()
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 470
diff changeset
80 QTimer.singleShot(2000, self.process.kill)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.process.waitForFinished(3000)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 e.accept()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 def __getVersionArg(self, version):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 Private method to get a svn revision argument for the given revision.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 @param version revision (integer or string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 @return version argument (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 if version == "WORKING":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 return None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 return str(version)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
97 def start(self, fn, versions=None, urls=None, summary=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 Public slot to start the svn diff command.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 @param fn filename to be diffed (string)
3009
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
102 @param versions list of versions to be diffed (list of up to 2 strings
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
103 or None)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 @keyparam urls list of repository URLs (list of 2 strings)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
105 @keyparam summary flag indicating a summarizing diff
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 (only valid for URL diffs) (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 self.errorGroup.hide()
1746
6c74208f22a2 Some little enhancements to the Subversion interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
109 self.inputGroup.show()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.intercept = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 self.filename = fn
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.process.kill()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 self.contents.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.paras = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
1503
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
118 self.filesCombo.clear()
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
119
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
120 self.__oldFile = ""
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
121 self.__oldFileLine = -1
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
122 self.__fileSeparators = []
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
123
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 args = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 args.append('diff')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 self.vcs.addArguments(args, self.vcs.options['global'])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 self.vcs.addArguments(args, self.vcs.options['diff'])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 if '--diff-cmd' in self.vcs.options['diff']:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 self.buttonBox.button(QDialogButtonBox.Save).hide()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 if versions is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 self.raise_()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 self.activateWindow()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 rev1 = self.__getVersionArg(versions[0])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 rev2 = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 if len(versions) == 2:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 rev2 = self.__getVersionArg(versions[1])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 if rev1 is not None or rev2 is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 args.append('-r')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 if rev1 is not None and rev2 is not None:
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 248
diff changeset
143 args.append('{0}:{1}'.format(rev1, rev2))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 elif rev2 is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 args.append(rev1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 elif rev1 is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 args.append(rev2)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.summaryPath = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 if urls is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 if summary:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 args.append("--summarize")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 self.summaryPath = urls[0]
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 248
diff changeset
154 args.append("--old={0}".format(urls[0]))
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 248
diff changeset
155 args.append("--new={0}".format(urls[1]))
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
156 if isinstance(fn, list):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 dname, fnames = self.vcs.splitPathList(fn)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 dname, fname = self.vcs.splitPath(fn)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 fnames = [fname]
248
f4561c24989a Changed code to better deal with project relative paths on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
161 project = e5App().getObject('Project')
f4561c24989a Changed code to better deal with project relative paths on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
162 if dname == project.getProjectPath():
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 path = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 else:
248
f4561c24989a Changed code to better deal with project relative paths on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
165 path = project.getRelativePath(dname)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 if path:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 path += "/"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 for fname in fnames:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 args.append(path + fname)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 else:
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
171 if isinstance(fn, list):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 dname, fnames = self.vcs.splitPathList(fn)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 self.vcs.addArguments(args, fnames)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 dname, fname = self.vcs.splitPath(fn)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 args.append(fname)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 self.process.setWorkingDirectory(dname)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 self.process.start('svn', args)
2771
281c9b30dd91 Changed all QProcess.waitForStarted() calls to use a 5s timeout (except the debugger interfaces, which have a 10s timeout).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2580
diff changeset
181 procStarted = self.process.waitForStarted(5000)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 if not procStarted:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 self.inputGroup.setEnabled(False)
1746
6c74208f22a2 Some little enhancements to the Subversion interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
184 self.inputGroup.hide()
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3009
diff changeset
185 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3009
diff changeset
186 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
187 self.tr('Process Generation Error'),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
188 self.tr(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 'The process {0} could not be started. '
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 'Ensure, that it is in the search path.'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 ).format('svn'))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 def __procFinished(self, exitCode, exitStatus):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 Private slot connected to the finished signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 @param exitCode exit code of the process (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 @param exitStatus exit status of the process (QProcess.ExitStatus)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 self.inputGroup.setEnabled(False)
1746
6c74208f22a2 Some little enhancements to the Subversion interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
201 self.inputGroup.hide()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 if self.paras == 0:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
204 self.contents.insertPlainText(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
205 self.tr('There is no difference.'))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(True)
1746
6c74208f22a2 Some little enhancements to the Subversion interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
209 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
3009
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
210 self.buttonBox.button(QDialogButtonBox.Close).setFocus(
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
211 Qt.OtherFocusReason)
1746
6c74208f22a2 Some little enhancements to the Subversion interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
212
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 tc = self.contents.textCursor()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 tc.movePosition(QTextCursor.Start)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 self.contents.setTextCursor(tc)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 self.contents.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
218 self.filesCombo.addItem(self.tr("<Start>"), 0)
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
219 self.filesCombo.addItem(self.tr("<End>"), -1)
1503
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
220 for oldFile, newFile, pos in sorted(self.__fileSeparators):
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
221 if oldFile != newFile:
3009
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
222 self.filesCombo.addItem(
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
223 "{0}\n{1}".format(oldFile, newFile), pos)
1503
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
224 else:
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
225 self.filesCombo.addItem(oldFile, pos)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
226
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 def __appendText(self, txt, format):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 Private method to append text to the end of the contents pane.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 @param txt text to insert (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 @param format text format to be used (QTextCharFormat)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 tc = self.contents.textCursor()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 tc.movePosition(QTextCursor.End)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 self.contents.setTextCursor(tc)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 self.contents.setCurrentCharFormat(format)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 self.contents.insertPlainText(txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239
1503
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
240 def __extractFileName(self, line):
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
241 """
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
242 Private method to extract the file name out of a file separator line.
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
243
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
244 @param line line to be processed (string)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
245 @return extracted file name (string)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
246 """
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
247 f = line.split(None, 1)[1]
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
248 f = f.rsplit(None, 2)[0]
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
249 return f
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
250
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
251 def __processFileLine(self, line):
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
252 """
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
253 Private slot to process a line giving the old/new file.
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
254
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
255 @param line line to be processed (string)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
256 """
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
257 if line.startswith('---'):
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
258 self.__oldFileLine = self.paras
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
259 self.__oldFile = self.__extractFileName(line)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
260 else:
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
261 self.__fileSeparators.append(
3009
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
262 (self.__oldFile, self.__extractFileName(line),
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
263 self.__oldFileLine))
1503
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
264
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 def __readStdout(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
267 Private slot to handle the readyReadStandardOutput signal.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 It reads the output of the process, formats it and inserts it into
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 the contents pane.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 self.process.setReadChannel(QProcess.StandardOutput)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 while self.process.canReadLine():
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
275 line = str(self.process.readLine(),
3037
a417a0670a36 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3025
diff changeset
276 Preferences.getSystem("IOEncoding"),
a417a0670a36 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3025
diff changeset
277 'replace')
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 if self.summaryPath:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 line = line.replace(self.summaryPath + '/', '')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 line = " ".join(line.split())
3037
a417a0670a36 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3025
diff changeset
281 if line.startswith("--- ") or line.startswith("+++ "):
1503
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
282 self.__processFileLine(line)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
283
3009
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
284 if line.startswith('+') or line.startswith('>') or \
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
285 line.startswith('A '):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 format = self.cAddedFormat
3009
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
287 elif line.startswith('-') or line.startswith('<') or \
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
288 line.startswith('D '):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 format = self.cRemovedFormat
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 elif line.startswith('@@'):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 format = self.cLineNoFormat
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 format = self.cNormalFormat
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 self.__appendText(line, format)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 self.paras += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 def __readStderr(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 Private slot to handle the readyReadStandardError signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 It reads the error output of the process and inserts it into the
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 error pane.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 if self.process is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 self.errorGroup.show()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
306 s = str(self.process.readAllStandardError(),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
307 Preferences.getSystem("IOEncoding"),
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
308 'replace')
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 self.errors.insertPlainText(s)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 self.errors.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 def on_buttonBox_clicked(self, button):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 Private slot called by a button of the button box clicked.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 @param button button that was clicked (QAbstractButton)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 if button == self.buttonBox.button(QDialogButtonBox.Save):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 self.on_saveButton_clicked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320
1503
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
321 @pyqtSlot(int)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
322 def on_filesCombo_activated(self, index):
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
323 """
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
324 Private slot to handle the selection of a file.
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
325
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
326 @param index activated row (integer)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
327 """
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
328 para = self.filesCombo.itemData(index)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
329
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
330 if para == 0:
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
331 tc = self.contents.textCursor()
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
332 tc.movePosition(QTextCursor.Start)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
333 self.contents.setTextCursor(tc)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
334 self.contents.ensureCursorVisible()
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
335 elif para == -1:
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
336 tc = self.contents.textCursor()
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
337 tc.movePosition(QTextCursor.End)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
338 self.contents.setTextCursor(tc)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
339 self.contents.ensureCursorVisible()
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
340 else:
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
341 # step 1: move cursor to end
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
342 tc = self.contents.textCursor()
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
343 tc.movePosition(QTextCursor.End)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
344 self.contents.setTextCursor(tc)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
345 self.contents.ensureCursorVisible()
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
346
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
347 # step 2: move cursor to desired line
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
348 tc = self.contents.textCursor()
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
349 delta = tc.blockNumber() - para
3009
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
350 tc.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor,
bf5ae5d7477d Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
351 delta)
1503
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
352 self.contents.setTextCursor(tc)
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
353 self.contents.ensureCursorVisible()
4e48604157a4 Added a file selector to the top of the diff dialogs to quickly jump to the diff for the selected file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1300
diff changeset
354
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 def on_saveButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 Private slot to handle the Save button press.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 It saves the diff shown in the dialog to a file in the local
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 filesystem.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 """
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
363 if isinstance(self.filename, list):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 if len(self.filename) > 1:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 fname = self.vcs.splitPathList(self.filename)[0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 dname, fname = self.vcs.splitPath(self.filename[0])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 if fname != '.':
425
ca5e65413fc5 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 248
diff changeset
369 fname = "{0}.diff".format(self.filename[0])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 fname = dname
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 fname = self.vcs.splitPath(self.filename)[0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
375 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
377 self.tr("Save Diff"),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 fname,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
379 self.tr("Patch Files (*.diff)"),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 None,
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
381 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 if not fname:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 return # user aborted
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 ext = QFileInfo(fname).suffix()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 if not ext:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 ex = selectedFilter.split("(*")[1].split(")")[0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 if ex:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 fname += ex
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 if QFileInfo(fname).exists():
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3009
diff changeset
392 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3009
diff changeset
393 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
394 self.tr("Save Diff"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
395 self.tr("<p>The patch file <b>{0}</b> already exists."
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
396 " Overwrite it?</p>").format(fname),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
397 icon=E5MessageBox.Warning)
546
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
398 if not res:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 fname = Utilities.toNativeSeparators(fname)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401
1297
6347cf782036 Fixed an issue in the various diff dialogs writing the patch.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
402 eol = e5App().getObject("Project").getEolString()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 try:
1300
9083f6b7ea3b Fixed an issue in the various diff dialogs writing the patch (this time properly).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1297
diff changeset
404 f = open(fname, "w", encoding="utf-8", newline="")
1297
6347cf782036 Fixed an issue in the various diff dialogs writing the patch.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
405 f.write(eol.join(self.contents.toPlainText().splitlines()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 f.close()
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
407 except IOError as why:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3009
diff changeset
408 E5MessageBox.critical(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
409 self, self.tr('Save Diff'),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
410 self.tr(
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
411 '<p>The patch file <b>{0}</b> could not be saved.'
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 '<br>Reason: {1}</p>')
3037
a417a0670a36 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3025
diff changeset
413 .format(fname, str(why)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 def on_passwordCheckBox_toggled(self, isOn):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 Private slot to handle the password checkbox toggled.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 @param isOn flag indicating the status of the check box (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 if isOn:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 self.input.setEchoMode(QLineEdit.Password)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 self.input.setEchoMode(QLineEdit.Normal)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 def on_sendButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 Private slot to send the input to the subversion process.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 input = self.input.text()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 input += os.linesep
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 if self.passwordCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 self.errors.insertPlainText(os.linesep)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 self.errors.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 self.errors.insertPlainText(input)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 self.errors.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 self.process.write(input)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 self.passwordCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 self.input.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 def on_input_returnPressed(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 Private slot to handle the press of the return key in the input field.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 self.intercept = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 self.on_sendButton_clicked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 def keyPressEvent(self, evt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 Protected slot to handle a key press event.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 @param evt the key press event (QKeyEvent)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 if self.intercept:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 self.intercept = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 evt.accept()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 return
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
463 super(SvnDiffDialog, self).keyPressEvent(evt)

eric ide

mercurial