Mercurial > hg
diff tests/sshprotoext.py @ 35937:a9cffd14aa04
sshpeer: inline I/O into _validaterepo()
We want to move the handshake code out of the peer class so the
peer factory function can perform the handshake and instantiate
a proper class depending on the results. To make that refactor
easier to read, we first inline I/O functionality into
_validaterepo().
Test output for low-level protocol tests didn't change, thus
hopefully demonstrating that this refactor didn't change any
material behavior.
Because we no longer call _callstream(), our test extension for
monkeypatching the peer had to change its hook point.
Differential Revision: https://phab.mercurial-scm.org/D2033
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 04 Feb 2018 14:10:56 -0800 |
parents | 83d67257ba90 |
children | 80a2b8ae42a1 |
line wrap: on
line diff
--- a/tests/sshprotoext.py Mon Feb 05 14:17:24 2018 -0800 +++ b/tests/sshprotoext.py Sun Feb 04 14:10:56 2018 -0800 @@ -54,24 +54,16 @@ class extrahandshakecommandspeer(sshpeer.sshpeer): """An ssh peer that sends extra commands as part of initial handshake.""" - # There isn't a good hook point. So we wrap _callstream() and inject - # logic when the peer says "hello". - def _callstream(self, cmd, **args): - if cmd != b'hello': - return super(extrahandshakecommandspeer, self)._callstream(cmd, - **args) - + def _validaterepo(self): mode = self._ui.config(b'sshpeer', b'handshake-mode') if mode == b'pre-no-args': self._callstream(b'no-args') - return super(extrahandshakecommandspeer, self)._callstream( - cmd, **args) + return super(extrahandshakecommandspeer, self)._validaterepo() elif mode == b'pre-multiple-no-args': self._callstream(b'unknown1') self._callstream(b'unknown2') self._callstream(b'unknown3') - return super(extrahandshakecommandspeer, self)._callstream( - cmd, **args) + return super(extrahandshakecommandspeer, self)._validaterepo() else: raise error.ProgrammingError(b'unknown HANDSHAKECOMMANDMODE: %s' % mode)