changeset 37393:afcfdf53e4b5

wireproto: provide accessors for client capabilities For HTTP, this refactors the existing logic, including the parsing of the compression engine capability. For SSH, this adds a ssh-only capability "protocaps" and a command for informing the server on what the client supports. Since SSH is stateful, keep track of the capabilities in the server instance. Differential Revision: https://phab.mercurial-scm.org/D1944
author Joerg Sonnenberger <joerg@bec.de>
date Sat, 24 Mar 2018 17:57:22 +0100
parents a4f02a17420d
children 65705fbc9c37
files mercurial/help/internals/wireprotocol.txt mercurial/sshpeer.py mercurial/wireproto.py mercurial/wireprotoserver.py mercurial/wireprototypes.py tests/test-debugcommands.t tests/test-ssh-bundle1.t tests/test-ssh-proto-unbundle.t tests/test-ssh-proto.t tests/test-ssh.t
diffstat 10 files changed, 340 insertions(+), 233 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/help/internals/wireprotocol.txt	Thu Apr 05 17:51:10 2018 +0200
+++ b/mercurial/help/internals/wireprotocol.txt	Sat Mar 24 17:57:22 2018 +0100
@@ -451,6 +451,10 @@
 
 The server terminates if it receives an empty command (a ``\n`` character).
 
+If the server announces support for the ``protocaps`` capability, the client
+should issue a ``protocaps`` command after the initial handshake to annonunce
+its own capabilities. The client capabilities are persistent.
+
 SSH Version 2 Transport
 -----------------------
 
@@ -1121,6 +1125,13 @@
 This capability was introduced at the same time as the ``changegroupsubset``
 capability/command.
 
+protocaps
+---------
+
+Whether the server supports the ``protocaps`` command for SSH V1 transport.
+
+This capability was introduced in Mercurial 4.6.
+
 pushkey
 -------
 
@@ -1530,6 +1541,16 @@
 
 There is no trailing newline.
 
+protocaps
+---------
+
+Notify the server about the client capabilities in the SSH V1 transport
+protocol.
+
+The ``caps`` argument is a space-delimited list of capabilities.
+
+The server will reply with the string ``OK``.
+
 pushkey
 -------
 
--- a/mercurial/sshpeer.py	Thu Apr 05 17:51:10 2018 +0200
+++ b/mercurial/sshpeer.py	Sat Mar 24 17:57:22 2018 +0100
@@ -163,6 +163,17 @@
 
     return proc, stdin, stdout, stderr
 
+def _clientcapabilities():
+    """Return list of capabilities of this client.
+
+    Returns a list of capabilities that are supported by this client.
+    """
+    protoparams = []
+    comps = [e.wireprotosupport().name for e in
+             util.compengines.supportedwireengines(util.CLIENTROLE)]
+    protoparams.append('comp=%s' % ','.join(comps))
+    return protoparams
+
 def _performhandshake(ui, stdin, stdout, stderr):
     def badresponse():
         # Flush any output on stderr.
@@ -609,4 +620,15 @@
     proc, stdin, stdout, stderr = _makeconnection(ui, sshcmd, args, remotecmd,
                                                   remotepath, sshenv)
 
-    return makepeer(ui, path, proc, stdin, stdout, stderr)
+    peer = makepeer(ui, path, proc, stdin, stdout, stderr)
+
+    # Finally, if supported by the server, notify it about our own
+    # capabilities.
+    if 'protocaps' in peer.capabilities():
+        try:
+            peer._call("protocaps", caps=' '.join(_clientcapabilities()))
+        except IOError:
+            peer._cleanup()
+            raise error.RepoError(_('capability exchange failed'))
+
+    return peer
--- a/mercurial/wireproto.py	Thu Apr 05 17:51:10 2018 +0200
+++ b/mercurial/wireproto.py	Sat Mar 24 17:57:22 2018 +0100
@@ -159,6 +159,18 @@
 
     return ';'.join(cmds)
 
+def clientcompressionsupport(proto):
+    """Returns a list of compression methods supported by the client.
+
+    Returns a list of the compression methods supported by the client
+    according to the protocol capabilities. If no such capability has
+    been announced, fallback to the default of zlib and uncompressed.
+    """
+    for cap in proto.getprotocaps():
+        if cap.startswith('comp='):
+            return cap[5:].split(',')
+    return ['zlib', 'none']
+
 # mapping of options accepted by getbundle and their types
 #
 # Meant to be extended by extensions. It is extensions responsibility to ensure
