src/eric7/Plugins/VcsPlugins/vcsMercurial/HgStatusDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
11 import os 11 import os
12 12
13 from PyQt6.QtCore import pyqtSlot, Qt, QSize 13 from PyQt6.QtCore import pyqtSlot, Qt, QSize
14 from PyQt6.QtGui import QTextCursor 14 from PyQt6.QtGui import QTextCursor
15 from PyQt6.QtWidgets import ( 15 from PyQt6.QtWidgets import (
16 QWidget, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem 16 QWidget,
17 QDialogButtonBox,
18 QMenu,
19 QHeaderView,
20 QTreeWidgetItem,
17 ) 21 )
18 22
19 from EricWidgets.EricApplication import ericApp 23 from EricWidgets.EricApplication import ericApp
20 from EricWidgets import EricMessageBox 24 from EricWidgets import EricMessageBox
21 25
31 class HgStatusDialog(QWidget, Ui_HgStatusDialog): 35 class HgStatusDialog(QWidget, Ui_HgStatusDialog):
32 """ 36 """
33 Class implementing a dialog to show the output of the hg status command 37 Class implementing a dialog to show the output of the hg status command
34 process. 38 process.
35 """ 39 """
40
36 def __init__(self, vcs, mq=False, parent=None): 41 def __init__(self, vcs, mq=False, parent=None):
37 """ 42 """
38 Constructor 43 Constructor
39 44
40 @param vcs reference to the vcs object 45 @param vcs reference to the vcs object
41 @param mq flag indicating to show a queue repo status (boolean) 46 @param mq flag indicating to show a queue repo status (boolean)
42 @param parent parent widget (QWidget) 47 @param parent parent widget (QWidget)
43 """ 48 """
44 super().__init__(parent) 49 super().__init__(parent)
45 self.setupUi(self) 50 self.setupUi(self)
46 51
47 self.__toBeCommittedColumn = 0 52 self.__toBeCommittedColumn = 0
48 self.__statusColumn = 1 53 self.__statusColumn = 1
49 self.__pathColumn = 2 54 self.__pathColumn = 2
50 self.__lastColumn = self.statusList.columnCount() 55 self.__lastColumn = self.statusList.columnCount()
51 56
52 self.refreshButton = self.buttonBox.addButton( 57 self.refreshButton = self.buttonBox.addButton(
53 self.tr("Refresh"), QDialogButtonBox.ButtonRole.ActionRole) 58 self.tr("Refresh"), QDialogButtonBox.ButtonRole.ActionRole
54 self.refreshButton.setToolTip( 59 )
55 self.tr("Press to refresh the status display")) 60 self.refreshButton.setToolTip(self.tr("Press to refresh the status display"))
56 self.refreshButton.setEnabled(False) 61 self.refreshButton.setEnabled(False)
57 self.buttonBox.button( 62 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False)
58 QDialogButtonBox.StandardButton.Close).setEnabled(False) 63 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True)
59 self.buttonBox.button( 64
60 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
61
62 self.diff = None 65 self.diff = None
63 self.vcs = vcs 66 self.vcs = vcs
64 self.vcs.committed.connect(self.__committed) 67 self.vcs.committed.connect(self.__committed)
65 self.__hgClient = self.vcs.getClient() 68 self.__hgClient = self.vcs.getClient()
66 self.__mq = mq 69 self.__mq = mq
67 70
68 self.statusList.headerItem().setText(self.__lastColumn, "") 71 self.statusList.headerItem().setText(self.__lastColumn, "")
69 self.statusList.header().setSortIndicator( 72 self.statusList.header().setSortIndicator(
70 self.__pathColumn, Qt.SortOrder.AscendingOrder) 73 self.__pathColumn, Qt.SortOrder.AscendingOrder
71 74 )
75
72 font = Preferences.getEditorOtherFonts("MonospacedFont") 76 font = Preferences.getEditorOtherFonts("MonospacedFont")
73 self.diffEdit.document().setDefaultFont(font) 77 self.diffEdit.document().setDefaultFont(font)
74 78
75 self.diffHighlighter = HgDiffHighlighter(self.diffEdit.document()) 79 self.diffHighlighter = HgDiffHighlighter(self.diffEdit.document())
76 self.__diffGenerator = HgDiffGenerator(vcs, self) 80 self.__diffGenerator = HgDiffGenerator(vcs, self)
77 self.__diffGenerator.finished.connect(self.__generatorFinished) 81 self.__diffGenerator.finished.connect(self.__generatorFinished)
78 82
79 self.__selectedName = "" 83 self.__selectedName = ""
80 84
81 self.modifiedIndicators = [ 85 self.modifiedIndicators = [
82 self.tr('added'), 86 self.tr("added"),
83 self.tr('modified'), 87 self.tr("modified"),
84 self.tr('removed'), 88 self.tr("removed"),
85 ] 89 ]
86 90
87 self.unversionedIndicators = [ 91 self.unversionedIndicators = [
88 self.tr('not tracked'), 92 self.tr("not tracked"),
89 ] 93 ]
90 94
91 self.missingIndicators = [ 95 self.missingIndicators = [self.tr("missing")]
92 self.tr('missing') 96
93 ]
94
95 self.status = { 97 self.status = {
96 'A': self.tr('added'), 98 "A": self.tr("added"),
97 'C': self.tr('normal'), 99 "C": self.tr("normal"),
98 'I': self.tr('ignored'), 100 "I": self.tr("ignored"),
99 'M': self.tr('modified'), 101 "M": self.tr("modified"),
100 'R': self.tr('removed'), 102 "R": self.tr("removed"),
101 '?': self.tr('not tracked'), 103 "?": self.tr("not tracked"),
102 '!': self.tr('missing'), 104 "!": self.tr("missing"),
103 } 105 }
104 106
105 self.__initActionsMenu() 107 self.__initActionsMenu()
106 108
107 if mq: 109 if mq:
108 self.diffLabel.setVisible(False) 110 self.diffLabel.setVisible(False)
109 self.diffEdit.setVisible(False) 111 self.diffEdit.setVisible(False)
110 self.actionsButton.setEnabled(False) 112 self.actionsButton.setEnabled(False)
111 self.diffSplitter.setSizes([600, 0]) 113 self.diffSplitter.setSizes([600, 0])
112 else: 114 else:
113 self.diffSplitter.setSizes([300, 300]) 115 self.diffSplitter.setSizes([300, 300])
114 116
115 def __initActionsMenu(self): 117 def __initActionsMenu(self):
116 """ 118 """
117 Private method to initialize the actions menu. 119 Private method to initialize the actions menu.
118 """ 120 """
119 self.__actionsMenu = QMenu() 121 self.__actionsMenu = QMenu()
120 self.__actionsMenu.setTearOffEnabled(True) 122 self.__actionsMenu.setTearOffEnabled(True)
121 self.__actionsMenu.setToolTipsVisible(True) 123 self.__actionsMenu.setToolTipsVisible(True)
122 self.__actionsMenu.aboutToShow.connect(self.__showActionsMenu) 124 self.__actionsMenu.aboutToShow.connect(self.__showActionsMenu)
123 125
124 self.__commitAct = self.__actionsMenu.addAction( 126 self.__commitAct = self.__actionsMenu.addAction(
125 self.tr("Commit"), self.__commit) 127 self.tr("Commit"), self.__commit
128 )
126 self.__commitAct.setToolTip(self.tr("Commit the selected changes")) 129 self.__commitAct.setToolTip(self.tr("Commit the selected changes"))
127 self.__commitSelectAct = self.__actionsMenu.addAction( 130 self.__commitSelectAct = self.__actionsMenu.addAction(
128 self.tr("Select all for commit"), self.__commitSelectAll) 131 self.tr("Select all for commit"), self.__commitSelectAll
132 )
129 self.__commitDeselectAct = self.__actionsMenu.addAction( 133 self.__commitDeselectAct = self.__actionsMenu.addAction(
130 self.tr("Unselect all from commit"), self.__commitDeselectAll) 134 self.tr("Unselect all from commit"), self.__commitDeselectAll
131 135 )
136
132 self.__actionsMenu.addSeparator() 137 self.__actionsMenu.addSeparator()
133 138
134 self.__addAct = self.__actionsMenu.addAction( 139 self.__addAct = self.__actionsMenu.addAction(self.tr("Add"), self.__add)
135 self.tr("Add"), self.__add)
136 self.__addAct.setToolTip(self.tr("Add the selected files")) 140 self.__addAct.setToolTip(self.tr("Add the selected files"))
137 self.__lfAddLargeAct = self.__actionsMenu.addAction( 141 self.__lfAddLargeAct = self.__actionsMenu.addAction(
138 self.tr("Add as Large Files"), lambda: self.__lfAdd("large")) 142 self.tr("Add as Large Files"), lambda: self.__lfAdd("large")
139 self.__lfAddLargeAct.setToolTip(self.tr( 143 )
140 "Add the selected files as a large files using the 'Large Files'" 144 self.__lfAddLargeAct.setToolTip(
141 " extension")) 145 self.tr(
146 "Add the selected files as a large files using the 'Large Files'"
147 " extension"
148 )
149 )
142 self.__lfAddNormalAct = self.__actionsMenu.addAction( 150 self.__lfAddNormalAct = self.__actionsMenu.addAction(
143 self.tr("Add as Normal Files"), lambda: self.__lfAdd("normal")) 151 self.tr("Add as Normal Files"), lambda: self.__lfAdd("normal")
144 self.__lfAddNormalAct.setToolTip(self.tr( 152 )
145 "Add the selected files as a normal files using the 'Large Files'" 153 self.__lfAddNormalAct.setToolTip(
146 " extension")) 154 self.tr(
147 155 "Add the selected files as a normal files using the 'Large Files'"
156 " extension"
157 )
158 )
159
148 self.__actionsMenu.addSeparator() 160 self.__actionsMenu.addSeparator()
149 161
150 self.__diffAct = self.__actionsMenu.addAction( 162 self.__diffAct = self.__actionsMenu.addAction(
151 self.tr("Differences"), self.__diff) 163 self.tr("Differences"), self.__diff
152 self.__diffAct.setToolTip(self.tr( 164 )
153 "Shows the differences of the selected entry in a" 165 self.__diffAct.setToolTip(
154 " separate dialog")) 166 self.tr(
167 "Shows the differences of the selected entry in a" " separate dialog"
168 )
169 )
155 self.__sbsDiffAct = self.__actionsMenu.addAction( 170 self.__sbsDiffAct = self.__actionsMenu.addAction(
156 self.tr("Differences Side-By-Side"), self.__sbsDiff) 171 self.tr("Differences Side-By-Side"), self.__sbsDiff
157 self.__sbsDiffAct.setToolTip(self.tr( 172 )
158 "Shows the differences of the selected entry side-by-side in" 173 self.__sbsDiffAct.setToolTip(
159 " a separate dialog")) 174 self.tr(
160 175 "Shows the differences of the selected entry side-by-side in"
176 " a separate dialog"
177 )
178 )
179
161 self.__actionsMenu.addSeparator() 180 self.__actionsMenu.addSeparator()
162 181
163 self.__revertAct = self.__actionsMenu.addAction( 182 self.__revertAct = self.__actionsMenu.addAction(
164 self.tr("Revert"), self.__revert) 183 self.tr("Revert"), self.__revert
165 self.__revertAct.setToolTip(self.tr( 184 )
166 "Reverts the changes of the selected files")) 185 self.__revertAct.setToolTip(
167 186 self.tr("Reverts the changes of the selected files")
187 )
188
168 self.__actionsMenu.addSeparator() 189 self.__actionsMenu.addSeparator()
169 190
170 self.__forgetAct = self.__actionsMenu.addAction( 191 self.__forgetAct = self.__actionsMenu.addAction(
171 self.tr("Forget Missing"), self.__forget) 192 self.tr("Forget Missing"), self.__forget
172 self.__forgetAct.setToolTip(self.tr( 193 )
173 "Forgets about the selected missing files")) 194 self.__forgetAct.setToolTip(self.tr("Forgets about the selected missing files"))
174 self.__restoreAct = self.__actionsMenu.addAction( 195 self.__restoreAct = self.__actionsMenu.addAction(
175 self.tr("Restore Missing"), self.__restoreMissing) 196 self.tr("Restore Missing"), self.__restoreMissing
176 self.__restoreAct.setToolTip(self.tr( 197 )
177 "Restores the selected missing files")) 198 self.__restoreAct.setToolTip(self.tr("Restores the selected missing files"))
178 199
179 self.__actionsMenu.addSeparator() 200 self.__actionsMenu.addSeparator()
180 201
181 self.__commitMergeAct = self.__actionsMenu.addAction( 202 self.__commitMergeAct = self.__actionsMenu.addAction(
182 self.tr("Commit Merge"), self.__commitMerge) 203 self.tr("Commit Merge"), self.__commitMerge
183 self.__commitMergeAct.setToolTip(self.tr("Commit all the merged" 204 )
184 " changes.")) 205 self.__commitMergeAct.setToolTip(self.tr("Commit all the merged" " changes."))
185 self.__abortMergeAct = self.__actionsMenu.addAction( 206 self.__abortMergeAct = self.__actionsMenu.addAction(
186 self.tr("Abort Merge"), self.__abortMerge) 207 self.tr("Abort Merge"), self.__abortMerge
187 self.__commitMergeAct.setToolTip(self.tr("Abort an uncommitted merge " 208 )
188 "and lose all changes")) 209 self.__commitMergeAct.setToolTip(
210 self.tr("Abort an uncommitted merge " "and lose all changes")
211 )
189 212
190 self.__actionsMenu.addSeparator() 213 self.__actionsMenu.addSeparator()
191 214
192 act = self.__actionsMenu.addAction( 215 act = self.__actionsMenu.addAction(
193 self.tr("Adjust column sizes"), self.__resizeColumns) 216 self.tr("Adjust column sizes"), self.__resizeColumns
194 act.setToolTip(self.tr( 217 )
195 "Adjusts the width of all columns to their contents")) 218 act.setToolTip(self.tr("Adjusts the width of all columns to their contents"))
196 219
197 self.actionsButton.setIcon( 220 self.actionsButton.setIcon(UI.PixmapCache.getIcon("actionsToolButton"))
198 UI.PixmapCache.getIcon("actionsToolButton"))
199 self.actionsButton.setMenu(self.__actionsMenu) 221 self.actionsButton.setMenu(self.__actionsMenu)
200 222
201 def closeEvent(self, e): 223 def closeEvent(self, e):
202 """ 224 """
203 Protected slot implementing a close event handler. 225 Protected slot implementing a close event handler.
204 226
205 @param e close event (QCloseEvent) 227 @param e close event (QCloseEvent)
206 """ 228 """
207 if self.__hgClient.isExecuting(): 229 if self.__hgClient.isExecuting():
208 self.__hgClient.cancel() 230 self.__hgClient.cancel()
209 231
210 if self.__mq: 232 if self.__mq:
211 self.vcs.getPlugin().setPreferences( 233 self.vcs.getPlugin().setPreferences(
212 "MqStatusDialogGeometry", self.saveGeometry()) 234 "MqStatusDialogGeometry", self.saveGeometry()
235 )
213 self.vcs.getPlugin().setPreferences( 236 self.vcs.getPlugin().setPreferences(
214 "MqStatusDialogSplitterState", self.diffSplitter.saveState()) 237 "MqStatusDialogSplitterState", self.diffSplitter.saveState()
238 )
215 else: 239 else:
216 self.vcs.getPlugin().setPreferences( 240 self.vcs.getPlugin().setPreferences(
217 "StatusDialogGeometry", self.saveGeometry()) 241 "StatusDialogGeometry", self.saveGeometry()
242 )
218 self.vcs.getPlugin().setPreferences( 243 self.vcs.getPlugin().setPreferences(
219 "StatusDialogSplitterState", self.diffSplitter.saveState()) 244 "StatusDialogSplitterState", self.diffSplitter.saveState()
220 245 )
246
221 e.accept() 247 e.accept()
222 248
223 def show(self): 249 def show(self):
224 """ 250 """
225 Public slot to show the dialog. 251 Public slot to show the dialog.
226 """ 252 """
227 super().show() 253 super().show()
228 254
229 geom = ( 255 geom = (
230 self.vcs.getPlugin().getPreferences("MqStatusDialogGeometry") 256 self.vcs.getPlugin().getPreferences("MqStatusDialogGeometry")
231 if self.__mq else 257 if self.__mq
232 self.vcs.getPlugin().getPreferences("StatusDialogGeometry") 258 else self.vcs.getPlugin().getPreferences("StatusDialogGeometry")
233 ) 259 )
234 if geom.isEmpty(): 260 if geom.isEmpty():
235 s = QSize(800, 600) 261 s = QSize(800, 600)
236 self.resize(s) 262 self.resize(s)
237 else: 263 else:
238 self.restoreGeometry(geom) 264 self.restoreGeometry(geom)
239 265
240 diffSplitterState = ( 266 diffSplitterState = (
241 self.vcs.getPlugin().getPreferences("MqStatusDialogSplitterState") 267 self.vcs.getPlugin().getPreferences("MqStatusDialogSplitterState")
242 if self.__mq else 268 if self.__mq
243 self.vcs.getPlugin().getPreferences("StatusDialogSplitterState") 269 else self.vcs.getPlugin().getPreferences("StatusDialogSplitterState")
244 ) 270 )
245 if diffSplitterState is not None: 271 if diffSplitterState is not None:
246 self.diffSplitter.restoreState(diffSplitterState) 272 self.diffSplitter.restoreState(diffSplitterState)
247 273
248 def __resort(self): 274 def __resort(self):
249 """ 275 """
250 Private method to resort the tree. 276 Private method to resort the tree.
251 """ 277 """
252 self.statusList.sortItems( 278 self.statusList.sortItems(
253 self.statusList.sortColumn(), 279 self.statusList.sortColumn(), self.statusList.header().sortIndicatorOrder()
254 self.statusList.header().sortIndicatorOrder()) 280 )
255 281
256 def __resizeColumns(self): 282 def __resizeColumns(self):
257 """ 283 """
258 Private method to resize the list columns. 284 Private method to resize the list columns.
259 """ 285 """
260 self.statusList.header().resizeSections( 286 self.statusList.header().resizeSections(QHeaderView.ResizeMode.ResizeToContents)
261 QHeaderView.ResizeMode.ResizeToContents)
262 self.statusList.header().setStretchLastSection(True) 287 self.statusList.header().setStretchLastSection(True)
263 288
264 def __generateItem(self, status, path): 289 def __generateItem(self, status, path):
265 """ 290 """
266 Private method to generate a status item in the status list. 291 Private method to generate a status item in the status list.
267 292
268 @param status status indicator (string) 293 @param status status indicator (string)
269 @param path path of the file or directory (string) 294 @param path path of the file or directory (string)
270 """ 295 """
271 statusText = self.status[status] 296 statusText = self.status[status]
272 itm = QTreeWidgetItem(self.statusList, [ 297 itm = QTreeWidgetItem(
273 "", 298 self.statusList,
274 statusText, 299 [
275 path, 300 "",
276 ]) 301 statusText,
277 302 path,
303 ],
304 )
305
278 itm.setTextAlignment(1, Qt.AlignmentFlag.AlignHCenter) 306 itm.setTextAlignment(1, Qt.AlignmentFlag.AlignHCenter)
279 itm.setTextAlignment(2, Qt.AlignmentFlag.AlignLeft) 307 itm.setTextAlignment(2, Qt.AlignmentFlag.AlignLeft)
280 308
281 if status in "AMR": 309 if status in "AMR":
282 itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable) 310 itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable)
283 itm.setCheckState(self.__toBeCommittedColumn, 311 itm.setCheckState(self.__toBeCommittedColumn, Qt.CheckState.Checked)
284 Qt.CheckState.Checked)
285 else: 312 else:
286 itm.setFlags(itm.flags() & ~Qt.ItemFlag.ItemIsUserCheckable) 313 itm.setFlags(itm.flags() & ~Qt.ItemFlag.ItemIsUserCheckable)
287 314
288 if statusText not in self.__statusFilters: 315 if statusText not in self.__statusFilters:
289 self.__statusFilters.append(statusText) 316 self.__statusFilters.append(statusText)
290 317
291 def start(self, fn): 318 def start(self, fn):
292 """ 319 """
293 Public slot to start the hg status command. 320 Public slot to start the hg status command.
294 321
295 @param fn filename(s)/directoryname(s) to show the status of 322 @param fn filename(s)/directoryname(s) to show the status of
296 (string or list of strings) 323 (string or list of strings)
297 """ 324 """
298 self.errorGroup.hide() 325 self.errorGroup.hide()
299 self.intercept = False 326 self.intercept = False
300 self.args = fn 327 self.args = fn
301 328
302 self.actionsButton.setEnabled(False) 329 self.actionsButton.setEnabled(False)
303 330
304 self.statusFilterCombo.clear() 331 self.statusFilterCombo.clear()
305 self.__statusFilters = [] 332 self.__statusFilters = []
306 self.statusList.clear() 333 self.statusList.clear()
307 334
308 if self.__mq: 335 if self.__mq:
309 self.setWindowTitle( 336 self.setWindowTitle(self.tr("Mercurial Queue Repository Status"))
310 self.tr("Mercurial Queue Repository Status")) 337 else:
311 else: 338 self.setWindowTitle(self.tr("Mercurial Status"))
312 self.setWindowTitle(self.tr('Mercurial Status')) 339
313
314 args = self.vcs.initCommand("status") 340 args = self.vcs.initCommand("status")
315 if self.__mq: 341 if self.__mq:
316 args.append('--mq') 342 args.append("--mq")
317 else: 343 else:
318 if self.vcs.hasSubrepositories(): 344 if self.vcs.hasSubrepositories():
319 args.append("--subrepos") 345 args.append("--subrepos")
320 346
321 if isinstance(fn, list): 347 if isinstance(fn, list):
322 self.vcs.addArguments(args, fn) 348 self.vcs.addArguments(args, fn)
323 else: 349 else:
324 args.append(fn) 350 args.append(fn)
325 351
326 self.refreshButton.setEnabled(False) 352 self.refreshButton.setEnabled(False)
327 353
328 self.__repoPath = self.__hgClient.getRepository() 354 self.__repoPath = self.__hgClient.getRepository()
329 355
330 out, err = self.__hgClient.runcommand(args) 356 out, err = self.__hgClient.runcommand(args)
331 if err: 357 if err:
332 self.__showError(err) 358 self.__showError(err)
333 if out: 359 if out:
334 for line in out.splitlines(): 360 for line in out.splitlines():
335 self.__processOutputLine(line) 361 self.__processOutputLine(line)
336 if self.__hgClient.wasCanceled(): 362 if self.__hgClient.wasCanceled():
337 break 363 break
338 self.__finish() 364 self.__finish()
339 365
340 def __finish(self): 366 def __finish(self):
341 """ 367 """
342 Private slot called when the process finished or the user pressed 368 Private slot called when the process finished or the user pressed
343 the button. 369 the button.
344 """ 370 """
345 self.refreshButton.setEnabled(True) 371 self.refreshButton.setEnabled(True)
346 372
347 self.buttonBox.button( 373 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True)
348 QDialogButtonBox.StandardButton.Close).setEnabled(True) 374 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
349 self.buttonBox.button( 375 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True)
350 QDialogButtonBox.StandardButton.Cancel).setEnabled(False) 376 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setFocus(
351 self.buttonBox.button( 377 Qt.FocusReason.OtherFocusReason
352 QDialogButtonBox.StandardButton.Close).setDefault(True) 378 )
353 self.buttonBox.button( 379
354 QDialogButtonBox.StandardButton.Close).setFocus(
355 Qt.FocusReason.OtherFocusReason)
356
357 self.__statusFilters.sort() 380 self.__statusFilters.sort()
358 self.__statusFilters.insert(0, "<{0}>".format(self.tr("all"))) 381 self.__statusFilters.insert(0, "<{0}>".format(self.tr("all")))
359 self.statusFilterCombo.addItems(self.__statusFilters) 382 self.statusFilterCombo.addItems(self.__statusFilters)
360 383
361 if not self.__mq: 384 if not self.__mq:
362 self.actionsButton.setEnabled(True) 385 self.actionsButton.setEnabled(True)
363 386
364 self.__resort() 387 self.__resort()
365 self.__resizeColumns() 388 self.__resizeColumns()
366 389
367 self.__refreshDiff() 390 self.__refreshDiff()
368 391
369 def on_buttonBox_clicked(self, button): 392 def on_buttonBox_clicked(self, button):
370 """ 393 """
371 Private slot called by a button of the button box clicked. 394 Private slot called by a button of the button box clicked.
372 395
373 @param button button that was clicked (QAbstractButton) 396 @param button button that was clicked (QAbstractButton)
374 """ 397 """
375 if button == self.buttonBox.button( 398 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close):
376 QDialogButtonBox.StandardButton.Close
377 ):
378 self.close() 399 self.close()
379 elif button == self.buttonBox.button( 400 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel):
380 QDialogButtonBox.StandardButton.Cancel
381 ):
382 self.__hgClient.cancel() 401 self.__hgClient.cancel()
383 elif button == self.refreshButton: 402 elif button == self.refreshButton:
384 self.on_refreshButton_clicked() 403 self.on_refreshButton_clicked()
385 404
386 def __processOutputLine(self, line): 405 def __processOutputLine(self, line):
387 """ 406 """
388 Private method to process the lines of output. 407 Private method to process the lines of output.
389 408
390 @param line output line to be processed (string) 409 @param line output line to be processed (string)
391 """ 410 """
392 if line[0] in "ACIMR?!" and line[1] == " ": 411 if line[0] in "ACIMR?!" and line[1] == " ":
393 status, path = line.strip().split(" ", 1) 412 status, path = line.strip().split(" ", 1)
394 self.__generateItem(status, path) 413 self.__generateItem(status, path)
395 414
396 def __showError(self, out): 415 def __showError(self, out):
397 """ 416 """
398 Private slot to show some error. 417 Private slot to show some error.
399 418
400 @param out error to be shown (string) 419 @param out error to be shown (string)
401 """ 420 """
402 self.errorGroup.show() 421 self.errorGroup.show()
403 self.errors.insertPlainText(out) 422 self.errors.insertPlainText(out)
404 self.errors.ensureCursorVisible() 423 self.errors.ensureCursorVisible()
405 424
406 @pyqtSlot() 425 @pyqtSlot()
407 def on_refreshButton_clicked(self): 426 def on_refreshButton_clicked(self):
408 """ 427 """
409 Private slot to refresh the status display. 428 Private slot to refresh the status display.
410 """ 429 """
411 selectedItems = self.statusList.selectedItems() 430 selectedItems = self.statusList.selectedItems()
412 if len(selectedItems) == 1: 431 if len(selectedItems) == 1:
413 self.__selectedName = selectedItems[0].text(self.__pathColumn) 432 self.__selectedName = selectedItems[0].text(self.__pathColumn)
414 else: 433 else:
415 self.__selectedName = "" 434 self.__selectedName = ""
416 435
417 self.start(self.args) 436 self.start(self.args)
418 437
419 @pyqtSlot(int) 438 @pyqtSlot(int)
420 def on_statusFilterCombo_activated(self, index): 439 def on_statusFilterCombo_activated(self, index):
421 """ 440 """
422 Private slot to react to the selection of a status filter. 441 Private slot to react to the selection of a status filter.
423 442
424 @param index index of the selected entry 443 @param index index of the selected entry
425 @type int 444 @type int
426 """ 445 """
427 txt = self.statusFilterCombo.itemText(index) 446 txt = self.statusFilterCombo.itemText(index)
428 if txt == "<{0}>".format(self.tr("all")): 447 if txt == "<{0}>".format(self.tr("all")):
431 topItem.setHidden(False) 450 topItem.setHidden(False)
432 else: 451 else:
433 for topIndex in range(self.statusList.topLevelItemCount()): 452 for topIndex in range(self.statusList.topLevelItemCount()):
434 topItem = self.statusList.topLevelItem(topIndex) 453 topItem = self.statusList.topLevelItem(topIndex)
435 topItem.setHidden(topItem.text(self.__statusColumn) != txt) 454 topItem.setHidden(topItem.text(self.__statusColumn) != txt)
436 455
437 @pyqtSlot() 456 @pyqtSlot()
438 def on_statusList_itemSelectionChanged(self): 457 def on_statusList_itemSelectionChanged(self):
439 """ 458 """
440 Private slot to act upon changes of selected items. 459 Private slot to act upon changes of selected items.
441 """ 460 """
442 self.__generateDiffs() 461 self.__generateDiffs()
443 462
444 ########################################################################### 463 ###########################################################################
445 ## Menu handling methods 464 ## Menu handling methods
446 ########################################################################### 465 ###########################################################################
447 466
448 def __showActionsMenu(self): 467 def __showActionsMenu(self):
449 """ 468 """
450 Private slot to prepare the actions button menu before it is shown. 469 Private slot to prepare the actions button menu before it is shown.
451 """ 470 """
452 if self.vcs.canCommitMerge(): 471 if self.vcs.canCommitMerge():
473 modified = len(self.__getModifiedItems()) 492 modified = len(self.__getModifiedItems())
474 unversioned = len(self.__getUnversionedItems()) 493 unversioned = len(self.__getUnversionedItems())
475 missing = len(self.__getMissingItems()) 494 missing = len(self.__getMissingItems())
476 commitable = len(self.__getCommitableItems()) 495 commitable = len(self.__getCommitableItems())
477 commitableUnselected = len(self.__getCommitableUnselectedItems()) 496 commitableUnselected = len(self.__getCommitableUnselectedItems())
478 497
479 self.__addAct.setEnabled(unversioned) 498 self.__addAct.setEnabled(unversioned)
480 self.__diffAct.setEnabled(modified) 499 self.__diffAct.setEnabled(modified)
481 self.__sbsDiffAct.setEnabled(modified == 1) 500 self.__sbsDiffAct.setEnabled(modified == 1)
482 self.__revertAct.setEnabled(modified) 501 self.__revertAct.setEnabled(modified)
483 self.__forgetAct.setEnabled(missing) 502 self.__forgetAct.setEnabled(missing)
484 self.__restoreAct.setEnabled(missing) 503 self.__restoreAct.setEnabled(missing)
485 self.__commitAct.setEnabled(commitable) 504 self.__commitAct.setEnabled(commitable)
486 self.__commitSelectAct.setEnabled(commitableUnselected) 505 self.__commitSelectAct.setEnabled(commitableUnselected)
487 self.__commitDeselectAct.setEnabled(commitable) 506 self.__commitDeselectAct.setEnabled(commitable)
488 507
489 if self.vcs.isExtensionActive("largefiles"): 508 if self.vcs.isExtensionActive("largefiles"):
490 enable = bool(unversioned) 509 enable = bool(unversioned)
491 else: 510 else:
492 enable = False 511 enable = False
493 self.__lfAddLargeAct.setEnabled(enable) 512 self.__lfAddLargeAct.setEnabled(enable)
494 self.__lfAddNormalAct.setEnabled(enable) 513 self.__lfAddNormalAct.setEnabled(enable)
495 514
496 def __commit(self): 515 def __commit(self):
497 """ 516 """
498 Private slot to handle the Commit context menu entry. 517 Private slot to handle the Commit context menu entry.
499 """ 518 """
500 if self.__mq: 519 if self.__mq:
501 self.vcs.vcsCommit(self.__repoPath, "", mq=True) 520 self.vcs.vcsCommit(self.__repoPath, "", mq=True)
502 else: 521 else:
503 names = [os.path.join(self.__repoPath, itm.text(self.__pathColumn)) 522 names = [
504 for itm in self.__getCommitableItems()] 523 os.path.join(self.__repoPath, itm.text(self.__pathColumn))
524 for itm in self.__getCommitableItems()
525 ]
505 if not names: 526 if not names:
506 EricMessageBox.information( 527 EricMessageBox.information(
507 self, 528 self,
508 self.tr("Commit"), 529 self.tr("Commit"),
509 self.tr("""There are no entries selected to be""" 530 self.tr(
510 """ committed.""")) 531 """There are no entries selected to be""" """ committed."""
532 ),
533 )
511 return 534 return
512 535
513 if Preferences.getVCS("AutoSaveFiles"): 536 if Preferences.getVCS("AutoSaveFiles"):
514 vm = ericApp().getObject("ViewManager") 537 vm = ericApp().getObject("ViewManager")
515 for name in names: 538 for name in names:
516 vm.saveEditor(name) 539 vm.saveEditor(name)
517 self.vcs.vcsCommit(names, '') 540 self.vcs.vcsCommit(names, "")
518 541
519 def __committed(self): 542 def __committed(self):
520 """ 543 """
521 Private slot called after the commit has finished. 544 Private slot called after the commit has finished.
522 """ 545 """
523 if self.isVisible(): 546 if self.isVisible():
524 self.on_refreshButton_clicked() 547 self.on_refreshButton_clicked()
525 self.vcs.checkVCSStatus() 548 self.vcs.checkVCSStatus()
526 549
527 def __commitSelectAll(self): 550 def __commitSelectAll(self):
528 """ 551 """
529 Private slot to select all entries for commit. 552 Private slot to select all entries for commit.
530 """ 553 """
531 self.__commitSelect(True) 554 self.__commitSelect(True)
532 555
533 def __commitDeselectAll(self): 556 def __commitDeselectAll(self):
534 """ 557 """
535 Private slot to deselect all entries from commit. 558 Private slot to deselect all entries from commit.
536 """ 559 """
537 self.__commitSelect(False) 560 self.__commitSelect(False)
538 561
539 def __add(self): 562 def __add(self):
540 """ 563 """
541 Private slot to handle the Add context menu entry. 564 Private slot to handle the Add context menu entry.
542 """ 565 """
543 names = [os.path.join(self.__repoPath, itm.text(self.__pathColumn)) 566 names = [
544 for itm in self.__getUnversionedItems()] 567 os.path.join(self.__repoPath, itm.text(self.__pathColumn))
568 for itm in self.__getUnversionedItems()
569 ]
545 if not names: 570 if not names:
546 EricMessageBox.information( 571 EricMessageBox.information(
547 self, 572 self,
548 self.tr("Add"), 573 self.tr("Add"),
549 self.tr("""There are no unversioned entries""" 574 self.tr(
550 """ available/selected.""")) 575 """There are no unversioned entries""" """ available/selected."""
576 ),
577 )
551 return 578 return
552 579
553 self.vcs.vcsAdd(names) 580 self.vcs.vcsAdd(names)
554 self.on_refreshButton_clicked() 581 self.on_refreshButton_clicked()
555 582
556 project = ericApp().getObject("Project") 583 project = ericApp().getObject("Project")
557 for name in names: 584 for name in names:
558 project.getModel().updateVCSStatus(name) 585 project.getModel().updateVCSStatus(name)
559 self.vcs.checkVCSStatus() 586 self.vcs.checkVCSStatus()
560 587
561 def __lfAdd(self, mode): 588 def __lfAdd(self, mode):
562 """ 589 """
563 Private slot to add a file to the repository. 590 Private slot to add a file to the repository.
564 591
565 @param mode add mode (string one of 'normal' or 'large') 592 @param mode add mode (string one of 'normal' or 'large')
566 """ 593 """
567 names = [os.path.join(self.__repoPath, itm.text(self.__pathColumn)) 594 names = [
568 for itm in self.__getUnversionedItems()] 595 os.path.join(self.__repoPath, itm.text(self.__pathColumn))
596 for itm in self.__getUnversionedItems()
597 ]
569 if not names: 598 if not names:
570 EricMessageBox.information( 599 EricMessageBox.information(
571 self, 600 self,
572 self.tr("Add"), 601 self.tr("Add"),
573 self.tr("""There are no unversioned entries""" 602 self.tr(
574 """ available/selected.""")) 603 """There are no unversioned entries""" """ available/selected."""
604 ),
605 )
575 return 606 return
576 607
577 self.vcs.getExtensionObject("largefiles").hgAdd( 608 self.vcs.getExtensionObject("largefiles").hgAdd(names, mode)
578 names, mode)
579 self.on_refreshButton_clicked() 609 self.on_refreshButton_clicked()
580 610
581 project = ericApp().getObject("Project") 611 project = ericApp().getObject("Project")
582 for name in names: 612 for name in names:
583 project.getModel().updateVCSStatus(name) 613 project.getModel().updateVCSStatus(name)
584 self.vcs.checkVCSStatus() 614 self.vcs.checkVCSStatus()
585 615
586 def __forget(self): 616 def __forget(self):
587 """ 617 """
588 Private slot to handle the Forget Missing context menu entry. 618 Private slot to handle the Forget Missing context menu entry.
589 """ 619 """
590 names = [os.path.join(self.__repoPath, itm.text(self.__pathColumn)) 620 names = [
591 for itm in self.__getMissingItems()] 621 os.path.join(self.__repoPath, itm.text(self.__pathColumn))
622 for itm in self.__getMissingItems()
623 ]
592 if not names: 624 if not names:
593 EricMessageBox.information( 625 EricMessageBox.information(
594 self, 626 self,
595 self.tr("Forget Missing"), 627 self.tr("Forget Missing"),
596 self.tr("""There are no missing entries""" 628 self.tr("""There are no missing entries""" """ available/selected."""),
597 """ available/selected.""")) 629 )
598 return 630 return
599 631
600 self.vcs.vcsForget(names) 632 self.vcs.vcsForget(names)
601 self.on_refreshButton_clicked() 633 self.on_refreshButton_clicked()
602 634
603 def __revert(self): 635 def __revert(self):
604 """ 636 """
605 Private slot to handle the Revert context menu entry. 637 Private slot to handle the Revert context menu entry.
606 """ 638 """
607 names = [os.path.join(self.__repoPath, itm.text(self.__pathColumn)) 639 names = [
608 for itm in self.__getModifiedItems()] 640 os.path.join(self.__repoPath, itm.text(self.__pathColumn))
641 for itm in self.__getModifiedItems()
642 ]
609 if not names: 643 if not names:
610 EricMessageBox.information( 644 EricMessageBox.information(
611 self, 645 self,
612 self.tr("Revert"), 646 self.tr("Revert"),
613 self.tr("""There are no uncommitted changes""" 647 self.tr(
614 """ available/selected.""")) 648 """There are no uncommitted changes""" """ available/selected."""
649 ),
650 )
615 return 651 return
616 652
617 self.vcs.vcsRevert(names) 653 self.vcs.vcsRevert(names)
618 self.raise_() 654 self.raise_()
619 self.activateWindow() 655 self.activateWindow()
620 self.on_refreshButton_clicked() 656 self.on_refreshButton_clicked()
621 657
622 project = ericApp().getObject("Project") 658 project = ericApp().getObject("Project")
623 for name in names: 659 for name in names:
624 project.getModel().updateVCSStatus(name) 660 project.getModel().updateVCSStatus(name)
625 self.vcs.checkVCSStatus() 661 self.vcs.checkVCSStatus()
626 662
627 def __restoreMissing(self): 663 def __restoreMissing(self):
628 """ 664 """
629 Private slot to handle the Restore Missing context menu entry. 665 Private slot to handle the Restore Missing context menu entry.
630 """ 666 """
631 names = [os.path.join(self.__repoPath, itm.text(self.__pathColumn)) 667 names = [
632 for itm in self.__getMissingItems()] 668 os.path.join(self.__repoPath, itm.text(self.__pathColumn))
669 for itm in self.__getMissingItems()
670 ]
633 if not names: 671 if not names:
634 EricMessageBox.information( 672 EricMessageBox.information(
635 self, 673 self,
636 self.tr("Restore Missing"), 674 self.tr("Restore Missing"),
637 self.tr("""There are no missing entries""" 675 self.tr("""There are no missing entries""" """ available/selected."""),
638 """ available/selected.""")) 676 )
639 return 677 return
640 678
641 self.vcs.vcsRevert(names) 679 self.vcs.vcsRevert(names)
642 self.on_refreshButton_clicked() 680 self.on_refreshButton_clicked()
643 self.vcs.checkVCSStatus() 681 self.vcs.checkVCSStatus()
644 682
645 def __diff(self): 683 def __diff(self):
646 """ 684 """
647 Private slot to handle the Diff context menu entry. 685 Private slot to handle the Diff context menu entry.
648 """ 686 """
649 names = [os.path.join(self.__repoPath, itm.text(self.__pathColumn)) 687 names = [
650 for itm in self.__getModifiedItems()] 688 os.path.join(self.__repoPath, itm.text(self.__pathColumn))
689 for itm in self.__getModifiedItems()
690 ]
651 if not names: 691 if not names:
652 EricMessageBox.information( 692 EricMessageBox.information(
653 self, 693 self,
654 self.tr("Differences"), 694 self.tr("Differences"),
655 self.tr("""There are no uncommitted changes""" 695 self.tr(
656 """ available/selected.""")) 696 """There are no uncommitted changes""" """ available/selected."""
697 ),
698 )
657 return 699 return
658 700
659 if self.diff is None: 701 if self.diff is None:
660 from .HgDiffDialog import HgDiffDialog 702 from .HgDiffDialog import HgDiffDialog
703
661 self.diff = HgDiffDialog(self.vcs) 704 self.diff = HgDiffDialog(self.vcs)
662 self.diff.show() 705 self.diff.show()
663 self.diff.start(names, refreshable=True) 706 self.diff.start(names, refreshable=True)
664 707
665 def __sbsDiff(self): 708 def __sbsDiff(self):
666 """ 709 """
667 Private slot to handle the Side-By-Side Diff context menu entry. 710 Private slot to handle the Side-By-Side Diff context menu entry.
668 """ 711 """
669 names = [os.path.join(self.__repoPath, itm.text(self.__pathColumn)) 712 names = [
670 for itm in self.__getModifiedItems()] 713 os.path.join(self.__repoPath, itm.text(self.__pathColumn))
714 for itm in self.__getModifiedItems()
715 ]
671 if not names: 716 if not names:
672 EricMessageBox.information( 717 EricMessageBox.information(
673 self, 718 self,
674 self.tr("Differences Side-By-Side"), 719 self.tr("Differences Side-By-Side"),
675 self.tr("""There are no uncommitted changes""" 720 self.tr(
676 """ available/selected.""")) 721 """There are no uncommitted changes""" """ available/selected."""
722 ),
723 )
677 return 724 return
678 elif len(names) > 1: 725 elif len(names) > 1:
679 EricMessageBox.information( 726 EricMessageBox.information(
680 self, 727 self,
681 self.tr("Differences Side-By-Side"), 728 self.tr("Differences Side-By-Side"),
682 self.tr("""Only one file with uncommitted changes""" 729 self.tr(
683 """ must be selected.""")) 730 """Only one file with uncommitted changes"""
731 """ must be selected."""
732 ),
733 )
684 return 734 return
685 735
686 self.vcs.vcsSbsDiff(names[0]) 736 self.vcs.vcsSbsDiff(names[0])
687 737
688 def __getCommitableItems(self): 738 def __getCommitableItems(self):
689 """ 739 """
690 Private method to retrieve all entries the user wants to commit. 740 Private method to retrieve all entries the user wants to commit.
691 741
692 @return list of all items, the user has checked 742 @return list of all items, the user has checked
693 """ 743 """
694 commitableItems = [] 744 commitableItems = []
695 for index in range(self.statusList.topLevelItemCount()): 745 for index in range(self.statusList.topLevelItemCount()):
696 itm = self.statusList.topLevelItem(index) 746 itm = self.statusList.topLevelItem(index)
697 if ( 747 if itm.checkState(self.__toBeCommittedColumn) == Qt.CheckState.Checked:
698 itm.checkState(self.__toBeCommittedColumn) ==
699 Qt.CheckState.Checked
700 ):
701 commitableItems.append(itm) 748 commitableItems.append(itm)
702 return commitableItems 749 return commitableItems
703 750
704 def __getCommitableUnselectedItems(self): 751 def __getCommitableUnselectedItems(self):
705 """ 752 """
706 Private method to retrieve all entries the user may commit but hasn't 753 Private method to retrieve all entries the user may commit but hasn't
707 selected. 754 selected.
708 755
709 @return list of all items, the user has checked 756 @return list of all items, the user has checked
710 """ 757 """
711 items = [] 758 items = []
712 for index in range(self.statusList.topLevelItemCount()): 759 for index in range(self.statusList.topLevelItemCount()):
713 itm = self.statusList.topLevelItem(index) 760 itm = self.statusList.topLevelItem(index)
714 if ( 761 if (
715 (itm.flags() & Qt.ItemFlag.ItemIsUserCheckable == 762 itm.flags() & Qt.ItemFlag.ItemIsUserCheckable
716 Qt.ItemFlag.ItemIsUserCheckable) and 763 == Qt.ItemFlag.ItemIsUserCheckable
717 itm.checkState(self.__toBeCommittedColumn) == 764 ) and itm.checkState(self.__toBeCommittedColumn) == Qt.CheckState.Unchecked:
718 Qt.CheckState.Unchecked
719 ):
720 items.append(itm) 765 items.append(itm)
721 return items 766 return items
722 767
723 def __getModifiedItems(self): 768 def __getModifiedItems(self):
724 """ 769 """
725 Private method to retrieve all entries, that have a modified status. 770 Private method to retrieve all entries, that have a modified status.
726 771
727 @return list of all items with a modified status 772 @return list of all items with a modified status
728 """ 773 """
729 modifiedItems = [] 774 modifiedItems = []
730 for itm in self.statusList.selectedItems(): 775 for itm in self.statusList.selectedItems():
731 if itm.text(self.__statusColumn) in self.modifiedIndicators: 776 if itm.text(self.__statusColumn) in self.modifiedIndicators:
732 modifiedItems.append(itm) 777 modifiedItems.append(itm)
733 return modifiedItems 778 return modifiedItems
734 779
735 def __getUnversionedItems(self): 780 def __getUnversionedItems(self):
736 """ 781 """
737 Private method to retrieve all entries, that have an unversioned 782 Private method to retrieve all entries, that have an unversioned
738 status. 783 status.
739 784
740 @return list of all items with an unversioned status 785 @return list of all items with an unversioned status
741 """ 786 """
742 unversionedItems = [] 787 unversionedItems = []
743 for itm in self.statusList.selectedItems(): 788 for itm in self.statusList.selectedItems():
744 if itm.text(self.__statusColumn) in self.unversionedIndicators: 789 if itm.text(self.__statusColumn) in self.unversionedIndicators:
745 unversionedItems.append(itm) 790 unversionedItems.append(itm)
746 return unversionedItems 791 return unversionedItems
747 792
748 def __getMissingItems(self): 793 def __getMissingItems(self):
749 """ 794 """
750 Private method to retrieve all entries, that have a missing status. 795 Private method to retrieve all entries, that have a missing status.
751 796
752 @return list of all items with a missing status 797 @return list of all items with a missing status
753 """ 798 """
754 missingItems = [] 799 missingItems = []
755 for itm in self.statusList.selectedItems(): 800 for itm in self.statusList.selectedItems():
756 if itm.text(self.__statusColumn) in self.missingIndicators: 801 if itm.text(self.__statusColumn) in self.missingIndicators:
757 missingItems.append(itm) 802 missingItems.append(itm)
758 return missingItems 803 return missingItems
759 804
760 def __commitSelect(self, selected): 805 def __commitSelect(self, selected):
761 """ 806 """
762 Private slot to select or deselect all entries. 807 Private slot to select or deselect all entries.
763 808
764 @param selected commit selection state to be set (boolean) 809 @param selected commit selection state to be set (boolean)
765 """ 810 """
766 for index in range(self.statusList.topLevelItemCount()): 811 for index in range(self.statusList.topLevelItemCount()):
767 itm = self.statusList.topLevelItem(index) 812 itm = self.statusList.topLevelItem(index)
768 if ( 813 if (
769 itm.flags() & Qt.ItemFlag.ItemIsUserCheckable == 814 itm.flags() & Qt.ItemFlag.ItemIsUserCheckable
770 Qt.ItemFlag.ItemIsUserCheckable 815 == Qt.ItemFlag.ItemIsUserCheckable
771 ): 816 ):
772 if selected: 817 if selected:
773 itm.setCheckState(self.__toBeCommittedColumn, 818 itm.setCheckState(self.__toBeCommittedColumn, Qt.CheckState.Checked)
774 Qt.CheckState.Checked)
775 else: 819 else:
776 itm.setCheckState(self.__toBeCommittedColumn, 820 itm.setCheckState(
777 Qt.CheckState.Unchecked) 821 self.__toBeCommittedColumn, Qt.CheckState.Unchecked
778 822 )
823
779 def __commitMerge(self): 824 def __commitMerge(self):
780 """ 825 """
781 Private slot to handle the Commit Merge context menu entry. 826 Private slot to handle the Commit Merge context menu entry.
782 """ 827 """
783 self.vcs.vcsCommit(self.__repoPath, self.tr('Merge'), merge=True) 828 self.vcs.vcsCommit(self.__repoPath, self.tr("Merge"), merge=True)
784 self.__committed() 829 self.__committed()
785 830
786 def __abortMerge(self): 831 def __abortMerge(self):
787 """ 832 """
788 Private slot used to abort an uncommitted merge. 833 Private slot used to abort an uncommitted merge.
791 self.__committed() 836 self.__committed()
792 837
793 ########################################################################### 838 ###########################################################################
794 ## Diff handling methods below 839 ## Diff handling methods below
795 ########################################################################### 840 ###########################################################################
796 841
797 def __generateDiffs(self): 842 def __generateDiffs(self):
798 """ 843 """
799 Private slot to generate diff outputs for the selected item. 844 Private slot to generate diff outputs for the selected item.
800 """ 845 """
801 self.diffEdit.clear() 846 self.diffEdit.clear()
802 self.diffHighlighter.regenerateRules() 847 self.diffHighlighter.regenerateRules()
803 848
804 if not self.__mq: 849 if not self.__mq:
805 selectedItems = self.statusList.selectedItems() 850 selectedItems = self.statusList.selectedItems()
806 if len(selectedItems) == 1: 851 if len(selectedItems) == 1:
807 fn = os.path.join(self.__repoPath, 852 fn = os.path.join(
808 selectedItems[0].text(self.__pathColumn)) 853 self.__repoPath, selectedItems[0].text(self.__pathColumn)
854 )
809 self.__diffGenerator.start(fn) 855 self.__diffGenerator.start(fn)
810 856
811 def __generatorFinished(self): 857 def __generatorFinished(self):
812 """ 858 """
813 Private slot connected to the finished signal of the diff generator. 859 Private slot connected to the finished signal of the diff generator.
814 """ 860 """
815 diff = self.__diffGenerator.getResult()[0] 861 diff = self.__diffGenerator.getResult()[0]
816 862
817 if diff: 863 if diff:
818 for line in diff[:]: 864 for line in diff[:]:
819 if line.startswith("@@ "): 865 if line.startswith("@@ "):
820 break 866 break
821 else: 867 else:
822 diff.pop(0) 868 diff.pop(0)
823 self.diffEdit.setPlainText("".join(diff)) 869 self.diffEdit.setPlainText("".join(diff))
824 870
825 tc = self.diffEdit.textCursor() 871 tc = self.diffEdit.textCursor()
826 tc.movePosition(QTextCursor.MoveOperation.Start) 872 tc.movePosition(QTextCursor.MoveOperation.Start)
827 self.diffEdit.setTextCursor(tc) 873 self.diffEdit.setTextCursor(tc)
828 self.diffEdit.ensureCursorVisible() 874 self.diffEdit.ensureCursorVisible()
829 875
830 def __refreshDiff(self): 876 def __refreshDiff(self):
831 """ 877 """
832 Private method to refresh the diff output after a refresh. 878 Private method to refresh the diff output after a refresh.
833 """ 879 """
834 if self.__selectedName and not self.__mq: 880 if self.__selectedName and not self.__mq:
835 for index in range(self.statusList.topLevelItemCount()): 881 for index in range(self.statusList.topLevelItemCount()):
836 itm = self.statusList.topLevelItem(index) 882 itm = self.statusList.topLevelItem(index)
837 if itm.text(self.__pathColumn) == self.__selectedName: 883 if itm.text(self.__pathColumn) == self.__selectedName:
838 itm.setSelected(True) 884 itm.setSelected(True)
839 break 885 break
840 886
841 self.__selectedName = "" 887 self.__selectedName = ""

eric ide

mercurial