##// END OF EJS Templates
wireproto: use new peer interface...
wireproto: use new peer interface The wirepeer class provides concrete implementations of peer interface methods for calling wire protocol commands. It makes sense for this class to inherit from the peer abstract base class. So we change that. Since httppeer and sshpeer have already been converted to the new interface, peerrepository is no longer adding any value. So it has been removed. httppeer and sshpeer have been updated to reflect the loss of peerrepository and the inheritance of the abstract base class in wirepeer. The code changes in wirepeer are reordering of methods to group by interface. Some Python code in tests was updated to reflect changed APIs. .. api:: peer.peerrepository has been removed. Use repository.peer abstract base class to represent a peer repository. Differential Revision: https://phab.mercurial-scm.org/D338

File last commit:

r33805:dedab036 default
r33805:dedab036 default
Show More
test-wireproto.py
80 lines | 1.7 KiB | text/x-python | PythonLexer
/ tests / test-wireproto.py
Pulkit Goyal
py3: make test-wireproto use print_function
r28675 from __future__ import absolute_import, print_function
Gregory Szorc
tests: use absolulte_import in test-wireproto.py
r27301
timeless
py3: use multi-line import in test-wireproto.py...
r28860 from mercurial import (
timeless
pycompat: switch to util.stringio for py3 compat
r28861 util,
timeless
py3: use multi-line import in test-wireproto.py...
r28860 wireproto,
)
timeless
pycompat: switch to util.stringio for py3 compat
r28861 stringio = util.stringio
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765
class proto(object):
def __init__(self, args):
self.args = args
def getargs(self, spec):
args = self.args
args.setdefault('*', {})
names = spec.split()
return [args[n] for n in names]
Peter Arrenbrecht
peer: introduce real peer classes...
r17192 class clientpeer(wireproto.wirepeer):
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 def __init__(self, serverrepo):
self.serverrepo = serverrepo
Augie Fackler
batching: migrate basic noop batching into peer.peer...
r25912
Gregory Szorc
wireproto: use new peer interface...
r33805 @property
def ui(self):
return self.serverrepo.ui
def url(self):
return 'test'
def local(self):
return None
def peer(self):
return self
def canpush(self):
return True
def close(self):
pass
def capabilities(self):
Augie Fackler
batching: migrate basic noop batching into peer.peer...
r25912 return ['batch']
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 def _call(self, cmd, **args):
return wireproto.dispatch(self.serverrepo, proto(args), cmd)
Augie Fackler
wireproto: make iterbatcher behave streamily over http(s)...
r28438 def _callstream(self, cmd, **args):
timeless
pycompat: switch to util.stringio for py3 compat
r28861 return stringio(self._call(cmd, **args))
Augie Fackler
wireproto: make iterbatcher behave streamily over http(s)...
r28438
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 @wireproto.batchable
def greet(self, name):
f = wireproto.future()
Augie Fackler
test-wireproto: move from dict() construction to {} literals...
r20686 yield {'name': mangle(name)}, f
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 yield unmangle(f.value)
class serverrepo(object):
def greet(self, name):
return "Hello, " + name
Pierre-Yves David
clfilter: make localpeer use a repo with "unserved" filter...
r18278 def filtered(self, name):
return self
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 def mangle(s):
return ''.join(chr(ord(c) + 1) for c in s)
def unmangle(s):
return ''.join(chr(ord(c) - 1) for c in s)
def greet(repo, proto, name):
return mangle(repo.greet(unmangle(name)))
wireproto.commands['greet'] = (greet, 'name',)
srv = serverrepo()
Peter Arrenbrecht
peer: introduce real peer classes...
r17192 clt = clientpeer(srv)
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765
Pulkit Goyal
py3: make test-wireproto use print_function
r28675 print(clt.greet("Foobar"))
Gregory Szorc
peer: remove non iterating batcher (API)...
r33762 b = clt.iterbatch()
map(b.greet, ('Fo, =;:<o', 'Bar'))
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 b.submit()
Gregory Szorc
peer: remove non iterating batcher (API)...
r33762 print([r for r in b.results()])