Show More
@@ -1,67 +1,62 b'' | |||||
1 | Test that, when an hg push is interrupted and the remote side recieves SIGPIPE, |
|
1 | Test that, when an hg push is interrupted and the remote side recieves SIGPIPE, | |
2 | the remote hg is able to successfully roll back the transaction. |
|
2 | the remote hg is able to successfully roll back the transaction. | |
3 |
|
3 | |||
4 | $ hg init -q remote |
|
4 | $ hg init -q remote | |
5 | $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" -q ssh://user@dummy/`pwd`/remote local |
|
5 | $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" -q ssh://user@dummy/`pwd`/remote local | |
6 |
|
6 | |||
7 | $ check_for_abandoned_transaction() { |
|
7 | $ check_for_abandoned_transaction() { | |
8 |
> |
|
8 | > [ -f $TESTTMP/remote/.hg/store/journal ] && echo "Abandoned transaction!" | |
9 | > } |
|
9 | > } | |
10 |
|
10 | |||
11 | $ pidfile=`pwd`/pidfile |
|
11 | $ pidfile=`pwd`/pidfile | |
12 | $ >$pidfile |
|
12 | $ >$pidfile | |
13 |
|
13 | |||
14 | $ script() { |
|
14 | $ script() { | |
15 | > cat >"$1" |
|
15 | > cat >"$1" | |
16 | > chmod +x "$1" |
|
16 | > chmod +x "$1" | |
17 | > } |
|
17 | > } | |
18 |
|
18 | |||
19 | On the remote end, run hg, piping stdout and stderr through processes that we |
|
19 | On the remote end, run hg, piping stdout and stderr through processes that we | |
20 | know the PIDs of. We will later kill these to simulate an ssh client |
|
20 | know the PIDs of. We will later kill these to simulate an ssh client | |
21 | disconnecting. |
|
21 | disconnecting. | |
22 |
|
22 | |||
23 | $ killable_pipe=`pwd`/killable_pipe.sh |
|
23 | $ killable_pipe=`pwd`/killable_pipe.sh | |
24 | $ script $killable_pipe <<EOF |
|
24 | $ script $killable_pipe <<EOF | |
25 | > #!/bin/bash |
|
25 | > #!/bin/bash | |
26 | > echo \$\$ >> $pidfile |
|
26 | > echo \$\$ >> $pidfile | |
27 | > exec cat |
|
27 | > exec cat | |
28 | > EOF |
|
28 | > EOF | |
29 |
|
29 | |||
30 | $ remotecmd=`pwd`/remotecmd.sh |
|
30 | $ remotecmd=`pwd`/remotecmd.sh | |
31 | $ script $remotecmd <<EOF |
|
31 | $ script $remotecmd <<EOF | |
32 | > #!/bin/bash |
|
32 | > #!/bin/bash | |
33 | > hg "\$@" 1> >($killable_pipe) 2> >($killable_pipe >&2) |
|
33 | > hg "\$@" 1> >($killable_pipe) 2> >($killable_pipe >&2) | |
34 | > EOF |
|
34 | > EOF | |
35 |
|
35 | |||
36 | In the pretxnchangegroup hook, kill the PIDs recorded above to simulate ssh |
|
36 | In the pretxnchangegroup hook, kill the PIDs recorded above to simulate ssh | |
37 | disconnecting. Then exit nonzero, to force a transaction rollback. |
|
37 | disconnecting. Then exit nonzero, to force a transaction rollback. | |
38 |
|
38 | |||
39 | $ hook_script=`pwd`/pretxnchangegroup.sh |
|
39 | $ hook_script=`pwd`/pretxnchangegroup.sh | |
40 | $ script $hook_script <<EOF |
|
40 | $ script $hook_script <<EOF | |
41 | > #!/bin/bash |
|
41 | > #!/bin/bash | |
42 | > for pid in \$(cat $pidfile) ; do |
|
42 | > for pid in \$(cat $pidfile) ; do | |
43 | > kill \$pid |
|
43 | > kill \$pid | |
44 | > while kill -0 \$pid 2>/dev/null ; do |
|
44 | > while kill -0 \$pid 2>/dev/null ; do | |
45 | > sleep 0.1 |
|
45 | > sleep 0.1 | |
46 | > done |
|
46 | > done | |
47 | > done |
|
47 | > done | |
48 | > exit 1 |
|
48 | > exit 1 | |
49 | > EOF |
|
49 | > EOF | |
50 |
|
50 | |||
51 | $ cat >remote/.hg/hgrc <<EOF |
|
51 | $ cat >remote/.hg/hgrc <<EOF | |
52 | > [hooks] |
|
52 | > [hooks] | |
53 | > pretxnchangegroup.break-things=$hook_script |
|
53 | > pretxnchangegroup.break-things=$hook_script | |
54 | > EOF |
|
54 | > EOF | |
55 |
|
55 | |||
56 | $ cd local |
|
56 | $ cd local | |
57 | $ echo foo > foo ; hg commit -qAm "commit" |
|
57 | $ echo foo > foo ; hg commit -qAm "commit" | |
58 | $ hg push -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" --remotecmd $remotecmd 2>&1 | grep -v $killable_pipe |
|
58 | $ hg push -q -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" --remotecmd $remotecmd 2>&1 | grep -v $killable_pipe | |
59 | pushing to ssh://user@dummy/$TESTTMP/remote |
|
|||
60 | searching for changes |
|
|||
61 | remote: adding changesets |
|
|||
62 | remote: adding manifests |
|
|||
63 | remote: adding file changes |
|
|||
64 | abort: stream ended unexpectedly (got 0 bytes, expected 4) |
|
59 | abort: stream ended unexpectedly (got 0 bytes, expected 4) | |
65 |
|
60 | |||
66 | $ check_for_abandoned_transaction |
|
61 | $ check_for_abandoned_transaction | |
67 | [1] |
|
62 | [1] |
General Comments 0
You need to be logged in to leave comments.
Login now