Mercurial > evolve
changeset 6383:c6e3d2dbbeb0
topic: simply reuse wirepeer.branchmap() as wirepeer.branchmaptns()
The function is just parsing bytes into a dict. In this way, branchmap and
branchmaptns are completely compatible.
The only downside is that wirepeer.branchmaptns doesn't get proper function
name, so if someone needs to debug this, they might still see
"wirepeer.branchmap" in certain places even if we're calling branchmaptns.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Thu, 02 Feb 2023 10:41:52 +0400 |
parents | 3d0b5b4b262a |
children | afd252e8f6e6 |
files | hgext3rd/topic/discovery.py |
diffstat | 1 files changed, 2 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/discovery.py Wed Feb 01 18:18:35 2023 +0400 +++ b/hgext3rd/topic/discovery.py Thu Feb 02 10:41:52 2023 +0400 @@ -10,7 +10,6 @@ bundle2, discovery, encoding, - error, exchange, extensions, scmutil, @@ -18,7 +17,7 @@ wireprototypes, wireprotov1server, ) -from mercurial.wireprotov1peer import batchable, wirepeer +from mercurial.wireprotov1peer import wirepeer from . import ( common, compat, @@ -325,26 +324,6 @@ caps.append(b'topics-namespaces') return caps -def branchmaptns(self): - """copied from wirepeer.branchmap() - - Client-side command for communicating with a peer repository. Calls wire - protocol command of the same name (thanks to the batchable decorator). - """ - def decode(d): - try: - branchmap = {} - for branchpart in d.splitlines(): - branchname, branchheads = branchpart.split(b' ', 1) - branchname = encoding.tolocal(urlreq.unquote(branchname)) - branchheads = wireprototypes.decodelist(branchheads) - branchmap[branchname] = branchheads - return branchmap - except TypeError: - self._abort(error.ResponseError(_(b"unexpected response:"), d)) - - return {}, decode - def wrapbranchinfo(orig, self, rev): b, close = orig(self, rev) if common.hastopicext(self._repo): @@ -368,7 +347,7 @@ wireprotov1server.commands.pop(b'branchmap') wireprotov1server.wireprotocommand(b'branchmap', permission=b'pull')(wireprotov1server.branchmap) extensions.wrapfunction(wireprotov1server, '_capabilities', wireprotocaps) - wirepeer.branchmaptns = batchable(branchmaptns) + wirepeer.branchmaptns = wirepeer.branchmap wireprotov1server.wireprotocommand(b'branchmaptns', permission=b'pull')(wireprotobranchmaptns) extensions.wrapfunction(branchmap.revbranchcache, 'branchinfo', wrapbranchinfo) # we need a proper wrap b2 part stuff