changeset 6270:00d1551bfa8c

topic: actually wrap branchmap wire-protocol command
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 08 Jul 2022 09:50:12 +0200
parents 16f6b18b9ec0
children caf302fb8f4d
files hgext3rd/topic/discovery.py
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/discovery.py	Fri Jul 08 17:52:25 2022 +0400
+++ b/hgext3rd/topic/discovery.py	Fri Jul 08 09:50:12 2022 +0200
@@ -158,17 +158,21 @@
 def wireprotobranchmap(orig, repo, proto):
     if not common.hastopicext(repo):
         return orig(repo, proto)
-    oldrepo = repo.__class__
+    unfi = repo.unfiltered()
+    oldrepocls = unfi.__class__
     try:
-        class repocls(repo.__class__):
+        class repocls(oldrepocls):
             def branchmap(self):
                 usetopic = not self.publishing()
                 return super(repocls, self).branchmap(topic=usetopic)
-        repo.__class__ = repocls
+        unfi.__class__ = repocls
+        if repo.filtername is not None:
+            repo = unfi.filtered(repo.filtername)
+        else:
+            repo = unfi
         return orig(repo, proto)
     finally:
-        repo.__class__ = oldrepo
-
+        unfi.__class__ = oldrepocls
 
 def _get_branch_name(ctx):
     # make it easy for extension with the branch logic there
@@ -308,6 +312,8 @@
     """run at uisetup time to install all destinations wrapping"""
     extensions.wrapfunction(discovery, '_headssummary', _headssummary)
     extensions.wrapfunction(wireprotov1server, 'branchmap', wireprotobranchmap)
+    wireprotov1server.commands.pop(b'branchmap')
+    wireprotov1server.wireprotocommand(b'branchmap', permission=b'pull')(wireprotov1server.branchmap)
     extensions.wrapfunction(wireprotov1server, '_capabilities', wireprotocaps)
     # we need a proper wrap b2 part stuff
     extensions.wrapfunction(bundle2, 'handlecheckheads', handlecheckheads)