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