diff mercurial/wireproto.py @ 37053:cd0ca979a8b8

wireproto: nominally don't expose "batch" to version 2 wire transports The unified frame-based protocol will (eventually) support multiple requests per client transmission. This means that the [very hacky] "batch" command has no purpose existing in this protocol. This commit marks the command as applying to v1 transports only. But because SSHv2 == SSHv1 currently, we had to hack it back in for the SSHv2 transport. Bleh. Tests changed because the capabilities string changed. The order of tokens in the string is not important. Differential Revision: https://phab.mercurial-scm.org/D2856
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 14 Mar 2018 08:18:15 -0700
parents d683c7367989
children f0b6fbea00cf
line wrap: on
line diff
--- a/mercurial/wireproto.py	Wed Mar 14 15:25:06 2018 -0700
+++ b/mercurial/wireproto.py	Wed Mar 14 08:18:15 2018 -0700
@@ -714,6 +714,12 @@
         raise error.ProgrammingError('invalid transport policy value: %s' %
                                      transportpolicy)
 
+    # Because SSHv2 is a mirror of SSHv1, we allow "batch" commands through to
+    # SSHv2.
+    # TODO undo this hack when SSH is using the unified frame protocol.
+    if name == b'batch':
+        transports.add(wireprototypes.SSHV2)
+
     if permission not in ('push', 'pull'):
         raise error.ProgrammingError('invalid wire protocol permission; '
                                      'got %s; expected "push" or "pull"' %
@@ -726,7 +732,8 @@
     return register
 
 # TODO define a more appropriate permissions type to use for this.
-@wireprotocommand('batch', 'cmds *', permission='pull')
+@wireprotocommand('batch', 'cmds *', permission='pull',
+                  transportpolicy=POLICY_V1_ONLY)
 def batch(repo, proto, cmds, others):
     repo = repo.filtered("served")
     res = []
@@ -815,7 +822,7 @@
     return bytesresponse(repo.vfs.tryread('clonebundles.manifest'))
 
 wireprotocaps = ['lookup', 'branchmap', 'pushkey',
-                 'known', 'getbundle', 'unbundlehash', 'batch']
+                 'known', 'getbundle', 'unbundlehash']
 
 def _capabilities(repo, proto):
     """return a list of capabilities for a repo