Mercurial > evolve
comparison hgext3rd/topic/server.py @ 6572:ef04d887c9a0
topic: compatibility for tns_heads peer command with Mercurial 5.9 and older
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 13 Oct 2023 15:16:18 -0300 |
parents | 2d3771d61068 |
children | d511eba4cdb0 |
comparison
equal
deleted
inserted
replaced
6571:40875ca5e724 | 6572:ef04d887c9a0 |
---|---|
8 branchmap, | 8 branchmap, |
9 error, | 9 error, |
10 extensions, | 10 extensions, |
11 localrepo, | 11 localrepo, |
12 repoview, | 12 repoview, |
13 util, | |
13 wireprototypes, | 14 wireprototypes, |
14 wireprotov1peer, | 15 wireprotov1peer, |
15 wireprotov1server, | 16 wireprotov1server, |
16 ) | 17 ) |
17 | 18 |
101 wireprotov1server.wireprotocommand(b'heads', permission=b'pull')(wireprotov1server.heads) | 102 wireprotov1server.wireprotocommand(b'heads', permission=b'pull')(wireprotov1server.heads) |
102 wireprotov1server.wireprotocommand(b'_exttopics_heads', permission=b'pull')(topicheads) | 103 wireprotov1server.wireprotocommand(b'_exttopics_heads', permission=b'pull')(topicheads) |
103 wireprotov1server.wireprotocommand(b'tns_heads', b'namespaces', permission=b'pull')(tns_heads) | 104 wireprotov1server.wireprotocommand(b'tns_heads', b'namespaces', permission=b'pull')(tns_heads) |
104 extensions.wrapfunction(wireprotov1server, '_capabilities', wireprotocaps) | 105 extensions.wrapfunction(wireprotov1server, '_capabilities', wireprotocaps) |
105 | 106 |
106 class tnspeer(wireprotov1peer.wirepeer): | 107 if util.safehasattr(wireprotov1peer, 'future'): |
107 @wireprotov1peer.batchable | 108 # hg <= 5.9 (c424ff4807e6) |
108 def tns_heads(self, namespaces): | 109 class tnspeer(wireprotov1peer.wirepeer): |
109 def decode(d): | 110 """ wirepeer that uses `future` class from before c424ff4807e6 """ |
111 @wireprotov1peer.batchable | |
112 def tns_heads(self, namespaces): | |
113 f = wireprotov1peer.future() | |
114 yield {b'namespaces': wireprototypes.encodelist(namespaces)}, f | |
115 d = f.value | |
110 try: | 116 try: |
111 return wireprototypes.decodelist(d[:-1]) | 117 yield wireprototypes.decodelist(d[:-1]) |
112 except ValueError: | 118 except ValueError: |
113 self._abort(error.ResponseError(_(b"unexpected response:"), d)) | 119 self._abort(error.ResponseError(_(b"unexpected response:"), d)) |
120 else: | |
121 class tnspeer(wireprotov1peer.wirepeer): | |
122 """ wirepeer that uses newer batchable scheme from c424ff4807e6 """ | |
123 @wireprotov1peer.batchable | |
124 def tns_heads(self, namespaces): | |
125 def decode(d): | |
126 try: | |
127 return wireprototypes.decodelist(d[:-1]) | |
128 except ValueError: | |
129 self._abort(error.ResponseError(_(b"unexpected response:"), d)) | |
114 | 130 |
115 return {b'namespaces': wireprototypes.encodelist(namespaces)}, decode | 131 return {b'namespaces': wireprototypes.encodelist(namespaces)}, decode |
116 | 132 |
117 wireprotov1peer.wirepeer = tnspeer | 133 wireprotov1peer.wirepeer = tnspeer |
118 | 134 |
119 class topicpeerexecutor(wireprotov1peer.peerexecutor): | 135 class topicpeerexecutor(wireprotov1peer.peerexecutor): |
120 | 136 |