@@ -1027,6 +1039,13 @@
     v = ''.join(b and '1' or '0' for b in repo.known(decodelist(nodes)))
     return wireprototypes.bytesresponse(v)
 
+@wireprotocommand('protocaps', 'caps', permission='pull',
+                  transportpolicy=POLICY_V1_ONLY)
+def protocaps(repo, proto, caps):
+    if proto.name == wireprototypes.SSHV1:
+        proto._protocaps = set(caps.split(' '))
+    return wireprototypes.bytesresponse('OK')
+
 @wireprotocommand('pushkey', 'namespace key old new', permission='push')
 def pushkey(repo, proto, namespace, key, old, new):
     # compatibility with pre-1.8 clients which were accidentally
--- a/mercurial/wireprotoserver.py	Thu Apr 05 17:51:10 2018 +0200
+++ b/mercurial/wireprotoserver.py	Sat Mar 24 17:57:22 2018 +0100
@@ -67,6 +67,7 @@
         self._req = req
         self._ui = ui
         self._checkperm = checkperm
+        self._protocaps = None
 
     @property
     def name(self):
@@ -99,6 +100,12 @@
         args.update(urlreq.parseqs(argvalue, keep_blank_values=True))
         return args
 
+    def getprotocaps(self):
+        if self._protocaps is None:
+            value = decodevaluefromheaders(self._req, r'X-HgProto')
+            self._protocaps = set(value.split(' '))
+        return self._protocaps
+
     def forwardpayload(self, fp):
         # Existing clients *always* send Content-Length.
         length = int(self._req.headers[b'Content-Length'])
@@ -599,6 +606,10 @@
 
         return [data[k] for k in args.split()]
 
+    def getprotocaps(self):
+        # Protocol capabilities are currently not implemented for HTTP V2.
+        return set()
+
     def forwardpayload(self, fp):
         raise NotImplementedError
 
@@ -615,28 +626,21 @@
     def checkperm(self, perm):
         raise NotImplementedError
 
-def _httpresponsetype(ui, req, prefer_uncompressed):
+def _httpresponsetype(ui, proto, prefer_uncompressed):
     """Determine the appropriate response type and compression settings.
 
     Returns a tuple of (mediatype, compengine, engineopts).
     """
     # Determine the response media type and compression engine based
     # on the request parameters.
-    protocaps = decodevaluefromheaders(req, 'X-HgProto').split(' ')
 
-    if '0.2' in protocaps:
+    if '0.2' in proto.getprotocaps():
         # All clients are expected to support uncompressed data.
         if prefer_uncompressed:
             return HGTYPE2, util._noopengine(), {}
 
-        # Default as defined by wire protocol spec.
-        compformats = ['zlib', 'none']
-        for cap in protocaps:
-            if cap.startswith('comp='):
-                compformats = cap[5:].split(',')
-                break
-
         # Now find an agreed upon compression format.
+        compformats = wireproto.clientcompressionsupport(proto)
         for engine in wireproto.supportedcompengines(ui, util.SERVERROLE):
             if engine.wireprotosupport().name in compformats:
                 opts = {}
@@ -705,7 +709,7 @@
         # This code for compression should not be streamres specific. It
         # is here because we only compress streamres at the moment.
         mediatype, engine, engineopts = _httpresponsetype(
-            repo.ui, req, rsp.prefer_uncompressed)
+            repo.ui, proto, rsp.prefer_uncompressed)
         gen = engine.compressstream(gen, engineopts)
 
         if mediatype == HGTYPE2:
@@ -749,6 +753,7 @@
         self._ui = ui
         self._fin = fin
         self._fout = fout
+        self._protocaps = set()
 
     @property
     def name(self):
@@ -775,6 +780,9 @@
                 data[arg] = val
         return [data[k] for k in keys]
 
+    def getprotocaps(self):
+        return self._protocaps
+
     def forwardpayload(self, fpout):
         # We initially send an empty response. This tells the client it is
         # OK to start sending data. If a client sees any other response, it
