Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
37052:8c3c47362934 | 37053:cd0ca979a8b8 |
---|---|
712 if v['version'] == 2} | 712 if v['version'] == 2} |
713 else: | 713 else: |
714 raise error.ProgrammingError('invalid transport policy value: %s' % | 714 raise error.ProgrammingError('invalid transport policy value: %s' % |
715 transportpolicy) | 715 transportpolicy) |
716 | 716 |
717 # Because SSHv2 is a mirror of SSHv1, we allow "batch" commands through to | |
718 # SSHv2. | |
719 # TODO undo this hack when SSH is using the unified frame protocol. | |
720 if name == b'batch': | |
721 transports.add(wireprototypes.SSHV2) | |
722 | |
717 if permission not in ('push', 'pull'): | 723 if permission not in ('push', 'pull'): |
718 raise error.ProgrammingError('invalid wire protocol permission; ' | 724 raise error.ProgrammingError('invalid wire protocol permission; ' |
719 'got %s; expected "push" or "pull"' % | 725 'got %s; expected "push" or "pull"' % |
720 permission) | 726 permission) |
721 | 727 |
724 permission=permission) | 730 permission=permission) |
725 return func | 731 return func |
726 return register | 732 return register |
727 | 733 |
728 # TODO define a more appropriate permissions type to use for this. | 734 # TODO define a more appropriate permissions type to use for this. |
729 @wireprotocommand('batch', 'cmds *', permission='pull') | 735 @wireprotocommand('batch', 'cmds *', permission='pull', |
736 transportpolicy=POLICY_V1_ONLY) | |
730 def batch(repo, proto, cmds, others): | 737 def batch(repo, proto, cmds, others): |
731 repo = repo.filtered("served") | 738 repo = repo.filtered("served") |
732 res = [] | 739 res = [] |
733 for pair in cmds.split(';'): | 740 for pair in cmds.split(';'): |
734 op, args = pair.split(' ', 1) | 741 op, args = pair.split(' ', 1) |
813 data center given the client's IP address. | 820 data center given the client's IP address. |
814 """ | 821 """ |
815 return bytesresponse(repo.vfs.tryread('clonebundles.manifest')) | 822 return bytesresponse(repo.vfs.tryread('clonebundles.manifest')) |
816 | 823 |
817 wireprotocaps = ['lookup', 'branchmap', 'pushkey', | 824 wireprotocaps = ['lookup', 'branchmap', 'pushkey', |
818 'known', 'getbundle', 'unbundlehash', 'batch'] | 825 'known', 'getbundle', 'unbundlehash'] |
819 | 826 |
820 def _capabilities(repo, proto): | 827 def _capabilities(repo, proto): |
821 """return a list of capabilities for a repo | 828 """return a list of capabilities for a repo |
822 | 829 |
823 This function exists to allow extensions to easily wrap capabilities | 830 This function exists to allow extensions to easily wrap capabilities |