tests/test-wireproto.py
changeset 28861 86db5cb55d46
parent 28860 50d11dd8ac02
child 33767 b47fe9733d76
equal deleted inserted replaced
28860:50d11dd8ac02 28861:86db5cb55d46
     1 from __future__ import absolute_import, print_function
     1 from __future__ import absolute_import, print_function
     2 
     2 
     3 import StringIO
       
     4 from mercurial import (
     3 from mercurial import (
       
     4     util,
     5     wireproto,
     5     wireproto,
     6 )
     6 )
       
     7 stringio = util.stringio
     7 
     8 
     8 class proto(object):
     9 class proto(object):
     9     def __init__(self, args):
    10     def __init__(self, args):
    10         self.args = args
    11         self.args = args
    11     def getargs(self, spec):
    12     def getargs(self, spec):
    23 
    24 
    24     def _call(self, cmd, **args):
    25     def _call(self, cmd, **args):
    25         return wireproto.dispatch(self.serverrepo, proto(args), cmd)
    26         return wireproto.dispatch(self.serverrepo, proto(args), cmd)
    26 
    27 
    27     def _callstream(self, cmd, **args):
    28     def _callstream(self, cmd, **args):
    28         return StringIO.StringIO(self._call(cmd, **args))
    29         return stringio(self._call(cmd, **args))
    29 
    30 
    30     @wireproto.batchable
    31     @wireproto.batchable
    31     def greet(self, name):
    32     def greet(self, name):
    32         f = wireproto.future()
    33         f = wireproto.future()
    33         yield {'name': mangle(name)}, f
    34         yield {'name': mangle(name)}, f