@@ -800,6 +808,8 @@
         return 'remote:ssh:' + client
 
     def addcapabilities(self, repo, caps):
+        if self.name == wireprototypes.SSHV1:
+            caps.append(b'protocaps')
         caps.append(b'batch')
         return caps
 
--- a/mercurial/wireprototypes.py	Thu Apr 05 17:51:10 2018 +0200
+++ b/mercurial/wireprototypes.py	Sat Mar 24 17:57:22 2018 +0100
@@ -117,6 +117,12 @@
 
         returns a list of values (same order as <args>)"""
 
+    def getprotocaps():
+        """Returns the list of protocol-level capabilities of client
+
+        Returns a list of capabilities as declared by the client for
+        the current request (or connection for stateful protocol handlers)."""
+
     def forwardpayload(fp):
         """Read the raw payload and forward to a file.
 
--- a/tests/test-debugcommands.t	Thu Apr 05 17:51:10 2018 +0200
+++ b/tests/test-debugcommands.t	Sat Mar 24 17:57:22 2018 +0100
@@ -407,9 +407,12 @@
   devel-peer-request: between
   devel-peer-request:   pairs: 81 bytes
   sending between command
-  remote: 403
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: 413
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   remote: 1
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   url: ssh://user@dummy/debugrevlog
   local: no
   pushable: yes
--- a/tests/test-ssh-bundle1.t	Thu Apr 05 17:51:10 2018 +0200
+++ b/tests/test-ssh-bundle1.t	Sat Mar 24 17:57:22 2018 +0100
@@ -480,10 +480,11 @@
   sending upgrade request: * proto=exp-ssh-v2-0001 (glob) (sshv2 !)
   sending hello command
   sending between command
-  remote: 403 (sshv1 !)
+  remote: 413 (sshv1 !)
   protocol upgraded to exp-ssh-v2-0001 (sshv2 !)
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   remote: 1 (sshv1 !)
+  sending protocaps command
   preparing listkeys for "bookmarks"
   sending listkeys command
   received listkey for "bookmarks": 45 bytes
--- a/tests/test-ssh-proto-unbundle.t	Thu Apr 05 17:51:10 2018 +0200
+++ b/tests/test-ssh-proto-unbundle.t	Sat Mar 24 17:57:22 2018 +0100
@@ -56,9 +56,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -110,8 +110,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending unbundle command
@@ -225,9 +225,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -285,8 +285,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending unbundle command
@@ -353,9 +353,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -414,8 +414,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending unbundle command
@@ -483,9 +483,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -543,8 +543,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending unbundle command
@@ -611,9 +611,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -672,8 +672,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending unbundle command
@@ -741,9 +741,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -804,8 +804,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending unbundle command
@@ -875,9 +875,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -935,8 +935,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending unbundle command
@@ -1003,9 +1003,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1066,8 +1066,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending unbundle command
@@ -1137,9 +1137,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1200,8 +1200,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending unbundle command
@@ -1277,9 +1277,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1338,8 +1338,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending unbundle command
@@ -1408,9 +1408,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1469,8 +1469,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending unbundle command
@@ -1541,9 +1541,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1604,8 +1604,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending unbundle command
@@ -1684,9 +1684,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1751,8 +1751,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending unbundle command
@@ -1826,9 +1826,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1882,8 +1882,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending unbundle command
@@ -1958,9 +1958,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -2018,8 +2018,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending unbundle command
--- a/tests/test-ssh-proto.t	Thu Apr 05 17:51:10 2018 +0200
+++ b/tests/test-ssh-proto.t	Sat Mar 24 17:57:22 2018 +0100
@@ -63,9 +63,12 @@
   devel-peer-request: between
   devel-peer-request:   pairs: 81 bytes
   sending between command
-  remote: 403
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: 413
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   remote: 1
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   url: ssh://user@dummy/server
   local: no
   pushable: yes
@@ -82,9 +85,9 @@
   i> write(6) -> 6:
   i>     hello\n
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
 
 `hg debugserve --sshstdio` works
 
@@ -92,8 +95,8 @@
   $ hg debugserve --sshstdio << EOF
   > hello
   > EOF
-  403
-  capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  413
+  capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
 
 I/O logging works
 
