Show More
@@ -531,6 +531,35 b' class sshv2peer(sshv1peer):' | |||||
531 | # And handshake is performed before the peer is instantiated. So |
|
531 | # And handshake is performed before the peer is instantiated. So | |
532 | # we need no custom code. |
|
532 | # we need no custom code. | |
533 |
|
533 | |||
|
534 | def makepeer(ui, path, proc, stdin, stdout, stderr): | |||
|
535 | """Make a peer instance from existing pipes. | |||
|
536 | ||||
|
537 | ``path`` and ``proc`` are stored on the eventual peer instance and may | |||
|
538 | not be used for anything meaningful. | |||
|
539 | ||||
|
540 | ``stdin``, ``stdout``, and ``stderr`` are the pipes connected to the | |||
|
541 | SSH server's stdio handles. | |||
|
542 | ||||
|
543 | This function is factored out to allow creating peers that don't | |||
|
544 | actually spawn a new process. It is useful for starting SSH protocol | |||
|
545 | servers and clients via non-standard means, which can be useful for | |||
|
546 | testing. | |||
|
547 | """ | |||
|
548 | try: | |||
|
549 | protoname, caps = _performhandshake(ui, stdin, stdout, stderr) | |||
|
550 | except Exception: | |||
|
551 | _cleanuppipes(ui, stdout, stdin, stderr) | |||
|
552 | raise | |||
|
553 | ||||
|
554 | if protoname == wireprotoserver.SSHV1: | |||
|
555 | return sshv1peer(ui, path, proc, stdin, stdout, stderr, caps) | |||
|
556 | elif protoname == wireprotoserver.SSHV2: | |||
|
557 | return sshv2peer(ui, path, proc, stdin, stdout, stderr, caps) | |||
|
558 | else: | |||
|
559 | _cleanuppipes(ui, stdout, stdin, stderr) | |||
|
560 | raise error.RepoError(_('unknown version of SSH protocol: %s') % | |||
|
561 | protoname) | |||
|
562 | ||||
534 | def instance(ui, path, create): |
|
563 | def instance(ui, path, create): | |
535 | """Create an SSH peer. |
|
564 | """Create an SSH peer. | |
536 |
|
565 | |||
@@ -565,17 +594,4 b' def instance(ui, path, create):' | |||||
565 | proc, stdin, stdout, stderr = _makeconnection(ui, sshcmd, args, remotecmd, |
|
594 | proc, stdin, stdout, stderr = _makeconnection(ui, sshcmd, args, remotecmd, | |
566 | remotepath, sshenv) |
|
595 | remotepath, sshenv) | |
567 |
|
596 | |||
568 | try: |
|
597 | return makepeer(ui, path, proc, stdin, stdout, stderr) | |
569 | protoname, caps = _performhandshake(ui, stdin, stdout, stderr) |
|
|||
570 | except Exception: |
|
|||
571 | _cleanuppipes(ui, stdout, stdin, stderr) |
|
|||
572 | raise |
|
|||
573 |
|
||||
574 | if protoname == wireprotoserver.SSHV1: |
|
|||
575 | return sshv1peer(ui, path, proc, stdin, stdout, stderr, caps) |
|
|||
576 | elif protoname == wireprotoserver.SSHV2: |
|
|||
577 | return sshv2peer(ui, path, proc, stdin, stdout, stderr, caps) |
|
|||
578 | else: |
|
|||
579 | _cleanuppipes(ui, stdout, stdin, stderr) |
|
|||
580 | raise error.RepoError(_('unknown version of SSH protocol: %s') % |
|
|||
581 | protoname) |
|
General Comments 0
You need to be logged in to leave comments.
Login now