wireprotopeer: clarify some variable names now that we allow snake_case
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 09 Feb 2021 09:37:39 -0800
changeset 46480 05dd091dfa6a
parent 46479 c2435280ca63
child 46481 0d734c0ae1cf
wireprotopeer: clarify some variable names now that we allow snake_case "encargsorres" is hard to parse ("encarg sorres" sounds like it might be Spanish to me, and indeed Google Translate tells me that it's Catalan for "order sands"). Let's clarify with some added underscores and longer names. Differential Revision: https://phab.mercurial-scm.org/D9973
mercurial/httppeer.py
mercurial/wireprotov1peer.py
tests/test-batching.py
--- a/mercurial/httppeer.py	Tue Feb 02 07:02:25 2021 +0100
+++ b/mercurial/httppeer.py	Tue Feb 09 09:37:39 2021 -0800
@@ -171,9 +171,9 @@
         # Send arguments via HTTP headers.
         if headersize > 0:
             # The headers can typically carry more data than the URL.
-            encargs = urlreq.urlencode(sorted(args.items()))
+            encoded_args = urlreq.urlencode(sorted(args.items()))
             for header, value in encodevalueinheaders(
-                encargs, b'X-HgArg', headersize
+                encoded_args, b'X-HgArg', headersize
             ):
                 headers[header] = value
         # Send arguments via query string (Mercurial <1.9).
--- a/mercurial/wireprotov1peer.py	Tue Feb 02 07:02:25 2021 +0100
+++ b/mercurial/wireprotov1peer.py	Tue Feb 09 09:37:39 2021 -0800
@@ -43,14 +43,14 @@
     @batchable
     def sample(self, one, two=None):
         # Build list of encoded arguments suitable for your wire protocol:
-        encargs = [('one', encode(one),), ('two', encode(two),)]
+        encoded_args = [('one', encode(one),), ('two', encode(two),)]
         # Create future for injection of encoded result:
-        encresref = future()
+        encoded_res_future = future()
         # Return encoded arguments and future:
-        yield encargs, encresref
+        yield encoded_args, encoded_res_future
         # Assuming the future to be filled with the result from the batched
         # request now. Decode it:
-        yield decode(encresref.value)
+        yield decode(encoded_res_future.value)
 
     The decorator returns a function which wraps this coroutine as a plain
     method, but adds the original method as an attribute called "batchable",
@@ -60,12 +60,12 @@
 
     def plain(*args, **opts):
         batchable = f(*args, **opts)
-        encargsorres, encresref = next(batchable)
-        if not encresref:
-            return encargsorres  # a local result in this case
+        encoded_args_or_res, encoded_res_future = next(batchable)
+        if not encoded_res_future:
+            return encoded_args_or_res  # a local result in this case
         self = args[0]
         cmd = pycompat.bytesurl(f.__name__)  # ensure cmd is ascii bytestr
-        encresref.set(self._submitone(cmd, encargsorres))
+        encoded_res_future.set(self._submitone(cmd, encoded_args_or_res))
         return next(batchable)
 
     setattr(plain, 'batchable', f)
@@ -257,15 +257,15 @@
 
             # Encoded arguments and future holding remote result.
             try:
-                encargsorres, fremote = next(batchable)
+                encoded_args_or_res, fremote = next(batchable)
             except Exception:
                 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
                 return
 
             if not fremote:
-                f.set_result(encargsorres)
+                f.set_result(encoded_args_or_res)
             else:
-                requests.append((command, encargsorres))
+                requests.append((command, encoded_args_or_res))
                 states.append((command, f, batchable, fremote))
 
         if not requests:
--- a/tests/test-batching.py	Tue Feb 02 07:02:25 2021 +0100
+++ b/tests/test-batching.py	Tue Feb 09 09:37:39 2021 -0800
@@ -204,7 +204,7 @@
 
     @wireprotov1peer.batchable
     def foo(self, one, two=None):
-        encargs = [
+        encoded_args = [
             (
                 b'one',
                 mangle(one),
@@ -214,9 +214,9 @@
                 mangle(two),
             ),
         ]
-        encresref = wireprotov1peer.future()
-        yield encargs, encresref
-        yield unmangle(encresref.value)
+        encoded_res_future = wireprotov1peer.future()
+        yield encoded_args, encoded_res_future
+        yield unmangle(encoded_res_future.value)
 
     @wireprotov1peer.batchable
     def bar(self, b, a):