debugcommands: allow sending of simple commands with debugwireproto
Previously, we only had support for low-level "raw" operations.
A goal of `hg debugwireproto` is to allow easily performing
higher-level primitives, such as sending a wire protocol command
and reading its response.
We implement a "command" action that does just this.
Currently, we only support simple commands (those without payloads).
We have basic support for sending command arguments. We don't yet
support sending dictionary arguments. This will be implemented later.
To prove it works, we add tests to test-ssh-proto.t that send some
"listkeys" commands.
Note: we don't observe/report os.read() events because these may not be
deterministic. We instead observe/report the read() and readline()
operations on the bufferedinputpipe. These *should* be deterministic.
Differential Revision: https://phab.mercurial-scm.org/D2406
$ cat > makepatch.py <<EOF
> f = open('eol.diff', 'wb')
> w = f.write
> w(b'test message\n')
> w(b'diff --git a/a b/a\n')
> w(b'--- a/a\n')
> w(b'+++ b/a\n')
> w(b'@@ -1,5 +1,5 @@\n')
> w(b' a\n')
> w(b'-bbb\r\n')
> w(b'+yyyy\r\n')
> w(b' cc\r\n')
> w(b' \n')
> w(b' d\n')
> w(b'-e\n')
> w(b'\ No newline at end of file\n')
> w(b'+z\r\n')
> w(b'\ No newline at end of file\r\n')
> EOF
$ hg init repo
$ cd repo
$ echo '\.diff' > .hgignore
Test different --eol values
$ $PYTHON -c 'open("a", "wb").write(b"a\nbbb\ncc\n\nd\ne")'
$ hg ci -Am adda
adding .hgignore
adding a
$ $PYTHON ../makepatch.py
invalid eol
$ hg --config patch.eol='LFCR' import eol.diff
applying eol.diff
abort: unsupported line endings type: LFCR
[255]
$ hg revert -a
force LF
$ hg --traceback --config patch.eol='LF' import eol.diff
applying eol.diff
$ cat a
a
yyyy
cc
d
e (no-eol)
$ hg st
force CRLF
$ hg up -C 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg --traceback --config patch.eol='CRLF' import eol.diff
applying eol.diff
$ cat a
a\r (esc)
yyyy\r (esc)
cc\r (esc)
\r (esc)
d\r (esc)
e (no-eol)
$ hg st
auto EOL on LF file
$ hg up -C 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg --traceback --config patch.eol='auto' import eol.diff
applying eol.diff
$ cat a
a
yyyy
cc
d
e (no-eol)
$ hg st
auto EOL on CRLF file
$ $PYTHON -c 'open("a", "wb").write(b"a\r\nbbb\r\ncc\r\n\r\nd\r\ne")'
$ hg commit -m 'switch EOLs in a'
$ hg --traceback --config patch.eol='auto' import eol.diff
applying eol.diff
$ cat a
a\r (esc)
yyyy\r (esc)
cc\r (esc)
\r (esc)
d\r (esc)
e (no-eol)
$ hg st
auto EOL on new file or source without any EOL
$ $PYTHON -c 'open("noeol", "wb").write(b"noeol")'
$ hg add noeol
$ hg commit -m 'add noeol'
$ $PYTHON -c 'open("noeol", "wb").write(b"noeol\r\nnoeol\n")'
$ $PYTHON -c 'open("neweol", "wb").write(b"neweol\nneweol\r\n")'
$ hg add neweol
$ hg diff --git > noeol.diff
$ hg revert --no-backup noeol neweol
$ rm neweol
$ hg --traceback --config patch.eol='auto' import -m noeol noeol.diff
applying noeol.diff
$ cat noeol
noeol\r (esc)
noeol
$ cat neweol
neweol
neweol\r (esc)
$ hg st
Test --eol and binary patches
$ $PYTHON -c 'open("b", "wb").write(b"a\x00\nb\r\nd")'
$ hg ci -Am addb
adding b
$ $PYTHON -c 'open("b", "wb").write(b"a\x00\nc\r\nd")'
$ hg diff --git > bin.diff
$ hg revert --no-backup b
binary patch with --eol
$ hg import --config patch.eol='CRLF' -m changeb bin.diff
applying bin.diff
$ cat b
a\x00 (esc)
c\r (esc)
d (no-eol)
$ hg st
$ cd ..