equal
deleted
inserted
replaced
3 from mercurial import ( |
3 from mercurial import ( |
4 error, |
4 error, |
5 pycompat, |
5 pycompat, |
6 ui as uimod, |
6 ui as uimod, |
7 util, |
7 util, |
8 wireproto, |
|
9 wireprototypes, |
8 wireprototypes, |
10 wireprotov1peer, |
9 wireprotov1peer, |
|
10 wireprotov1server, |
11 ) |
11 ) |
12 stringio = util.stringio |
12 stringio = util.stringio |
13 |
13 |
14 class proto(object): |
14 class proto(object): |
15 def __init__(self, args): |
15 def __init__(self, args): |
53 def capabilities(self): |
53 def capabilities(self): |
54 return [b'batch'] |
54 return [b'batch'] |
55 |
55 |
56 def _call(self, cmd, **args): |
56 def _call(self, cmd, **args): |
57 args = pycompat.byteskwargs(args) |
57 args = pycompat.byteskwargs(args) |
58 res = wireproto.dispatch(self.serverrepo, proto(args), cmd) |
58 res = wireprotov1server.dispatch(self.serverrepo, proto(args), cmd) |
59 if isinstance(res, wireprototypes.bytesresponse): |
59 if isinstance(res, wireprototypes.bytesresponse): |
60 return res.data |
60 return res.data |
61 elif isinstance(res, bytes): |
61 elif isinstance(res, bytes): |
62 return res |
62 return res |
63 else: |
63 else: |
85 return b''.join(pycompat.bytechr(ord(c) - 1) for c in pycompat.bytestr(s)) |
85 return b''.join(pycompat.bytechr(ord(c) - 1) for c in pycompat.bytestr(s)) |
86 |
86 |
87 def greet(repo, proto, name): |
87 def greet(repo, proto, name): |
88 return mangle(repo.greet(unmangle(name))) |
88 return mangle(repo.greet(unmangle(name))) |
89 |
89 |
90 wireproto.commands[b'greet'] = (greet, b'name',) |
90 wireprotov1server.commands[b'greet'] = (greet, b'name') |
91 |
91 |
92 srv = serverrepo() |
92 srv = serverrepo() |
93 clt = clientpeer(srv, uimod.ui()) |
93 clt = clientpeer(srv, uimod.ui()) |
94 |
94 |
95 print(clt.greet(b"Foobar")) |
95 print(clt.greet(b"Foobar")) |