@@ -101,24 +104,24 @@
   > hello
   > EOF
   o> write(4) -> 4:
-  o>     403\n
-  o> write(403) -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
-  403
-  capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     413\n
+  o> write(413) -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
+  413
+  capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> flush() -> None
 
   $ hg debugserve --sshstdio --logiofile $TESTTMP/io << EOF
   > hello
   > EOF
-  403
-  capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  413
+  capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
 
   $ cat $TESTTMP/io
   o> write(4) -> 4:
-  o>     403\n
-  o> write(403) -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> write(413) -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> flush() -> None
 
   $ cd ..
@@ -143,9 +146,9 @@
   i> write(6) -> 6:
   i>     hello\n
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   i> write(98) -> 98:
   i>     between\n
   i>     pairs 81\n
@@ -182,9 +185,12 @@
   remote: banner: line 7
   remote: banner: line 8
   remote: banner: line 9
-  remote: 403
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: 413
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   remote: 1
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   url: ssh://user@dummy/server
   local: no
   pushable: yes
@@ -237,9 +243,9 @@
   o> readline() -> 15:
   o>     banner: line 9\n
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   i> write(98) -> 98:
   i>     between\n
   i>     pairs 81\n
@@ -290,13 +296,13 @@
   i> write(6) -> 6:
   i>     hello\n
   o> readline() -> 4:
-  o>     403\n
+  o>     413\n
   i> write(98) -> 98:
   i>     between\n
   i>     pairs 81\n
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
 
@@ -310,9 +316,12 @@
   devel-peer-request:   pairs: 81 bytes
   sending between command
   remote: 0
-  remote: 403
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: 413
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   remote: 1
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   url: ssh://user@dummy/server
   local: no
   pushable: yes
@@ -356,9 +365,9 @@
   i> write(6) -> 6:
   i>     hello\n
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   i> write(98) -> 98:
   i>     between\n
   i>     pairs 81\n
@@ -382,9 +391,12 @@
   remote: 0
   remote: 0
   remote: 0
-  remote: 403
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: 413
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   remote: 1
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   url: ssh://user@dummy/server
   local: no
   pushable: yes
@@ -436,9 +448,9 @@
   i> write(6) -> 6:
   i>     hello\n
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   i> write(98) -> 98:
   i>     between\n
   i>     pairs 81\n
@@ -483,9 +495,9 @@
   i> write(6) -> 6:
   i>     hello\n
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   i> write(98) -> 98:
   i>     between\n
   i>     pairs 81\n
@@ -528,9 +540,9 @@
   i> write(6) -> 6:
   i>     hello\n
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   i> write(98) -> 98:
   i>     between\n
   i>     pairs 81\n
@@ -598,9 +610,9 @@
   i> write(6) -> 6:
   i>     hello\n
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
 
 Incomplete dictionary send
 
@@ -680,9 +692,9 @@
   i> write(6) -> 6:
   i>     hello\n
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   i> write(98) -> 98:
   i>     between\n
   i>     pairs 81\n
@@ -714,9 +726,9 @@
   i> write(6) -> 6:
   i>     hello\n
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   i> write(98) -> 98:
   i>     between\n
   i>     pairs 81\n
@@ -757,9 +769,9 @@
   i> write(6) -> 6:
   i>     hello\n
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   i> write(98) -> 98:
   i>     between\n
   i>     pairs 81\n
@@ -786,9 +798,9 @@
   i> write(6) -> 6:
   i>     hello\n
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   i> write(105) -> 105:
   i>     between\n
   i>     pairs 81\n
@@ -827,9 +839,9 @@
   i>     pairs 81\n
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -876,9 +888,9 @@
   o> readline() -> 41:
   o>     68986213bd4485ea51533535e3fc9e78007a711f\n
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
 
@@ -903,7 +915,7 @@
   o> readline() -> 41:
   o>     68986213bd4485ea51533535e3fc9e78007a711f\n
   o> readline() -> 4:
-  o>     403\n
+  o>     413\n
 
 Send an upgrade request to a server that doesn't support that command
 
@@ -932,9 +944,9 @@
   i>     pairs 81\n
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -952,9 +964,12 @@
   devel-peer-request:   pairs: 81 bytes
   sending between command
   remote: 0
