eric7/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py

branch
eric7
changeset 8659
0e58d3367e92
parent 8621
8c9f41115c04
child 8814
59bae82bf176
--- a/eric7/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Fri Oct 01 17:08:37 2021 +0200
+++ b/eric7/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Sat Oct 02 15:35:19 2021 +0200
@@ -63,6 +63,9 @@
     LargefilesCacheW = ".hglf\\"
     PathSeparatorRe = re.compile(r"/|\\")
     
+    GraftedRe = re.compile(r"\(grafted from ([0-9a-fA-F]+)\)")
+    GraftedTemplate = '(grafted from <a href="chg:{0}">{0}</a>)'
+    
     ClosedIndicator = " \u2612"
     
     def __init__(self, vcs, mode="", parent=None):
@@ -1658,10 +1661,16 @@
             else:
                 childrenStr = ""
             
-            messageStr = "<br />\n".join([
-                Utilities.html_encode(line.strip())
-                for line in itm.data(0, self.__messageRole)
-            ])
+            messagesList = []
+            for line in itm.data(0, self.__messageRole):
+                match = HgLogBrowserDialog.GraftedRe.fullmatch(line)
+                if match:
+                    messagesList.append(
+                        HgLogBrowserDialog.GraftedTemplate.format(
+                            match.group(1)))
+                else:
+                    messagesList.append(Utilities.html_encode(line.strip()))
+            messageStr = "<br />\n".join(messagesList)
             
             html = self.__detailsTemplate.format(
                 itm.text(self.RevisionColumn),
@@ -2464,13 +2473,21 @@
         @param url URL that was clicked
         @type QUrl
         """
-        if url.scheme() == "rev":
-            # a parent or child revision was clicked, show the respective item
-            rev = url.path()
-            searchStr = "{0:>7}:".format(rev)
-            # format must be in sync with item generation format
+        if url.scheme() in ("rev", "chg"):
+            if url.scheme() == "rev":
+                # a parent or child revision was clicked, show the item
+                rev = url.path()
+                searchStr = "{0:>7}:".format(rev)
+                # format must be in sync with item generation format
+                searchFlags = Qt.MatchFlag.MatchStartsWith
+            elif url.scheme() == "chg":
+                # a changeset hash was clicked, show the item
+                changeset = url.path()
+                searchStr = ":{0}".format(changeset[:12])  # max. 12 hash chars
+                # format must be in sync with item generation format
+                searchFlags = Qt.MatchFlag.MatchContains
             items = self.logTree.findItems(
-                searchStr, Qt.MatchFlag.MatchStartsWith, self.RevisionColumn)
+                searchStr, searchFlags, self.RevisionColumn)
             if items:
                 itm = items[0]
                 if itm.isHidden():
@@ -2478,7 +2495,7 @@
                 self.logTree.setCurrentItem(itm)
             else:
                 # load the next batch and try again
-                if self.nextButton.isEnabled():
+                if not self.cancelled and self.nextButton.isEnabled():
                     self.__addFinishCallback(
                         lambda: self.__revisionClicked(url))
                     self.on_nextButton_clicked()

eric ide

mercurial