changeset 2696:a32afe67e8a6

topic: also have the revbranchcache during the discovery
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 02 Jul 2017 16:39:48 +0200
parents b4824e169f18
children 189fd9d6a405
files hgext3rd/topic/discovery.py
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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