Show More
@@ -1,139 +1,139 | |||||
1 | Verify that pending changesets are seen by pretxn* hooks but not by other |
|
1 | Verify that pending changesets are seen by pretxn* hooks but not by other | |
2 | processes that access the destination repo while the hooks are running. |
|
2 | processes that access the destination repo while the hooks are running. | |
3 |
|
3 | |||
4 | The hooks (python and external) both reject changesets after some think time, |
|
4 | The hooks (python and external) both reject changesets after some think time, | |
5 | during which another process runs pull. Each hook creates a file ('notify') to |
|
5 | during which another process runs pull. Each hook creates a file ('notify') to | |
6 | indicate to the controlling process that it is running; the process removes the |
|
6 | indicate to the controlling process that it is running; the process removes the | |
7 | file to indicate the hook can terminate. |
|
7 | file to indicate the hook can terminate. | |
8 |
|
8 | |||
9 | init env vars |
|
9 | init env vars | |
10 |
|
10 | |||
11 | $ d=`pwd` |
|
11 | $ d=`pwd` | |
12 | $ maxwait=20 |
|
12 | $ maxwait=20 | |
13 |
|
13 | |||
14 | utility to run the test - start a push in the background and run pull |
|
14 | utility to run the test - start a push in the background and run pull | |
15 |
|
15 | |||
16 | $ dotest() { |
|
16 | $ dotest() { | |
17 | > rm -f notify |
|
17 | > rm -f notify | |
18 | > printf 'push '; hg -R child-push tip --template '{node}\n' |
|
18 | > printf 'push '; hg -R child-push tip --template '{node}\n' | |
19 | > hg -R child-push -q push > push.out 2>&1 & |
|
19 | > hg -R child-push -q push > push.out 2>&1 & | |
20 | > |
|
20 | > | |
21 | > # wait for hook to create the notify file |
|
21 | > # wait for hook to create the notify file | |
22 | > i=$maxwait |
|
22 | > i=$maxwait | |
23 | > while [ ! -f notify -a $i != 0 ]; do |
|
23 | > while [ ! -f notify -a $i != 0 ]; do | |
24 | > sleep 1 |
|
24 | > sleep 1 | |
25 | > i=`expr $i - 1` |
|
25 | > i=`expr $i - 1` | |
26 | > done |
|
26 | > done | |
27 | > |
|
27 | > | |
28 | > # run pull |
|
28 | > # run pull | |
29 | > hg -R child-pull -q pull |
|
29 | > hg -R child-pull -q pull | |
30 | > rc=$? |
|
30 | > rc=$? | |
31 | > |
|
31 | > | |
32 | > # tell hook to finish; notify should exist. |
|
32 | > # tell hook to finish; notify should exist. | |
33 | > rm notify |
|
33 | > rm notify | |
34 | > wait |
|
34 | > wait | |
35 | > |
|
35 | > | |
36 | > cat push.out |
|
36 | > cat push.out | |
37 | > printf 'pull '; hg -R child-pull tip --template '{node}\n' |
|
37 | > printf 'pull '; hg -R child-pull tip --template '{node}\n' | |
38 | > return $rc |
|
38 | > return $rc | |
39 | > } |
|
39 | > } | |
40 |
|
40 | |||
41 | python hook |
|
41 | python hook | |
42 |
|
42 | |||
43 | $ cat <<EOF > reject.py |
|
43 | $ cat <<EOF > reject.py | |
44 | > import os, time |
|
44 | > import os, time | |
45 | > from mercurial import ui, localrepo |
|
45 | > from mercurial import ui, localrepo | |
46 | > def rejecthook(ui, repo, hooktype, node, **opts): |
|
46 | > def rejecthook(ui, repo, hooktype, node, **opts): | |
47 | > ui.write('hook %s\\n' % repo['tip'].hex()) |
|
47 | > ui.write(b'hook %s\\n' % repo[b'tip'].hex()) | |
48 | > # create the notify file so caller knows we're running |
|
48 | > # create the notify file so caller knows we're running | |
49 | > fpath = os.path.join('$d', 'notify') |
|
49 | > fpath = os.path.join('$d', 'notify') | |
50 | > f = open(fpath, 'w') |
|
50 | > f = open(fpath, 'w') | |
51 | > f.close() |
|
51 | > f.close() | |
52 | > # wait for ack - caller should delete the notify file |
|
52 | > # wait for ack - caller should delete the notify file | |
53 | > i = $maxwait |
|
53 | > i = $maxwait | |
54 | > while os.path.exists(fpath) and i > 0: |
|
54 | > while os.path.exists(fpath) and i > 0: | |
55 | > time.sleep(1) |
|
55 | > time.sleep(1) | |
56 | > i -= 1 |
|
56 | > i -= 1 | |
57 | > return True # reject the changesets |
|
57 | > return True # reject the changesets | |
58 | > EOF |
|
58 | > EOF | |
59 |
|
59 | |||
60 | external hook |
|
60 | external hook | |
61 |
|
61 | |||
62 | $ cat <<EOF > reject.sh |
|
62 | $ cat <<EOF > reject.sh | |
63 | > printf 'hook '; hg tip --template '{node}\\n' |
|
63 | > printf 'hook '; hg tip --template '{node}\\n' | |
64 | > # create the notify file so caller knows we're running |
|
64 | > # create the notify file so caller knows we're running | |
65 | > fpath=$d/notify |
|
65 | > fpath=$d/notify | |
66 | > touch \$fpath |
|
66 | > touch \$fpath | |
67 | > # wait for ack - caller should delete the notify file |
|
67 | > # wait for ack - caller should delete the notify file | |
68 | > i=$maxwait |
|
68 | > i=$maxwait | |
69 | > while [ -f \$fpath -a \$i != 0 ]; do |
|
69 | > while [ -f \$fpath -a \$i != 0 ]; do | |
70 | > sleep 1 |
|
70 | > sleep 1 | |
71 | > i=\`expr \$i - 1\` |
|
71 | > i=\`expr \$i - 1\` | |
72 | > done |
|
72 | > done | |
73 | > exit 1 # reject the changesets |
|
73 | > exit 1 # reject the changesets | |
74 | > EOF |
|
74 | > EOF | |
75 |
|
75 | |||
76 | create repos |
|
76 | create repos | |
77 |
|
77 | |||
78 | $ hg init parent |
|
78 | $ hg init parent | |
79 | $ hg clone -q parent child-push |
|
79 | $ hg clone -q parent child-push | |
80 | $ hg clone -q parent child-pull |
|
80 | $ hg clone -q parent child-pull | |
81 | $ echo a > child-push/a |
|
81 | $ echo a > child-push/a | |
82 | $ hg -R child-push add child-push/a |
|
82 | $ hg -R child-push add child-push/a | |
83 | $ hg -R child-push commit -m a -d '1000000 0' |
|
83 | $ hg -R child-push commit -m a -d '1000000 0' | |
84 |
|
84 | |||
85 | test python hook |
|
85 | test python hook | |
86 |
|
86 | |||
87 | $ cat <<EOF > parent/.hg/hgrc |
|
87 | $ cat <<EOF > parent/.hg/hgrc | |
88 | > [extensions] |
|
88 | > [extensions] | |
89 | > reject = $d/reject.py |
|
89 | > reject = $d/reject.py | |
90 | > [hooks] |
|
90 | > [hooks] | |
91 | > pretxnchangegroup = python:reject.rejecthook |
|
91 | > pretxnchangegroup = python:reject.rejecthook | |
92 | > EOF |
|
92 | > EOF | |
93 |
|
93 | |||
94 | $ dotest |
|
94 | $ dotest | |
95 | push 29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
|
95 | push 29b62aeb769fdf78d8d9c5f28b017f76d7ef824b | |
96 | hook 29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
|
96 | hook 29b62aeb769fdf78d8d9c5f28b017f76d7ef824b | |
97 | transaction abort! |
|
97 | transaction abort! | |
98 | rollback completed |
|
98 | rollback completed | |
99 | abort: pretxnchangegroup hook failed |
|
99 | abort: pretxnchangegroup hook failed | |
100 | pull 0000000000000000000000000000000000000000 |
|
100 | pull 0000000000000000000000000000000000000000 | |
101 |
|
101 | |||
102 | test external hook |
|
102 | test external hook | |
103 |
|
103 | |||
104 | $ cat <<EOF > parent/.hg/hgrc |
|
104 | $ cat <<EOF > parent/.hg/hgrc | |
105 | > [hooks] |
|
105 | > [hooks] | |
106 | > pretxnchangegroup = sh $d/reject.sh |
|
106 | > pretxnchangegroup = sh $d/reject.sh | |
107 | > EOF |
|
107 | > EOF | |
108 |
|
108 | |||
109 | $ dotest |
|
109 | $ dotest | |
110 | push 29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
|
110 | push 29b62aeb769fdf78d8d9c5f28b017f76d7ef824b | |
111 | hook 29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
|
111 | hook 29b62aeb769fdf78d8d9c5f28b017f76d7ef824b | |
112 | transaction abort! |
|
112 | transaction abort! | |
113 | rollback completed |
|
113 | rollback completed | |
114 | abort: pretxnchangegroup hook exited with status 1 |
|
114 | abort: pretxnchangegroup hook exited with status 1 | |
115 | pull 0000000000000000000000000000000000000000 |
|
115 | pull 0000000000000000000000000000000000000000 | |
116 |
|
116 | |||
117 | Test that pending on transaction without changegroup see the normal changegroup( |
|
117 | Test that pending on transaction without changegroup see the normal changegroup( | |
118 | (issue4609) |
|
118 | (issue4609) | |
119 |
|
119 | |||
120 | $ cat <<EOF > parent/.hg/hgrc |
|
120 | $ cat <<EOF > parent/.hg/hgrc | |
121 | > [hooks] |
|
121 | > [hooks] | |
122 | > pretxnchangegroup= |
|
122 | > pretxnchangegroup= | |
123 | > pretxnclose = hg tip -T "tip: {node|short}\n" |
|
123 | > pretxnclose = hg tip -T "tip: {node|short}\n" | |
124 | > [phases] |
|
124 | > [phases] | |
125 | > publishing=False |
|
125 | > publishing=False | |
126 | > EOF |
|
126 | > EOF | |
127 |
|
127 | |||
128 | setup |
|
128 | setup | |
129 |
|
129 | |||
130 | $ cd parent |
|
130 | $ cd parent | |
131 | $ echo a > a |
|
131 | $ echo a > a | |
132 | $ hg add a |
|
132 | $ hg add a | |
133 | $ hg commit -m a |
|
133 | $ hg commit -m a | |
134 | tip: cb9a9f314b8b |
|
134 | tip: cb9a9f314b8b | |
135 |
|
135 | |||
136 | actual test |
|
136 | actual test | |
137 |
|
137 | |||
138 | $ hg phase --public . |
|
138 | $ hg phase --public . | |
139 | tip: cb9a9f314b8b |
|
139 | tip: cb9a9f314b8b |
General Comments 0
You need to be logged in to leave comments.
Login now