D5482: wireproto: in batch queries, support queries with immediate responses

valentin.gatienbaron (Valentin Gatien-Baron) phabricator at mercurial-scm.org
Thu Dec 27 07:34:06 EST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG55e8da487b8a: wireproto: in batch queries, support queries with immediate responses (authored by valentin.gatienbaron, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5482?vs=12976&id=12984

REVISION DETAIL
  https://phab.mercurial-scm.org/D5482

AFFECTED FILES
  mercurial/wireprotov1peer.py
  tests/test-missing-capability.t

CHANGE DETAILS

diff --git a/tests/test-missing-capability.t b/tests/test-missing-capability.t
new file mode 100644
--- /dev/null
+++ b/tests/test-missing-capability.t
@@ -0,0 +1,46 @@
+Checking how hg behaves when one side of a pull/push doesn't support
+some capability (because it's running an older hg version, usually).
+
+  $ hg init repo1
+  $ cd repo1
+  $ echo a > a; hg add -q a; hg commit -q -m a
+  $ hg bookmark a
+  $ hg clone -q . ../repo2
+  $ cd ../repo2
+
+  $ touch $TESTTMP/disable-lookup.py
+  $ disable_cap() {
+  >   rm -f $TESTTMP/disable-lookup.pyc # pyc caching is buggy
+  >   cat <<EOF > $TESTTMP/disable-lookup.py
+  > from mercurial import extensions, wireprotov1server
+  > def wcapabilities(orig, *args, **kwargs):
+  >   cap = orig(*args, **kwargs)
+  >   cap.remove('$1')
+  >   return cap
+  > extensions.wrapfunction(wireprotov1server, '_capabilities', wcapabilities)
+  > EOF
+  > }
+  $ cat >> ../repo1/.hg/hgrc <<EOF
+  > [extensions]
+  > disable-lookup = $TESTTMP/disable-lookup.py
+  > EOF
+  $ cat >> .hg/hgrc <<EOF
+  > [ui]
+  > ssh = "$PYTHON" "$TESTDIR/dummyssh"
+  > EOF
+
+  $ hg pull ssh://user@dummy/repo1 -r tip -B a
+  pulling from ssh://user@dummy/repo1
+  no changes found
+
+  $ disable_cap lookup
+  $ hg pull ssh://user@dummy/repo1 -r tip -B a
+  pulling from ssh://user@dummy/repo1
+  abort: other repository doesn't support revision lookup, so a rev cannot be specified.
+  [255]
+
+  $ disable_cap pushkey
+  $ hg pull ssh://user@dummy/repo1 -r tip -B a
+  pulling from ssh://user@dummy/repo1
+  abort: remote bookmark a not found!
+  [255]
diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py
--- a/mercurial/wireprotov1peer.py
+++ b/mercurial/wireprotov1peer.py
@@ -240,13 +240,16 @@
 
             # Encoded arguments and future holding remote result.
             try:
-                encodedargs, fremote = next(batchable)
+                encargsorres, fremote = next(batchable)
             except Exception:
                 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
                 return
 
-            requests.append((command, encodedargs))
-            states.append((command, f, batchable, fremote))
+            if not fremote:
+                f.set_result(encargsorres)
+            else:
+                requests.append((command, encargsorres))
+                states.append((command, f, batchable, fremote))
 
         if not requests:
             return



To: valentin.gatienbaron, #hg-reviewers
Cc: yuja, mercurial-devel


More information about the Mercurial-devel mailing list