Page MenuHomePhabricator

Enable Mercurial reads and writes over SSH
ClosedPublic

Authored by epriestley on Nov 11 2013, 12:10 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 18, 12:23 AM
Unknown Object (File)
Sun, Nov 10, 1:12 AM
Unknown Object (File)
Mon, Oct 28, 2:11 AM
Unknown Object (File)
Thu, Oct 24, 10:43 AM
Unknown Object (File)
Wed, Oct 23, 6:54 PM
Unknown Object (File)
Oct 22 2024, 1:10 PM
Unknown Object (File)
Oct 15 2024, 1:06 PM
Unknown Object (File)
Oct 15 2024, 1:02 PM
Subscribers

Details

Reviewers
asherkin
btrahan
Maniphest Tasks
Restricted Maniphest Task
Commits
Restricted Diffusion Commit
rP8840f60218ef: Enable Mercurial reads and writes over SSH
Summary

Ref T2230. This is substantially more complicated than Git, but mostly because Mercurial's protocol is a like 50 ad-hoc extensions cobbled together. Because we must decode protocol frames in order to determine if a request is read or write, 90% of this is implementing a stream parser for the protocol.

Mercurial's own parser is simpler, but relies on blocking reads. Since we don't even have methods for blocking reads right now and keeping the whole thing non-blocking is conceptually better, I made the parser nonblocking. It ends up being a lot of stuff. I made an effort to cover it reasonably well with unit tests, and to make sure we fail closed (i.e., reject requests) if there are any parts of the protocol I got wrong.

A lot of the complexity is sharable with the HTTP stuff, so it ends up being not-so-bad, just very hard to verify by inspection as clearly correct.

Test Plan
  • Ran hg clone over SSH.
  • Ran hg fetch over SSH.
  • Ran hg push over SSH, to a read-only repo (error) and a read-write repo (success).

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

src/applications/diffusion/ssh/DiffusionSSHMercurialServeWorkflow.php
60

To clarify this comment, the errors are perfectly visible and usable, we just ship them over stderr instead of actually using the special protocol error mechanism. This doesn't appreciably impact the usability, it would just be nice to have eventually.

src/applications/diffusion/ssh/DiffusionSSHMercurialWireClientProtocolChannel.php
4

good luck reviewing this

This all looks sane (and awesome!) at a once-over, nice work.

Don't think I'm crazy enough to hit Accept on it though, as I don't fully understand all the existing channel stuff.

btrahan added inline comments.
src/applications/diffusion/ssh/DiffusionSSHMercurialWireClientProtocolChannel.php
4

haha, this wasn't so bad actually. decodeStream has lots of nice comments to hold your hand.