equal
deleted
inserted
replaced
1 from __future__ import absolute_import, print_function |
1 from __future__ import absolute_import, print_function |
|
2 |
|
3 import sys |
2 |
4 |
3 from mercurial import ( |
5 from mercurial import ( |
4 error, |
6 error, |
5 pycompat, |
7 pycompat, |
6 ui as uimod, |
8 ui as uimod, |
7 util, |
9 util, |
8 wireprototypes, |
10 wireprototypes, |
9 wireprotov1peer, |
11 wireprotov1peer, |
10 wireprotov1server, |
12 wireprotov1server, |
|
13 ) |
|
14 from mercurial.utils import ( |
|
15 stringutil, |
11 ) |
16 ) |
12 stringio = util.stringio |
17 stringio = util.stringio |
13 |
18 |
14 class proto(object): |
19 class proto(object): |
15 def __init__(self, args): |
20 def __init__(self, args): |
90 wireprotov1server.commands[b'greet'] = (greet, b'name') |
95 wireprotov1server.commands[b'greet'] = (greet, b'name') |
91 |
96 |
92 srv = serverrepo() |
97 srv = serverrepo() |
93 clt = clientpeer(srv, uimod.ui()) |
98 clt = clientpeer(srv, uimod.ui()) |
94 |
99 |
95 print(clt.greet(b"Foobar")) |
100 def printb(data, end=b'\n'): |
|
101 out = getattr(sys.stdout, 'buffer', sys.stdout) |
|
102 out.write(data + end) |
|
103 out.flush() |
|
104 |
|
105 printb(clt.greet(b"Foobar")) |
96 |
106 |
97 with clt.commandexecutor() as e: |
107 with clt.commandexecutor() as e: |
98 fgreet1 = e.callcommand(b'greet', {b'name': b'Fo, =;:<o'}) |
108 fgreet1 = e.callcommand(b'greet', {b'name': b'Fo, =;:<o'}) |
99 fgreet2 = e.callcommand(b'greet', {b'name': b'Bar'}) |
109 fgreet2 = e.callcommand(b'greet', {b'name': b'Bar'}) |
100 |
110 |
101 print([f.result() for f in (fgreet1, fgreet2)]) |
111 printb(stringutil.pprint([f.result() for f in (fgreet1, fgreet2)])) |