197d10e157ce made this change for the HTTP peer. Let's do the same
for the SSH peer.
Test output changes as expected. A redundant test has been dropped.
.. bc::
Support for connecting to Mercurial servers older than 0.9.1 has been removed.
( )
lothiraldan | |
yuja |
hg-reviewers |
197d10e157ce made this change for the HTTP peer. Let's do the same
for the SSH peer.
Test output changes as expected. A redundant test has been dropped.
.. bc::
Support for connecting to Mercurial servers older than 0.9.1 has been removed.
Lint Skipped |
Unit Tests Skipped |
caps = set() | caps = set() | ||||
for l in reversed(lines): | for l in reversed(lines): | ||||
# Look for response to ``hello`` command. Scan from the back so | # Look for response to ``hello`` command. Scan from the back so | ||||
# we don't misinterpret banner output as the command reply. | # we don't misinterpret banner output as the command reply. | ||||
if l.startswith('capabilities:'): | if l.startswith('capabilities:'): | ||||
caps.update(l[:-1].split(':')[1].split()) | caps.update(l[:-1].split(':')[1].split()) | ||||
break | break | ||||
# Error if we couldn't find a response to ``hello``. This could | |||||
# mean: | |||||
# | |||||
# 1. Remote isn't a Mercurial server | |||||
# 2. Remote is a <0.9.1 Mercurial server | |||||
# 3. Remote is a future Mercurial server that dropped ``hello`` | |||||
# support. | |||||
if not caps: | |||||
badresponse() | |||||
return caps | return caps | ||||
class sshpeer(wireproto.wirepeer): | class sshpeer(wireproto.wirepeer): | ||||
def __init__(self, ui, url, proc, pipei, pipeo, pipee, caps): | def __init__(self, ui, url, proc, pipei, pipeo, pipee, caps): | ||||
"""Create a peer from an existing SSH connection. | """Create a peer from an existing SSH connection. | ||||
``proc`` is a handle on the underlying SSH process. | ``proc`` is a handle on the underlying SSH process. | ||||
``pipei``, ``pipeo``, and ``pipee`` are handles on the stdin, | ``pipei``, ``pipeo``, and ``pipee`` are handles on the stdin, |
banner: line 7 | banner: line 7 | ||||
banner: line 8 | banner: line 8 | ||||
banner: line 9 | banner: line 9 | ||||
384 | 384 | ||||
capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN | capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN | ||||
1 | 1 | ||||
Connecting to a <0.9.1 server that doesn't support the hello command | Connecting to a <0.9.1 server that doesn't support the hello command. | ||||
The client should refuse, as we dropped support for connecting to such | |||||
servers. | |||||
$ SSHSERVERMODE=no-hello hg --debug debugpeer ssh://user@dummy/server | $ SSHSERVERMODE=no-hello hg --debug debugpeer ssh://user@dummy/server | ||||
running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) | running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) | ||||
devel-peer-request: hello | devel-peer-request: hello | ||||
sending hello command | sending hello command | ||||
devel-peer-request: between | devel-peer-request: between | ||||
devel-peer-request: pairs: 81 bytes | devel-peer-request: pairs: 81 bytes | ||||
sending between command | sending between command | ||||
remote: 0 | remote: 0 | ||||
remote: 1 | remote: 1 | ||||
url: ssh://user@dummy/server | abort: no suitable response from remote hg! | ||||
local: no | [255] | ||||
pushable: yes | |||||
The client should interpret this as no capabilities | |||||
$ SSHSERVERMODE=no-hello hg debugcapabilities ssh://user@dummy/server | |||||
Main capabilities: | |||||
Sending an unknown command to the server results in an empty response to that command | Sending an unknown command to the server results in an empty response to that command | ||||
$ hg -R server serve --stdio << EOF | $ hg -R server serve --stdio << EOF | ||||
> pre-hello | > pre-hello | ||||
> hello | > hello | ||||
> between | > between | ||||
> pairs 81 | > pairs 81 |