diff hgext3rd/serverminitopic.py @ 3651:fa15068a9945

serverminitopic: wrap context.changectx.branch instead of context.changectx Recently some changes in core resulted in this wrapping of class leading to an infinite recursion. Let's wrap the particular function instead of wrapping the whole command. This fixes test-minitopic.t which was breaking.
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 06 Apr 2018 23:42:47 +0530
parents d938808e31bc
children b12c5d107187
line wrap: on
line diff
--- a/hgext3rd/serverminitopic.py	Fri Apr 06 17:53:41 2018 +0200
+++ b/hgext3rd/serverminitopic.py	Fri Apr 06 23:42:47 2018 +0530
@@ -43,17 +43,14 @@
 
 ### make topic visible though "ctx.branch()"
 
-class topicchangectx(context.changectx):
-    """a sunclass of changectx that add topic to the branch name"""
-
-    def branch(self):
-        branch = super(topicchangectx, self).branch()
-        if hasminitopic(self._repo) and self.phase():
-            topic = self._changeset.extra.get('topic')
-            if topic is not None:
-                topic = encoding.tolocal(topic)
-                branch = '%s:%s' % (branch, topic)
-        return branch
+def topicbranch(orig, self):
+    branch = orig(self)
+    if hasminitopic(self._repo) and self.phase():
+        topic = self._changeset.extra.get('topic')
+        if topic is not None:
+            topic = encoding.tolocal(topic)
+            branch = '%s:%s' % (branch, topic)
+    return branch
 
 ### avoid caching topic data in rev-branch-cache
 
@@ -220,7 +217,7 @@
     assert issubclass(current, new), (current, new, targetclass)
 
 def uisetup(ui):
-    wrapclass(context, 'changectx', topicchangectx)
     wrapclass(branchmap, 'branchcache', _topiccache)
     extensions.wrapfunction(branchmap, 'read', wrapread)
     extensions.wrapfunction(wireproto, '_capabilities', wireprotocaps)
+    extensions.wrapfunction(context.changectx, 'branch', topicbranch)