D318: wireproto: remove support for local results in @batchable (API)
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Thu Aug 10 06:47:39 UTC 2017
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
@peer.batchable decorated generator functions have two forms:
yield value, None
and
yield args, future
yield value
These forms have been present since the decorator was introduced.
There are currently no in-repo consumers of the first form. So this
commit removes support for it.
Note that remoteiterbatcher.submit() asserts the 2nd form. And
https://phab.mercurial-scm.org/rHGb6e71f8af5b8710139b64706a375b3f16eb1241e removed the last user of remotebatcher, forcing everyone
to remoteiterbatcher. So anything relying on this in the wild would
have been broken since https://phab.mercurial-scm.org/rHGb6e71f8af5b8710139b64706a375b3f16eb1241e.
.. api::
@peer.batchable can no longer emit local values
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D318
AFFECTED FILES
mercurial/peer.py
mercurial/wireproto.py
tests/test-batching.py
tests/test-batching.py.out
CHANGE DETAILS
diff --git a/tests/test-batching.py.out b/tests/test-batching.py.out
--- a/tests/test-batching.py.out
+++ b/tests/test-batching.py.out
@@ -4,7 +4,6 @@
Un and Deux
Eins und Zwei
One and Two
-Nope
Eins und Zwei
Hello, John Smith
Ready.
@@ -25,7 +24,6 @@
REQ: batch?cmds=bar:b=Vop,a=Evf
-> Vop!voe!Evf
One and Two
-Nope
Eins und Zwei
Hello, John Smith
Ready.
diff --git a/tests/test-batching.py b/tests/test-batching.py
--- a/tests/test-batching.py
+++ b/tests/test-batching.py
@@ -45,7 +45,6 @@
batch = it.batch()
# The calls return futures to eventually hold results.
foo = batch.foo(one="One", two="Two")
- foo2 = batch.foo(None)
bar = batch.bar("Eins", "Zwei")
# We can call non-batchable proxy methods, but the break the current batch
# request and cause additional roundtrips.
@@ -58,7 +57,6 @@
batch.submit()
# After the call to submit, the futures actually contain values.
print(foo.value)
- print(foo2.value)
print(bar.value)
print(greet.value)
print(hello.value)
@@ -153,8 +151,6 @@
@peer.batchable
def foo(self, one, two=None):
- if not one:
- yield "Nope", None
encargs = [('one', mangle(one),), ('two', mangle(two),)]
encresref = peer.future()
yield encargs, encresref
diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -95,11 +95,9 @@
if batchablefn is not None:
batchable = batchablefn(mtd.im_self, *args, **opts)
encargsorres, encresref = next(batchable)
- if encresref:
- req.append((name, encargsorres,))
- rsp.append((batchable, encresref, resref,))
- else:
- resref.set(encargsorres)
+ assert encresref
+ req.append((name, encargsorres,))
+ rsp.append((batchable, encresref, resref,))
else:
if req:
self._submitreq(req, rsp)
diff --git a/mercurial/peer.py b/mercurial/peer.py
--- a/mercurial/peer.py
+++ b/mercurial/peer.py
@@ -78,9 +78,6 @@
@batchable
def sample(self, one, two=None):
- # Handle locally computable results first:
- if not one:
- yield "a local result", None
# Build list of encoded arguments suitable for your wire protocol:
encargs = [('one', encode(one),), ('two', encode(two),)]
# Create future for injection of encoded result:
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list