Plugins/VcsPlugins/vcsMercurial/HgDiffDialog.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2791
a9577f248f04
parent 3008
7848489bcb92
child 3058
0a02c433f52d
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
28 import Preferences 28 import Preferences
29 29
30 30
31 class HgDiffDialog(QWidget, Ui_HgDiffDialog): 31 class HgDiffDialog(QWidget, Ui_HgDiffDialog):
32 """ 32 """
33 Class implementing a dialog to show the output of the hg diff command process. 33 Class implementing a dialog to show the output of the hg diff command
34 process.
34 """ 35 """
35 def __init__(self, vcs, parent=None): 36 def __init__(self, vcs, parent=None):
36 """ 37 """
37 Constructor 38 Constructor
38 39
98 def start(self, fn, versions=None, bundle=None, qdiff=False): 99 def start(self, fn, versions=None, bundle=None, qdiff=False):
99 """ 100 """
100 Public slot to start the hg diff command. 101 Public slot to start the hg diff command.
101 102
102 @param fn filename to be diffed (string) 103 @param fn filename to be diffed (string)
103 @param versions list of versions to be diffed (list of up to 2 strings or None) 104 @param versions list of versions to be diffed (list of up to 2 strings
105 or None)
104 @param bundle name of a bundle file (string) 106 @param bundle name of a bundle file (string)
105 @param qdiff flag indicating qdiff command shall be used (boolean) 107 @param qdiff flag indicating qdiff command shall be used (boolean)
106 """ 108 """
107 self.errorGroup.hide() 109 self.errorGroup.hide()
108 self.inputGroup.show() 110 self.inputGroup.show()
212 """ 214 """
213 self.__finish() 215 self.__finish()
214 216
215 def __finish(self): 217 def __finish(self):
216 """ 218 """
217 Private slot called when the process finished or the user pressed the button. 219 Private slot called when the process finished or the user pressed
220 the button.
218 """ 221 """
219 QApplication.restoreOverrideCursor() 222 QApplication.restoreOverrideCursor()
220 self.inputGroup.setEnabled(False) 223 self.inputGroup.setEnabled(False)
221 self.inputGroup.hide() 224 self.inputGroup.hide()
222 225
225 self.trUtf8('There is no difference.')) 228 self.trUtf8('There is no difference.'))
226 return 229 return
227 230
228 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(True) 231 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(True)
229 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 232 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
230 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason) 233 self.buttonBox.button(QDialogButtonBox.Close).setFocus(
234 Qt.OtherFocusReason)
231 235
232 tc = self.contents.textCursor() 236 tc = self.contents.textCursor()
233 tc.movePosition(QTextCursor.Start) 237 tc.movePosition(QTextCursor.Start)
234 self.contents.setTextCursor(tc) 238 self.contents.setTextCursor(tc)
235 self.contents.ensureCursorVisible() 239 self.contents.ensureCursorVisible()
236 240
237 self.filesCombo.addItem(self.trUtf8("<Start>"), 0) 241 self.filesCombo.addItem(self.trUtf8("<Start>"), 0)
238 self.filesCombo.addItem(self.trUtf8("<End>"), -1) 242 self.filesCombo.addItem(self.trUtf8("<End>"), -1)
239 for oldFile, newFile, pos in sorted(self.__fileSeparators): 243 for oldFile, newFile, pos in sorted(self.__fileSeparators):
240 if oldFile != newFile: 244 if oldFile != newFile:
241 self.filesCombo.addItem("{0}\n{1}".format(oldFile, newFile), pos) 245 self.filesCombo.addItem(
246 "{0}\n{1}".format(oldFile, newFile), pos)
242 else: 247 else:
243 self.filesCombo.addItem(oldFile, pos) 248 self.filesCombo.addItem(oldFile, pos)
244 249
245 def __appendText(self, txt, format): 250 def __appendText(self, txt, format):
246 """ 251 """
276 if line.startswith('---'): 281 if line.startswith('---'):
277 self.__oldFileLine = self.paras 282 self.__oldFileLine = self.paras
278 self.__oldFile = self.__extractFileName(line) 283 self.__oldFile = self.__extractFileName(line)
279 else: 284 else:
280 self.__fileSeparators.append( 285 self.__fileSeparators.append(
281 (self.__oldFile, self.__extractFileName(line), self.__oldFileLine)) 286 (self.__oldFile, self.__extractFileName(line),
287 self.__oldFileLine))
282 288
283 def __processOutputLine(self, line): 289 def __processOutputLine(self, line):
284 """ 290 """
285 Private method to process the lines of output. 291 Private method to process the lines of output.
286 292
375 self.contents.ensureCursorVisible() 381 self.contents.ensureCursorVisible()
376 382
377 # step 2: move cursor to desired line 383 # step 2: move cursor to desired line
378 tc = self.contents.textCursor() 384 tc = self.contents.textCursor()
379 delta = tc.blockNumber() - para 385 delta = tc.blockNumber() - para
380 tc.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor, delta) 386 tc.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor,
387 delta)
381 self.contents.setTextCursor(tc) 388 self.contents.setTextCursor(tc)
382 self.contents.ensureCursorVisible() 389 self.contents.ensureCursorVisible()
383 390
384 @pyqtSlot() 391 @pyqtSlot()
385 def on_saveButton_clicked(self): 392 def on_saveButton_clicked(self):

eric ide

mercurial