Plugins/VcsPlugins/vcsSubversion/SvnDiffDialog.py

changeset 3009
bf5ae5d7477d
parent 2771
281c9b30dd91
child 3020
542e97d4ecb3
child 3057
10516539f238
equal deleted inserted replaced
3008:7848489bcb92 3009:bf5ae5d7477d
2 2
3 # Copyright (c) 2003 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2003 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Module implementing a dialog to show the output of the svn diff command process. 7 Module implementing a dialog to show the output of the svn diff command
8 process.
8 """ 9 """
9 10
10 import os 11 import os
11 12
12 from PyQt4.QtCore import QTimer, QFileInfo, QProcess, pyqtSlot, Qt 13 from PyQt4.QtCore import QTimer, QFileInfo, QProcess, pyqtSlot, Qt
13 from PyQt4.QtGui import QWidget, QColor, QLineEdit, QBrush, QTextCursor, QDialogButtonBox 14 from PyQt4.QtGui import QWidget, QColor, QLineEdit, QBrush, QTextCursor, \
15 QDialogButtonBox
14 16
15 from E5Gui.E5Application import e5App 17 from E5Gui.E5Application import e5App
16 from E5Gui import E5MessageBox, E5FileDialog 18 from E5Gui import E5MessageBox, E5FileDialog
17 19
18 from .Ui_SvnDiffDialog import Ui_SvnDiffDialog 20 from .Ui_SvnDiffDialog import Ui_SvnDiffDialog
21 import Preferences 23 import Preferences
22 24
23 25
24 class SvnDiffDialog(QWidget, Ui_SvnDiffDialog): 26 class SvnDiffDialog(QWidget, Ui_SvnDiffDialog):
25 """ 27 """
26 Class implementing a dialog to show the output of the svn diff command process. 28 Class implementing a dialog to show the output of the svn diff command
29 process.
27 """ 30 """
28 def __init__(self, vcs, parent=None): 31 def __init__(self, vcs, parent=None):
29 """ 32 """
30 Constructor 33 Constructor
31 34
86 def start(self, fn, versions=None, urls=None, summary=False): 89 def start(self, fn, versions=None, urls=None, summary=False):
87 """ 90 """
88 Public slot to start the svn diff command. 91 Public slot to start the svn diff command.
89 92
90 @param fn filename to be diffed (string) 93 @param fn filename to be diffed (string)
91 @param versions list of versions to be diffed (list of up to 2 strings or None) 94 @param versions list of versions to be diffed (list of up to 2 strings
95 or None)
92 @keyparam urls list of repository URLs (list of 2 strings) 96 @keyparam urls list of repository URLs (list of 2 strings)
93 @keyparam summary flag indicating a summarizing diff 97 @keyparam summary flag indicating a summarizing diff
94 (only valid for URL diffs) (boolean) 98 (only valid for URL diffs) (boolean)
95 """ 99 """
96 self.errorGroup.hide() 100 self.errorGroup.hide()
192 self.trUtf8('There is no difference.')) 196 self.trUtf8('There is no difference.'))
193 return 197 return
194 198
195 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(True) 199 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(True)
196 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 200 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
197 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason) 201 self.buttonBox.button(QDialogButtonBox.Close).setFocus(
202 Qt.OtherFocusReason)
198 203
199 tc = self.contents.textCursor() 204 tc = self.contents.textCursor()
200 tc.movePosition(QTextCursor.Start) 205 tc.movePosition(QTextCursor.Start)
201 self.contents.setTextCursor(tc) 206 self.contents.setTextCursor(tc)
202 self.contents.ensureCursorVisible() 207 self.contents.ensureCursorVisible()
203 208
204 self.filesCombo.addItem(self.trUtf8("<Start>"), 0) 209 self.filesCombo.addItem(self.trUtf8("<Start>"), 0)
205 self.filesCombo.addItem(self.trUtf8("<End>"), -1) 210 self.filesCombo.addItem(self.trUtf8("<End>"), -1)
206 for oldFile, newFile, pos in sorted(self.__fileSeparators): 211 for oldFile, newFile, pos in sorted(self.__fileSeparators):
207 if oldFile != newFile: 212 if oldFile != newFile:
208 self.filesCombo.addItem("{0}\n{1}".format(oldFile, newFile), pos) 213 self.filesCombo.addItem(
214 "{0}\n{1}".format(oldFile, newFile), pos)
209 else: 215 else:
210 self.filesCombo.addItem(oldFile, pos) 216 self.filesCombo.addItem(oldFile, pos)
211 217
212 def __appendText(self, txt, format): 218 def __appendText(self, txt, format):
213 """ 219 """
242 if line.startswith('---'): 248 if line.startswith('---'):
243 self.__oldFileLine = self.paras 249 self.__oldFileLine = self.paras
244 self.__oldFile = self.__extractFileName(line) 250 self.__oldFile = self.__extractFileName(line)
245 else: 251 else:
246 self.__fileSeparators.append( 252 self.__fileSeparators.append(
247 (self.__oldFile, self.__extractFileName(line), self.__oldFileLine)) 253 (self.__oldFile, self.__extractFileName(line),
254 self.__oldFileLine))
248 255
249 def __readStdout(self): 256 def __readStdout(self):
250 """ 257 """
251 Private slot to handle the readyReadStandardOutput signal. 258 Private slot to handle the readyReadStandardOutput signal.
252 259
264 line = " ".join(line.split()) 271 line = " ".join(line.split())
265 if line.startswith("--- ") or \ 272 if line.startswith("--- ") or \
266 line.startswith("+++ "): 273 line.startswith("+++ "):
267 self.__processFileLine(line) 274 self.__processFileLine(line)
268 275
269 if line.startswith('+') or line.startswith('>') or line.startswith('A '): 276 if line.startswith('+') or line.startswith('>') or \
277 line.startswith('A '):
270 format = self.cAddedFormat 278 format = self.cAddedFormat
271 elif line.startswith('-') or line.startswith('<') or line.startswith('D '): 279 elif line.startswith('-') or line.startswith('<') or \
280 line.startswith('D '):
272 format = self.cRemovedFormat 281 format = self.cRemovedFormat
273 elif line.startswith('@@'): 282 elif line.startswith('@@'):
274 format = self.cLineNoFormat 283 format = self.cLineNoFormat
275 else: 284 else:
276 format = self.cNormalFormat 285 format = self.cNormalFormat
328 self.contents.ensureCursorVisible() 337 self.contents.ensureCursorVisible()
329 338
330 # step 2: move cursor to desired line 339 # step 2: move cursor to desired line
331 tc = self.contents.textCursor() 340 tc = self.contents.textCursor()
332 delta = tc.blockNumber() - para 341 delta = tc.blockNumber() - para
333 tc.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor, delta) 342 tc.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor,
343 delta)
334 self.contents.setTextCursor(tc) 344 self.contents.setTextCursor(tc)
335 self.contents.ensureCursorVisible() 345 self.contents.ensureCursorVisible()
336 346
337 @pyqtSlot() 347 @pyqtSlot()
338 def on_saveButton_clicked(self): 348 def on_saveButton_clicked(self):

eric ide

mercurial