-  remote: 403
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: 413
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   remote: 1
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   url: ssh://user@dummy/server
   local: no
   pushable: yes
@@ -992,9 +1007,9 @@
   o> readline() -> 44:
   o>     upgraded this-is-some-token exp-ssh-v2-0001\n
   o> readline() -> 4:
-  o>     402\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     412\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
 
   $ cd ..
 
@@ -1008,7 +1023,10 @@
   devel-peer-request:   pairs: 81 bytes
   sending between command
   protocol upgraded to exp-ssh-v2-0001
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   url: ssh://user@dummy/server
   local: no
   pushable: yes
@@ -1025,7 +1043,10 @@
   devel-peer-request:   pairs: 81 bytes
   sending between command
   protocol upgraded to exp-ssh-v2-0001
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   Main capabilities:
     batch
     branchmap
@@ -1034,6 +1055,7 @@
     getbundle
     known
     lookup
+    protocaps
     pushkey
     streamreqs=generaldelta,revlogv1
     unbundle=HG10GZ,HG10BZ,HG10UN
@@ -1092,9 +1114,9 @@
   o> readline() -> 44:
   o>     upgraded this-is-some-token exp-ssh-v2-0001\n
   o> readline() -> 4:
-  o>     402\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     412\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   i> write(6) -> 6:
   i>     hello\n
   o> readline() -> 4:
@@ -1130,9 +1152,9 @@
   o> readline() -> 44:
   o>     upgraded this-is-some-token exp-ssh-v2-0001\n
   o> readline() -> 4:
-  o>     402\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     412\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   i> write(45) -> 45:
   i>     upgrade another-token proto=irrelevant\n
   i>     hello\n
@@ -1203,9 +1225,9 @@
   i> write(6) -> 6:
   i>     hello\n
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   i> write(98) -> 98:
   i>     between\n
   i>     pairs 81\n
@@ -1325,9 +1347,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1359,8 +1381,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending listkeys command
@@ -1405,9 +1427,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1435,8 +1457,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending listkeys command
@@ -1466,9 +1488,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1497,8 +1519,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending listkeys command
@@ -1529,9 +1551,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1562,8 +1584,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending listkeys command
@@ -1598,9 +1620,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1638,8 +1660,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending pushkey command
@@ -1690,9 +1712,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1721,8 +1743,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending listkeys command
@@ -1769,9 +1791,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1803,8 +1825,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending listkeys command
@@ -1838,9 +1860,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1871,8 +1893,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending listkeys command
@@ -1905,9 +1927,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -1936,8 +1958,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending listkeys command
@@ -1972,9 +1994,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -2013,8 +2035,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending pushkey command
@@ -2079,9 +2101,9 @@
   i>     0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
   i> flush() -> None
   o> readline() -> 4:
-  o>     403\n
-  o> readline() -> 403:
-  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch\n
+  o>     413\n
+  o> readline() -> 413:
+  o>     capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch\n
   o> readline() -> 2:
   o>     1\n
   o> readline() -> 1:
@@ -2119,8 +2141,8 @@
   o> readline() -> 62:
   o>     upgraded * exp-ssh-v2-0001\n (glob)
   o> readline() -> 4:
-  o>     402\n
-  o> read(402) -> 402: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  o>     412\n
+  o> read(412) -> 412: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   o> read(1) -> 1:
   o>     \n
   sending batch with 3 sub-commands
--- a/tests/test-ssh.t	Thu Apr 05 17:51:10 2018 +0200
+++ b/tests/test-ssh.t	Sat Mar 24 17:57:22 2018 +0100
@@ -495,10 +495,13 @@
   devel-peer-request: between
   devel-peer-request:   pairs: 81 bytes
   sending between command
-  remote: 403 (sshv1 !)
+  remote: 413 (sshv1 !)
   protocol upgraded to exp-ssh-v2-0001 (sshv2 !)
-  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN batch
+  remote: capabilities: lookup branchmap pushkey known getbundle unbundlehash changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN protocaps batch
   remote: 1 (sshv1 !)
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
   query 1; heads
   devel-peer-request: batched-content
   devel-peer-request:    - heads (0 arguments)