eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py

changeset 8143
2c730d5fd177
parent 7971
ff2971513d6d
child 8151
8c1445825e7b
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
77 """ 77 """
78 super(HgLogBrowserDialog, self).__init__(parent) 78 super(HgLogBrowserDialog, self).__init__(parent)
79 self.setupUi(self) 79 self.setupUi(self)
80 80
81 windowFlags = self.windowFlags() 81 windowFlags = self.windowFlags()
82 windowFlags |= Qt.WindowContextHelpButtonHint 82 windowFlags |= Qt.WindowType.WindowContextHelpButtonHint
83 self.setWindowFlags(windowFlags) 83 self.setWindowFlags(windowFlags)
84 84
85 self.mainSplitter.setSizes([300, 400]) 85 self.mainSplitter.setSizes([300, 400])
86 self.mainSplitter.setStretchFactor(0, 1) 86 self.mainSplitter.setStretchFactor(0, 1)
87 self.mainSplitter.setStretchFactor(1, 2) 87 self.mainSplitter.setStretchFactor(1, 2)
101 elif mode == "outgoing": 101 elif mode == "outgoing":
102 self.setWindowTitle(self.tr("Mercurial Log (Outgoing)")) 102 self.setWindowTitle(self.tr("Mercurial Log (Outgoing)"))
103 elif mode == "full_log": 103 elif mode == "full_log":
104 self.setWindowTitle(self.tr("Mercurial Full Log")) 104 self.setWindowTitle(self.tr("Mercurial Full Log"))
105 105
106 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 106 self.buttonBox.button(
107 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 107 QDialogButtonBox.StandardButton.Close).setEnabled(False)
108 self.buttonBox.button(
109 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
108 110
109 self.filesTree.headerItem().setText(self.filesTree.columnCount(), "") 111 self.filesTree.headerItem().setText(self.filesTree.columnCount(), "")
110 self.filesTree.header().setSortIndicator(0, Qt.AscendingOrder) 112 self.filesTree.header().setSortIndicator(
113 0, Qt.SortOrder.AscendingOrder)
111 114
112 self.upButton.setIcon(UI.PixmapCache.getIcon("1uparrow")) 115 self.upButton.setIcon(UI.PixmapCache.getIcon("1uparrow"))
113 self.downButton.setIcon(UI.PixmapCache.getIcon("1downarrow")) 116 self.downButton.setIcon(UI.PixmapCache.getIcon("1downarrow"))
114 117
115 self.refreshButton = self.buttonBox.addButton( 118 self.refreshButton = self.buttonBox.addButton(
116 self.tr("&Refresh"), QDialogButtonBox.ActionRole) 119 self.tr("&Refresh"), QDialogButtonBox.ButtonRole.ActionRole)
117 self.refreshButton.setToolTip( 120 self.refreshButton.setToolTip(
118 self.tr("Press to refresh the list of changesets")) 121 self.tr("Press to refresh the list of changesets"))
119 self.refreshButton.setEnabled(False) 122 self.refreshButton.setEnabled(False)
120 123
121 self.findPrevButton.setIcon(UI.PixmapCache.getIcon("1leftarrow")) 124 self.findPrevButton.setIcon(UI.PixmapCache.getIcon("1leftarrow"))
189 self.fromDate.setDisplayFormat("yyyy-MM-dd") 192 self.fromDate.setDisplayFormat("yyyy-MM-dd")
190 self.toDate.setDisplayFormat("yyyy-MM-dd") 193 self.toDate.setDisplayFormat("yyyy-MM-dd")
191 self.__resetUI() 194 self.__resetUI()
192 195
193 # roles used in the log tree 196 # roles used in the log tree
194 self.__messageRole = Qt.UserRole 197 self.__messageRole = Qt.ItemDataRole.UserRole
195 self.__changesRole = Qt.UserRole + 1 198 self.__changesRole = Qt.ItemDataRole.UserRole + 1
196 self.__edgesRole = Qt.UserRole + 2 199 self.__edgesRole = Qt.ItemDataRole.UserRole + 2
197 self.__parentsRole = Qt.UserRole + 3 200 self.__parentsRole = Qt.ItemDataRole.UserRole + 3
198 self.__latestTagRole = Qt.UserRole + 4 201 self.__latestTagRole = Qt.ItemDataRole.UserRole + 4
199 self.__incomingRole = Qt.UserRole + 5 202 self.__incomingRole = Qt.ItemDataRole.UserRole + 5
200 203
201 # roles used in the file tree 204 # roles used in the file tree
202 self.__diffFileLineRole = Qt.UserRole 205 self.__diffFileLineRole = Qt.ItemDataRole.UserRole
203 206
204 self.flags = { 207 self.flags = {
205 'A': self.tr('Added'), 208 'A': self.tr('Added'),
206 'D': self.tr('Deleted'), 209 'D': self.tr('Deleted'),
207 'M': self.tr('Modified'), 210 'M': self.tr('Modified'),
497 500
498 def __resizeColumnsLog(self): 501 def __resizeColumnsLog(self):
499 """ 502 """
500 Private method to resize the log tree columns. 503 Private method to resize the log tree columns.
501 """ 504 """
502 self.logTree.header().resizeSections(QHeaderView.ResizeToContents) 505 self.logTree.header().resizeSections(
506 QHeaderView.ResizeMode.ResizeToContents)
503 self.logTree.header().setStretchLastSection(True) 507 self.logTree.header().setStretchLastSection(True)
504 508
505 def __resizeColumnsFiles(self): 509 def __resizeColumnsFiles(self):
506 """ 510 """
507 Private method to resize the changed files tree columns. 511 Private method to resize the changed files tree columns.
508 """ 512 """
509 self.filesTree.header().resizeSections(QHeaderView.ResizeToContents) 513 self.filesTree.header().resizeSections(
514 QHeaderView.ResizeMode.ResizeToContents)
510 self.filesTree.header().setStretchLastSection(True) 515 self.filesTree.header().setStretchLastSection(True)
511 516
512 def __resortFiles(self): 517 def __resortFiles(self):
513 """ 518 """
514 Private method to resort the changed files tree. 519 Private method to resort the changed files tree.
628 @param col column number (integer) 633 @param col column number (integer)
629 @param radius radius of the indicator circle (integer) 634 @param radius radius of the indicator circle (integer)
630 """ 635 """
631 return int(1.2 * radius) * col + radius // 2 + 3 636 return int(1.2 * radius) * col + radius // 2 + 3
632 637
633 textColor = self.logTree.palette().color(QPalette.Text) 638 textColor = self.logTree.palette().color(QPalette.ColorRole.Text)
634 639
635 radius = self.__dotRadius 640 radius = self.__dotRadius
636 w = len(bottomedges) * radius + 20 641 w = len(bottomedges) * radius + 20
637 h = self.__rowHeight 642 h = self.__rowHeight
638 643
640 dot_y = h // 2 645 dot_y = h // 2
641 646
642 pix = QPixmap(w, h) 647 pix = QPixmap(w, h)
643 pix.fill(QColor(0, 0, 0, 0)) # draw transparent background 648 pix.fill(QColor(0, 0, 0, 0)) # draw transparent background
644 painter = QPainter(pix) 649 painter = QPainter(pix)
645 painter.setRenderHint(QPainter.Antialiasing) 650 painter.setRenderHint(QPainter.RenderHint.Antialiasing)
646 651
647 # draw the revision history lines 652 # draw the revision history lines
648 for y1, y2, lines in ((0, h, bottomedges), 653 for y1, y2, lines in ((0, h, bottomedges),
649 (-h, 0, topedges)): 654 (-h, 0, topedges)):
650 if lines: 655 if lines:
975 Private method to retrieve log entries from the repository. 980 Private method to retrieve log entries from the repository.
976 981
977 @param startRev revision number to start from (integer, string) 982 @param startRev revision number to start from (integer, string)
978 @param noEntries number of entries to get (0 = default) (int) 983 @param noEntries number of entries to get (0 = default) (int)
979 """ 984 """
980 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 985 self.buttonBox.button(
981 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) 986 QDialogButtonBox.StandardButton.Close).setEnabled(False)
982 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 987 self.buttonBox.button(
988 QDialogButtonBox.StandardButton.Cancel).setEnabled(True)
989 self.buttonBox.button(
990 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
983 QApplication.processEvents() 991 QApplication.processEvents()
984 992
985 with E5OverrideCursor(): 993 with E5OverrideCursor():
986 self.buf = [] 994 self.buf = []
987 self.cancelled = False 995 self.cancelled = False
1113 def __finish(self): 1121 def __finish(self):
1114 """ 1122 """
1115 Private slot called when the process finished or the user pressed 1123 Private slot called when the process finished or the user pressed
1116 the button. 1124 the button.
1117 """ 1125 """
1118 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 1126 self.buttonBox.button(
1119 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 1127 QDialogButtonBox.StandardButton.Close).setEnabled(True)
1120 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 1128 self.buttonBox.button(
1129 QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
1130 self.buttonBox.button(
1131 QDialogButtonBox.StandardButton.Close).setDefault(True)
1121 1132
1122 self.refreshButton.setEnabled(True) 1133 self.refreshButton.setEnabled(True)
1123 1134
1124 while self.__finishCallbacks: 1135 while self.__finishCallbacks:
1125 self.__finishCallbacks.pop(0)() 1136 self.__finishCallbacks.pop(0)()
1236 log["author"], log["date"], 1247 log["author"], log["date"],
1237 log["message"], log["revision"], changedPaths, 1248 log["message"], log["revision"], changedPaths,
1238 log["parents"], log["branches"], log["tags"], 1249 log["parents"], log["branches"], log["tags"],
1239 log["phase"], log["bookmarks"], log["latesttag"], 1250 log["phase"], log["bookmarks"], log["latesttag"],
1240 canPush=canPush) 1251 canPush=canPush)
1241 dt = QDate.fromString(log["date"], Qt.ISODate) 1252 dt = QDate.fromString(log["date"], Qt.DateFormat.ISODate)
1242 if ( 1253 if (
1243 not self.__maxDate.isValid() and 1254 not self.__maxDate.isValid() and
1244 not self.__minDate.isValid() 1255 not self.__minDate.isValid()
1245 ): 1256 ):
1246 self.__maxDate = dt 1257 self.__maxDate = dt
1260 if self.__started: 1271 if self.__started:
1261 if not self.__finishCallbacks: 1272 if not self.__finishCallbacks:
1262 # we are really done 1273 # we are really done
1263 if self.__selectedRevisions: 1274 if self.__selectedRevisions:
1264 foundItems = self.logTree.findItems( 1275 foundItems = self.logTree.findItems(
1265 self.__selectedRevisions[0], Qt.MatchExactly, 1276 self.__selectedRevisions[0], Qt.MatchFlag.MatchExactly,
1266 self.RevisionColumn) 1277 self.RevisionColumn)
1267 if foundItems: 1278 if foundItems:
1268 self.logTree.setCurrentItem(foundItems[0]) 1279 self.logTree.setCurrentItem(foundItems[0])
1269 else: 1280 else:
1270 self.logTree.setCurrentItem( 1281 self.logTree.setCurrentItem(
1272 elif self.__projectWorkingDirParents: 1283 elif self.__projectWorkingDirParents:
1273 for rev in self.__projectWorkingDirParents: 1284 for rev in self.__projectWorkingDirParents:
1274 # rev string format must match with the format of the 1285 # rev string format must match with the format of the
1275 # __generateLogItem() method 1286 # __generateLogItem() method
1276 items = self.logTree.findItems( 1287 items = self.logTree.findItems(
1277 "{0:>7}:".format(rev), Qt.MatchStartsWith, 1288 "{0:>7}:".format(rev),
1289 Qt.MatchFlag.MatchStartsWith,
1278 self.RevisionColumn) 1290 self.RevisionColumn)
1279 if items: 1291 if items:
1280 self.logTree.setCurrentItem(items[0]) 1292 self.logTree.setCurrentItem(items[0])
1281 break 1293 break
1282 else: 1294 else:
1322 # restore selected item 1334 # restore selected item
1323 if self.__selectedRevisions and not self.__finishCallbacks: 1335 if self.__selectedRevisions and not self.__finishCallbacks:
1324 # we are really done 1336 # we are really done
1325 for revision in self.__selectedRevisions: 1337 for revision in self.__selectedRevisions:
1326 items = self.logTree.findItems( 1338 items = self.logTree.findItems(
1327 revision, Qt.MatchExactly, self.RevisionColumn) 1339 revision, Qt.MatchFlag.MatchExactly, self.RevisionColumn)
1328 if items: 1340 if items:
1329 items[0].setSelected(True) 1341 items[0].setSelected(True)
1330 self.__selectedRevisions = [] 1342 self.__selectedRevisions = []
1331 1343
1332 def __showError(self, out): 1344 def __showError(self, out):
1343 """ 1355 """
1344 Private slot called by a button of the button box clicked. 1356 Private slot called by a button of the button box clicked.
1345 1357
1346 @param button button that was clicked (QAbstractButton) 1358 @param button button that was clicked (QAbstractButton)
1347 """ 1359 """
1348 if button == self.buttonBox.button(QDialogButtonBox.Close): 1360 if button == self.buttonBox.button(
1361 QDialogButtonBox.StandardButton.Close
1362 ):
1349 self.close() 1363 self.close()
1350 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): 1364 elif button == self.buttonBox.button(
1365 QDialogButtonBox.StandardButton.Cancel
1366 ):
1351 self.cancelled = True 1367 self.cancelled = True
1352 self.__hgClient.cancel() 1368 self.__hgClient.cancel()
1353 elif button == self.refreshButton: 1369 elif button == self.refreshButton:
1354 self.on_refreshButton_clicked() 1370 self.on_refreshButton_clicked()
1355 1371
1918 1934
1919 @param addNext flag indicating to get a second batch of log entries as 1935 @param addNext flag indicating to get a second batch of log entries as
1920 well 1936 well
1921 @type bool 1937 @type bool
1922 """ 1938 """
1923 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 1939 self.buttonBox.button(
1924 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) 1940 QDialogButtonBox.StandardButton.Close).setEnabled(False)
1925 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 1941 self.buttonBox.button(
1942 QDialogButtonBox.StandardButton.Cancel).setEnabled(True)
1943 self.buttonBox.button(
1944 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
1926 1945
1927 self.refreshButton.setEnabled(False) 1946 self.refreshButton.setEnabled(False)
1928 1947
1929 # save the selected items commit IDs 1948 # save the selected items commit IDs
1930 self.__selectedRevisions = [] 1949 self.__selectedRevisions = []
2091 bookmark, ok = QInputDialog.getText( 2110 bookmark, ok = QInputDialog.getText(
2092 self, 2111 self,
2093 self.tr("Define Bookmark"), 2112 self.tr("Define Bookmark"),
2094 self.tr('Enter bookmark name for changeset "{0}":').format( 2113 self.tr('Enter bookmark name for changeset "{0}":').format(
2095 changeset), 2114 changeset),
2096 QLineEdit.Normal) 2115 QLineEdit.EchoMode.Normal)
2097 if ok and bool(bookmark): 2116 if ok and bool(bookmark):
2098 self.vcs.hgBookmarkDefine( 2117 self.vcs.hgBookmarkDefine(
2099 revision="rev({0})".format(rev), 2118 revision="rev({0})".format(rev),
2100 bookmark=bookmark) 2119 bookmark=bookmark)
2101 self.on_refreshButton_clicked() 2120 self.on_refreshButton_clicked()
2456 if url.scheme() == "rev": 2475 if url.scheme() == "rev":
2457 # a parent or child revision was clicked, show the respective item 2476 # a parent or child revision was clicked, show the respective item
2458 rev = url.path() 2477 rev = url.path()
2459 searchStr = "{0:>7}:".format(rev) 2478 searchStr = "{0:>7}:".format(rev)
2460 # format must be in sync with item generation format 2479 # format must be in sync with item generation format
2461 items = self.logTree.findItems(searchStr, Qt.MatchStartsWith, 2480 items = self.logTree.findItems(
2462 self.RevisionColumn) 2481 searchStr, Qt.MatchFlag.MatchStartsWith, self.RevisionColumn)
2463 if items: 2482 if items:
2464 itm = items[0] 2483 itm = items[0]
2465 if itm.isHidden(): 2484 if itm.isHidden():
2466 itm.setHidden(False) 2485 itm.setHidden(False)
2467 self.logTree.setCurrentItem(itm) 2486 self.logTree.setCurrentItem(itm)
2554 else: 2573 else:
2555 for oldFileName, newFileName, lineNumber in fileSeparators: 2574 for oldFileName, newFileName, lineNumber in fileSeparators:
2556 for fileName in (oldFileName, newFileName): 2575 for fileName in (oldFileName, newFileName):
2557 if fileName != "__NULL__": 2576 if fileName != "__NULL__":
2558 items = self.filesTree.findItems( 2577 items = self.filesTree.findItems(
2559 fileName, Qt.MatchExactly, 1) 2578 fileName, Qt.MatchFlag.MatchExactly, 1)
2560 for item in items: 2579 for item in items:
2561 item.setData(0, self.__diffFileLineRole, 2580 item.setData(0, self.__diffFileLineRole,
2562 lineNumber) 2581 lineNumber)
2563 2582
2564 tc = self.diffEdit.textCursor() 2583 tc = self.diffEdit.textCursor()
2565 tc.movePosition(QTextCursor.Start) 2584 tc.movePosition(QTextCursor.MoveOperation.Start)
2566 self.diffEdit.setTextCursor(tc) 2585 self.diffEdit.setTextCursor(tc)
2567 self.diffEdit.ensureCursorVisible() 2586 self.diffEdit.ensureCursorVisible()
2568 2587
2569 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) 2588 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
2570 def on_filesTree_currentItemChanged(self, current, previous): 2589 def on_filesTree_currentItemChanged(self, current, previous):
2577 if current: 2596 if current:
2578 para = current.data(0, self.__diffFileLineRole) 2597 para = current.data(0, self.__diffFileLineRole)
2579 if para is not None: 2598 if para is not None:
2580 if para == 0: 2599 if para == 0:
2581 tc = self.diffEdit.textCursor() 2600 tc = self.diffEdit.textCursor()
2582 tc.movePosition(QTextCursor.Start) 2601 tc.movePosition(QTextCursor.MoveOperation.Start)
2583 self.diffEdit.setTextCursor(tc) 2602 self.diffEdit.setTextCursor(tc)
2584 self.diffEdit.ensureCursorVisible() 2603 self.diffEdit.ensureCursorVisible()
2585 elif para == -1: 2604 elif para == -1:
2586 tc = self.diffEdit.textCursor() 2605 tc = self.diffEdit.textCursor()
2587 tc.movePosition(QTextCursor.End) 2606 tc.movePosition(QTextCursor.MoveOperation.End)
2588 self.diffEdit.setTextCursor(tc) 2607 self.diffEdit.setTextCursor(tc)
2589 self.diffEdit.ensureCursorVisible() 2608 self.diffEdit.ensureCursorVisible()
2590 else: 2609 else:
2591 # step 1: move cursor to end 2610 # step 1: move cursor to end
2592 tc = self.diffEdit.textCursor() 2611 tc = self.diffEdit.textCursor()
2593 tc.movePosition(QTextCursor.End) 2612 tc.movePosition(QTextCursor.MoveOperation.End)
2594 self.diffEdit.setTextCursor(tc) 2613 self.diffEdit.setTextCursor(tc)
2595 self.diffEdit.ensureCursorVisible() 2614 self.diffEdit.ensureCursorVisible()
2596 2615
2597 # step 2: move cursor to desired line 2616 # step 2: move cursor to desired line
2598 tc = self.diffEdit.textCursor() 2617 tc = self.diffEdit.textCursor()
2599 delta = tc.blockNumber() - para 2618 delta = tc.blockNumber() - para
2600 tc.movePosition(QTextCursor.PreviousBlock, 2619 tc.movePosition(QTextCursor.MoveOperation.PreviousBlock,
2601 QTextCursor.MoveAnchor, delta) 2620 QTextCursor.MoveMode.MoveAnchor, delta)
2602 self.diffEdit.setTextCursor(tc) 2621 self.diffEdit.setTextCursor(tc)
2603 self.diffEdit.ensureCursorVisible() 2622 self.diffEdit.ensureCursorVisible()
2604 2623
2605 @pyqtSlot(str) 2624 @pyqtSlot(str)
2606 def on_diffSelectLabel_linkActivated(self, link): 2625 def on_diffSelectLabel_linkActivated(self, link):

eric ide

mercurial