topic: also have the revbranchcache during the discovery
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sun, 02 Jul 2017 16:39:48 +0200
changeset 2696 a32afe67e8a6
parent 2695 b4824e169f18
child 2697 189fd9d6a405
topic: also have the revbranchcache during the discovery
hgext3rd/topic/discovery.py
--- a/hgext3rd/topic/discovery.py	Sun Jul 02 16:00:38 2017 +0200
+++ b/hgext3rd/topic/discovery.py	Sun Jul 02 16:39:48 2017 +0200
@@ -35,6 +35,7 @@
         return orig(*args)
 
     class repocls(repo.__class__):
+        # awful hack to see branch as "branch:topic"
         def __getitem__(self, key):
             ctx = super(repocls, self).__getitem__(key)
             oldbranch = ctx.branch
@@ -49,6 +50,20 @@
             ctx.branch = branch
             return ctx
 
+        def revbranchcache(self):
+            rbc = super(repocls, self).revbranchcache()
+            changelog = self.changelog
+
+            def branchinfo(rev):
+                branch, close = changelog.branchinfo(rev)
+                topic = repo[rev].topic()
+                if topic:
+                    branch = "%s:%s" % (branch, topic)
+                return branch, close
+
+            rbc.branchinfo = branchinfo
+            return rbc
+
     oldrepocls = repo.__class__
     try:
         repo.__class__ = repocls