##// END OF EJS Templates
wireprotopeer: clarify some variable names now that we allow snake_case...
Martin von Zweigbergk -
r47209:05dd091d default
parent child Browse files
Show More
@@ -171,9 +171,9 b' def makev1commandrequest('
171 # Send arguments via HTTP headers.
171 # Send arguments via HTTP headers.
172 if headersize > 0:
172 if headersize > 0:
173 # The headers can typically carry more data than the URL.
173 # The headers can typically carry more data than the URL.
174 encargs = urlreq.urlencode(sorted(args.items()))
174 encoded_args = urlreq.urlencode(sorted(args.items()))
175 for header, value in encodevalueinheaders(
175 for header, value in encodevalueinheaders(
176 encargs, b'X-HgArg', headersize
176 encoded_args, b'X-HgArg', headersize
177 ):
177 ):
178 headers[header] = value
178 headers[header] = value
179 # Send arguments via query string (Mercurial <1.9).
179 # Send arguments via query string (Mercurial <1.9).
@@ -43,14 +43,14 b' def batchable(f):'
43 @batchable
43 @batchable
44 def sample(self, one, two=None):
44 def sample(self, one, two=None):
45 # Build list of encoded arguments suitable for your wire protocol:
45 # Build list of encoded arguments suitable for your wire protocol:
46 encargs = [('one', encode(one),), ('two', encode(two),)]
46 encoded_args = [('one', encode(one),), ('two', encode(two),)]
47 # Create future for injection of encoded result:
47 # Create future for injection of encoded result:
48 encresref = future()
48 encoded_res_future = future()
49 # Return encoded arguments and future:
49 # Return encoded arguments and future:
50 yield encargs, encresref
50 yield encoded_args, encoded_res_future
51 # Assuming the future to be filled with the result from the batched
51 # Assuming the future to be filled with the result from the batched
52 # request now. Decode it:
52 # request now. Decode it:
53 yield decode(encresref.value)
53 yield decode(encoded_res_future.value)
54
54
55 The decorator returns a function which wraps this coroutine as a plain
55 The decorator returns a function which wraps this coroutine as a plain
56 method, but adds the original method as an attribute called "batchable",
56 method, but adds the original method as an attribute called "batchable",
@@ -60,12 +60,12 b' def batchable(f):'
60
60
61 def plain(*args, **opts):
61 def plain(*args, **opts):
62 batchable = f(*args, **opts)
62 batchable = f(*args, **opts)
63 encargsorres, encresref = next(batchable)
63 encoded_args_or_res, encoded_res_future = next(batchable)
64 if not encresref:
64 if not encoded_res_future:
65 return encargsorres # a local result in this case
65 return encoded_args_or_res # a local result in this case
66 self = args[0]
66 self = args[0]
67 cmd = pycompat.bytesurl(f.__name__) # ensure cmd is ascii bytestr
67 cmd = pycompat.bytesurl(f.__name__) # ensure cmd is ascii bytestr
68 encresref.set(self._submitone(cmd, encargsorres))
68 encoded_res_future.set(self._submitone(cmd, encoded_args_or_res))
69 return next(batchable)
69 return next(batchable)
70
70
71 setattr(plain, 'batchable', f)
71 setattr(plain, 'batchable', f)
@@ -257,15 +257,15 b' class peerexecutor(object):'
257
257
258 # Encoded arguments and future holding remote result.
258 # Encoded arguments and future holding remote result.
259 try:
259 try:
260 encargsorres, fremote = next(batchable)
260 encoded_args_or_res, fremote = next(batchable)
261 except Exception:
261 except Exception:
262 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
262 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
263 return
263 return
264
264
265 if not fremote:
265 if not fremote:
266 f.set_result(encargsorres)
266 f.set_result(encoded_args_or_res)
267 else:
267 else:
268 requests.append((command, encargsorres))
268 requests.append((command, encoded_args_or_res))
269 states.append((command, f, batchable, fremote))
269 states.append((command, f, batchable, fremote))
270
270
271 if not requests:
271 if not requests:
@@ -204,7 +204,7 b' class remotething(thing):'
204
204
205 @wireprotov1peer.batchable
205 @wireprotov1peer.batchable
206 def foo(self, one, two=None):
206 def foo(self, one, two=None):
207 encargs = [
207 encoded_args = [
208 (
208 (
209 b'one',
209 b'one',
210 mangle(one),
210 mangle(one),
@@ -214,9 +214,9 b' class remotething(thing):'
214 mangle(two),
214 mangle(two),
215 ),
215 ),
216 ]
216 ]
217 encresref = wireprotov1peer.future()
217 encoded_res_future = wireprotov1peer.future()
218 yield encargs, encresref
218 yield encoded_args, encoded_res_future
219 yield unmangle(encresref.value)
219 yield unmangle(encoded_res_future.value)
220
220
221 @wireprotov1peer.batchable
221 @wireprotov1peer.batchable
222 def bar(self, b, a):
222 def bar(self, b, a):
General Comments 0
You need to be logged in to leave comments. Login now