##// END OF EJS Templates
sshpeer: implement peer for version 2 of wire protocol...
Gregory Szorc -
r35996:59e4a778 default
parent child Browse files
Show More
@@ -326,7 +326,7 b' def _performhandshake(ui, stdin, stdout,'
326 if not caps:
326 if not caps:
327 badresponse()
327 badresponse()
328
328
329 return caps
329 return protoname, caps
330
330
331 class sshv1peer(wireproto.wirepeer):
331 class sshv1peer(wireproto.wirepeer):
332 def __init__(self, ui, url, proc, stdin, stdout, stderr, caps):
332 def __init__(self, ui, url, proc, stdin, stdout, stderr, caps):
@@ -497,6 +497,12 b' class sshv1peer(wireproto.wirepeer):'
497 self._pipeo.flush()
497 self._pipeo.flush()
498 self._readerr()
498 self._readerr()
499
499
500 class sshv2peer(sshv1peer):
501 """A peer that speakers version 2 of the transport protocol."""
502 # Currently version 2 is identical to version 1 post handshake.
503 # And handshake is performed before the peer is instantiated. So
504 # we need no custom code.
505
500 def instance(ui, path, create):
506 def instance(ui, path, create):
501 """Create an SSH peer.
507 """Create an SSH peer.
502
508
@@ -532,9 +538,16 b' def instance(ui, path, create):'
532 remotepath, sshenv)
538 remotepath, sshenv)
533
539
534 try:
540 try:
535 caps = _performhandshake(ui, stdin, stdout, stderr)
541 protoname, caps = _performhandshake(ui, stdin, stdout, stderr)
536 except Exception:
542 except Exception:
537 _cleanuppipes(ui, stdout, stdin, stderr)
543 _cleanuppipes(ui, stdout, stdin, stderr)
538 raise
544 raise
539
545
540 return sshv1peer(ui, path, proc, stdin, stdout, stderr, caps)
546 if protoname == wireprotoserver.SSHV1:
547 return sshv1peer(ui, path, proc, stdin, stdout, stderr, caps)
548 elif protoname == wireprotoserver.SSHV2:
549 return sshv2peer(ui, path, proc, stdin, stdout, stderr, caps)
550 else:
551 _cleanuppipes(ui, stdout, stdin, stderr)
552 raise error.RepoError(_('unknown version of SSH protocol: %s') %
553 protoname)
@@ -67,6 +67,8 b' def main():'
67 checkobject(localrepo.localpeer(dummyrepo()))
67 checkobject(localrepo.localpeer(dummyrepo()))
68 checkobject(sshpeer.sshv1peer(ui, 'ssh://localhost/foo', None, None, None,
68 checkobject(sshpeer.sshv1peer(ui, 'ssh://localhost/foo', None, None, None,
69 None, None))
69 None, None))
70 checkobject(sshpeer.sshv2peer(ui, 'ssh://localhost/foo', None, None, None,
71 None, None))
70 checkobject(bundlerepo.bundlepeer(dummyrepo()))
72 checkobject(bundlerepo.bundlepeer(dummyrepo()))
71 checkobject(statichttprepo.statichttppeer(dummyrepo()))
73 checkobject(statichttprepo.statichttppeer(dummyrepo()))
72 checkobject(unionrepo.unionpeer(dummyrepo()))
74 checkobject(unionrepo.unionpeer(dummyrepo()))
General Comments 0
You need to be logged in to leave comments. Login now