comparison tests/test-batching.py @ 28800:544908ae36ce

test-batching: stop direct symbol import of mercurial modules Silences future errors reported by import-checker.py.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 05 Apr 2016 23:10:13 +0900
parents e2b118592c63
children e2fc2122029c
comparison
equal deleted inserted replaced
28799:ccab2923a093 28800:544908ae36ce
4 # 4 #
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from __future__ import absolute_import, print_function 8 from __future__ import absolute_import, print_function
9 from mercurial.peer import ( 9
10 localbatch, 10 from mercurial import (
11 batchable, 11 peer,
12 future, 12 wireproto,
13 )
14 from mercurial.wireproto import (
15 remotebatch,
16 ) 13 )
17 14
18 # equivalent of repo.repository 15 # equivalent of repo.repository
19 class thing(object): 16 class thing(object):
20 def hello(self): 17 def hello(self):
30 return "%s und %s" % (b, a,) 27 return "%s und %s" % (b, a,)
31 def greet(self, name=None): 28 def greet(self, name=None):
32 return "Hello, %s" % name 29 return "Hello, %s" % name
33 def batch(self): 30 def batch(self):
34 '''Support for local batching.''' 31 '''Support for local batching.'''
35 return localbatch(self) 32 return peer.localbatch(self)
36 33
37 # usage of "thing" interface 34 # usage of "thing" interface
38 def use(it): 35 def use(it):
39 36
40 # Direct call to base method shared between client and server. 37 # Direct call to base method shared between client and server.
150 req = ';'.join(req) 147 req = ';'.join(req)
151 res = self._submitone('batch', [('cmds', req,)]) 148 res = self._submitone('batch', [('cmds', req,)])
152 return res.split(';') 149 return res.split(';')
153 150
154 def batch(self): 151 def batch(self):
155 return remotebatch(self) 152 return wireproto.remotebatch(self)
156 153
157 @batchable 154 @peer.batchable
158 def foo(self, one, two=None): 155 def foo(self, one, two=None):
159 if not one: 156 if not one:
160 yield "Nope", None 157 yield "Nope", None
161 encargs = [('one', mangle(one),), ('two', mangle(two),)] 158 encargs = [('one', mangle(one),), ('two', mangle(two),)]
162 encresref = future() 159 encresref = peer.future()
163 yield encargs, encresref 160 yield encargs, encresref
164 yield unmangle(encresref.value) 161 yield unmangle(encresref.value)
165 162
166 @batchable 163 @peer.batchable
167 def bar(self, b, a): 164 def bar(self, b, a):
168 encresref = future() 165 encresref = peer.future()
169 yield [('b', mangle(b),), ('a', mangle(a),)], encresref 166 yield [('b', mangle(b),), ('a', mangle(a),)], encresref
170 yield unmangle(encresref.value) 167 yield unmangle(encresref.value)
171 168
172 # greet is coded directly. It therefore does not support batching. If it 169 # greet is coded directly. It therefore does not support batching. If it
173 # does appear in a batch, the batch is split around greet, and the call to 170 # does appear in a batch, the batch is split around greet, and the call to