Mercurial > hg
view tests/test-eol-hook.t @ 36534:5faeabb07cf5
debugcommands: support for triggering push protocol
The mechanism for pushing to a remote is a bit more complicated
than other commands. On SSH, we wait for a positive reply from
the server before we start sending the bundle payload.
This commit adds a mechanism to the "command" action in
`hg debugwireproto` to trigger the "push protocol" and to
specify a file whose contents should be submitted as the command
payload.
With this new feature, we implement a handful of tests for the
"unbundle" command. We try to cover various server failures and
hook/output scenarios so protocol behavior is as comprehensively
tested as possible. Even with so much test output, we only cover
bundle1 with Python hooks. There's still a lot of test coverage
that needs to be implemented. But this is certainly a good start.
Because there are so many new tests, we split these tests into their
own test file.
In order to make output deterministic, we need to disable the
doublepipe primitive. We add an option to `hg debugwireproto`
to do that. Because something in the bowels of the peer does a
read of stderr, we still capture read I/O from stderr. So there
is test coverage of what the server emits.
The tests around I/O capture some wonkiness. For example,
interleaved ui.write() and ui.write_err() calls are emitted in
order. However, (presumably due to buffering), print() to
sys.stdout and sys.stderr aren't in order.
We currently only test bundle1 because bundle2 is substantially
harder to test because it is more complicated (the server responds
with a stream containing a bundle2 instead of a frame).
Differential Revision: https://phab.mercurial-scm.org/D2471
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 26 Feb 2018 18:01:13 -0800 |
parents | f5b6b4e574c1 |
children | d7304434390f |
line wrap: on
line source
Test the EOL hook $ hg init main $ cat > main/.hg/hgrc <<EOF > [hooks] > pretxnchangegroup = python:hgext.eol.hook > EOF $ hg clone main fork updating to branch default 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd fork Create repo $ cat > .hgeol <<EOF > [patterns] > mixed.txt = BIN > crlf.txt = CRLF > **.txt = native > EOF $ hg add .hgeol $ hg commit -m 'Commit .hgeol' $ printf "first\nsecond\nthird\n" > a.txt $ hg add a.txt $ hg commit -m 'LF a.txt' $ hg push ../main pushing to ../main searching for changes adding changesets adding manifests adding file changes added 2 changesets with 2 changes to 2 files $ printf "first\r\nsecond\r\nthird\n" > a.txt $ hg commit -m 'CRLF a.txt' $ hg push ../main pushing to ../main searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files error: pretxnchangegroup hook failed: end-of-line check failed: a.txt in a8ee6548cd86 should not have CRLF line endings transaction abort! rollback completed abort: end-of-line check failed: a.txt in a8ee6548cd86 should not have CRLF line endings [255] $ printf "first\nsecond\nthird\n" > a.txt $ hg commit -m 'LF a.txt (fixed)' $ hg push ../main pushing to ../main searching for changes adding changesets adding manifests adding file changes added 2 changesets with 2 changes to 1 files $ printf "first\nsecond\nthird\n" > crlf.txt $ hg add crlf.txt $ hg commit -m 'LF crlf.txt' $ hg push ../main pushing to ../main searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files error: pretxnchangegroup hook failed: end-of-line check failed: crlf.txt in 004ba2132725 should not have LF line endings transaction abort! rollback completed abort: end-of-line check failed: crlf.txt in 004ba2132725 should not have LF line endings [255] $ printf "first\r\nsecond\r\nthird\r\n" > crlf.txt $ hg commit -m 'CRLF crlf.txt (fixed)' $ hg push ../main pushing to ../main searching for changes adding changesets adding manifests adding file changes added 2 changesets with 2 changes to 1 files $ printf "first\r\nsecond" > b.txt $ hg add b.txt $ hg commit -m 'CRLF b.txt' $ hg push ../main pushing to ../main searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files error: pretxnchangegroup hook failed: end-of-line check failed: b.txt in fbcf9b1025f5 should not have CRLF line endings transaction abort! rollback completed abort: end-of-line check failed: b.txt in fbcf9b1025f5 should not have CRLF line endings [255] $ hg up -r -2 0 files updated, 0 files merged, 1 files removed, 0 files unresolved $ printf "some\nother\nfile" > c.txt $ hg add c.txt $ hg commit -m "LF c.txt, b.txt doesn't exist here" created new head $ hg push -f ../main pushing to ../main searching for changes adding changesets adding manifests adding file changes added 2 changesets with 2 changes to 2 files (+1 heads) error: pretxnchangegroup hook failed: end-of-line check failed: b.txt in fbcf9b1025f5 should not have CRLF line endings transaction abort! rollback completed abort: end-of-line check failed: b.txt in fbcf9b1025f5 should not have CRLF line endings [255] Test checkheadshook alias $ cat > ../main/.hg/hgrc <<EOF > [hooks] > pretxnchangegroup = python:hgext.eol.checkheadshook > EOF $ hg push -f ../main pushing to ../main searching for changes adding changesets adding manifests adding file changes added 2 changesets with 2 changes to 2 files (+1 heads) error: pretxnchangegroup hook failed: end-of-line check failed: b.txt in fbcf9b1025f5 should not have CRLF line endings transaction abort! rollback completed abort: end-of-line check failed: b.txt in fbcf9b1025f5 should not have CRLF line endings [255] We can fix the head and push again $ hg up 6 1 files updated, 0 files merged, 1 files removed, 0 files unresolved $ printf "first\nsecond" > b.txt $ hg ci -m "remove CRLF from b.txt" $ hg push -f ../main pushing to ../main searching for changes adding changesets adding manifests adding file changes added 3 changesets with 3 changes to 2 files (+1 heads) $ hg -R ../main rollback repository tip rolled back to revision 5 (undo push) Test it still fails with checkallhook $ cat > ../main/.hg/hgrc <<EOF > [hooks] > pretxnchangegroup = python:hgext.eol.checkallhook > EOF $ hg push -f ../main pushing to ../main searching for changes adding changesets adding manifests adding file changes added 3 changesets with 3 changes to 2 files (+1 heads) error: pretxnchangegroup hook failed: end-of-line check failed: b.txt in fbcf9b1025f5 should not have CRLF line endings transaction abort! rollback completed abort: end-of-line check failed: b.txt in fbcf9b1025f5 should not have CRLF line endings [255] But we can push the clean head $ hg push -r7 -f ../main pushing to ../main searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files Test multiple files/revisions output $ printf "another\r\nbad\r\none" > d.txt $ hg add d.txt $ hg ci -m "add d.txt" $ hg push -f ../main pushing to ../main searching for changes adding changesets adding manifests adding file changes added 3 changesets with 3 changes to 2 files (+1 heads) error: pretxnchangegroup hook failed: end-of-line check failed: b.txt in fbcf9b1025f5 should not have CRLF line endings d.txt in a7040e68714f should not have CRLF line endings transaction abort! rollback completed abort: end-of-line check failed: b.txt in fbcf9b1025f5 should not have CRLF line endings d.txt in a7040e68714f should not have CRLF line endings [255] $ cd ..