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 > #!/usr/bin/env 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 > #!/usr/bin/env 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 > #!/usr/bin/env 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 |