This is an archive of the discontinued Mercurial Phabricator instance.

sshpeer: move handshake outside of sshpeer
ClosedPublic

Authored by indygreg on Feb 4 2018, 10:35 PM.

Details

Summary

With the handshake now performed before a peer class is instantiated,
we can now instantiate a different peer class depending on the results
of the handshake.

Our test extension had to change to cope with the new API. Because
we now issue the command via raw I/O calls and don't call
_callstream(), we no longer have to register the fake command.
(_callstream() uses the command registration to see what args to
send).

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Feb 4 2018, 10:35 PM
lothiraldan added inline comments.
mercurial/sshpeer.py
174

Nit that could be outside of the try: Except:

421

Nit: Could the except block could be replaced by a finally block?

indygreg marked an inline comment as done.Feb 5 2018, 12:04 PM
indygreg added inline comments.
mercurial/sshpeer.py
421

No, because the pipes are used for the remainder of the connection.

I would like to switch peers to use context managers so we have stronger lifetimes for these pipes. But that will require a bit of changes throughout the code base. If someone were to write those patches, I'd review them. This is definitely the cycle to do it, as we're breaking all the APIs around the wire protocol.

indygreg marked an inline comment as done.Feb 5 2018, 12:15 PM
indygreg updated this revision to Diff 5229.
indygreg updated this revision to Diff 5235.Feb 5 2018, 5:21 PM
yuja accepted this revision.Feb 6 2018, 8:07 AM
This revision is now accepted and ready to land.Feb 6 2018, 8:07 AM
This revision was automatically updated to reflect the committed changes.