Mercurial > hg
comparison tests/sshprotoext.py @ 36064:5767664d39a5
wireprotoserver: extract SSH response handling functions
The lookup/dispatch table was cute. But it isn't needed. Future
refactors will benefit from the handlers for individual response
types living outside the class.
As part of this, I snuck in a change that changes a type compare
from str to bytes. This has no effect on Python 2. But it might
make Python 3 a bit happier.
Differential Revision: https://phab.mercurial-scm.org/D2091
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 07 Feb 2018 21:04:54 -0800 |
parents | 48a3a9283f09 |
children | bf676267f64f |
comparison
equal
deleted
inserted
replaced
36063:5a53af7d09aa | 36064:5767664d39a5 |
---|---|
43 """ | 43 """ |
44 def serve_forever(self): | 44 def serve_forever(self): |
45 l = self._fin.readline() | 45 l = self._fin.readline() |
46 assert l == b'hello\n' | 46 assert l == b'hello\n' |
47 # Respond to unknown commands with an empty reply. | 47 # Respond to unknown commands with an empty reply. |
48 self._sendresponse(b'') | 48 wireprotoserver._sshv1respondbytes(self._fout, b'') |
49 l = self._fin.readline() | 49 l = self._fin.readline() |
50 assert l == b'between\n' | 50 assert l == b'between\n' |
51 rsp = wireproto.dispatch(self._repo, self, b'between') | 51 rsp = wireproto.dispatch(self._repo, self, b'between') |
52 self._handlers[rsp.__class__](self, rsp) | 52 wireprotoserver._sshv1respondbytes(self._fout, rsp) |
53 | 53 |
54 super(prehelloserver, self).serve_forever() | 54 super(prehelloserver, self).serve_forever() |
55 | 55 |
56 class upgradev2server(wireprotoserver.sshserver): | 56 class upgradev2server(wireprotoserver.sshserver): |
57 """Tests behavior for clients that issue upgrade to version 2.""" | 57 """Tests behavior for clients that issue upgrade to version 2.""" |