Differences between revisions 3 and 8 (spanning 5 versions)
Revision 3 as of 2006-06-04 17:59:12
Size: 671
Comment:
Revision 8 as of 2013-12-10 13:11:16
Size: 1346
Comment: Cleaned up example a bit, and added info on --stdio
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Commands names are sent over the ssh pipe as plain text followed by newline. Arguments are sent as "[argname] [value length]\n" followed by the value. Responses are "[response length]\n" followed by the response. <<Include(A:stub)>>
Line 3: Line 3:
Examples: Command names are sent over the ssh pipe as plain text, followed by a ''single character'' linebreak. This is important on systems that automatically use a two character line-break, such as CR+LF on Windows: if there is extra whitespace on the end of the command (in the case of windows, there will be an extra CR at the end), it will not be recognized.

Arguments are sent as {{{[argname] [value length]\n}}}, followed by the value. Responses are {{{[response length]\n}}}, followed by the response.

Example:

To issue the "lookup" command on the key "tip", the client issues the following:
{{{
lookup
key 3
tip
}}

And the server might respond:
{{{
25
1 9b4a87d1a1c9c3577b12990ce5819e2955347083
}}}

===== Version detection =====
Because older Mercurial versions give no/zero-length responses to unknown commands, you must first send the ''`hello`'' command followed by a command with known output, and then determine if the ''`hello`'' command responded before the known output was sent.


=== Over STDIO ===

You can use the SSH command protocol over stdio with the following command:
Line 6: Line 31:
send:
heads
response:
41
482d3fb47d80693f929101f95944bf019009dd79
hg serve --stdio
Line 13: Line 34:
Unknown commands elicit no response in early hg versions and zero length. You can now type or otherwise send your client commands to the server directly through its STDIN stream, and it will respond on its STDOUT stream.
Line 15: Line 36:
Version detection:

Because older Mercurial versions have no response to unknown commands, to detect a version you must send the {{{hello}}} command followed by a command with known output and then determine if the {{{hello}}} command responded before the known output was sent.
----
CategoryInternals

{i} This page is an incomplete stub. Please help improve this page by expanding it, following our wiki style guidelines.

Command names are sent over the ssh pipe as plain text, followed by a single character linebreak. This is important on systems that automatically use a two character line-break, such as CR+LF on Windows: if there is extra whitespace on the end of the command (in the case of windows, there will be an extra CR at the end), it will not be recognized.

Arguments are sent as [argname] [value length]\n, followed by the value. Responses are [response length]\n, followed by the response.

Example:

To issue the "lookup" command on the key "tip", the client issues the following:

lookup
key 3
tip
}}

And the server might respond:
{{{
25
1 9b4a87d1a1c9c3577b12990ce5819e2955347083

Version detection

Because older Mercurial versions give no/zero-length responses to unknown commands, you must first send the hello command followed by a command with known output, and then determine if the hello command responded before the known output was sent.

Over STDIO

You can use the SSH command protocol over stdio with the following command:

hg serve --stdio

You can now type or otherwise send your client commands to the server directly through its STDIN stream, and it will respond on its STDOUT stream.


CategoryInternals

SshCommandProtocol (last edited 2013-12-10 13:11:46 by MaytagMetalark)