Show More
@@ -1,18 +1,18 b'' | |||||
1 | $ "$TESTDIR/hghave" system-sh || exit 80 |
|
|||
2 |
|
||||
3 | commit hooks can see env vars |
|
1 | commit hooks can see env vars | |
4 |
|
2 | |||
5 | $ hg init a |
|
3 | $ hg init a | |
6 | $ cd a |
|
4 | $ cd a | |
7 |
$ |
|
5 | $ cat > .hg/hgrc <<EOF | |
8 | $ echo 'commit = unset HG_LOCAL HG_TAG; python "$TESTDIR"/printenv.py commit' >> .hg/hgrc |
|
6 | > [hooks] | |
9 |
|
|
7 | > commit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit" | |
10 |
|
|
8 | > commit.b = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit.b" | |
11 |
|
|
9 | > precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= python \"$TESTDIR/printenv.py\" precommit" | |
12 | $ echo 'pretxncommit.tip = hg -q tip' >> .hg/hgrc |
|
10 | > pretxncommit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxncommit" | |
13 | $ echo 'pre-identify = python "$TESTDIR"/printenv.py pre-identify 1' >> .hg/hgrc |
|
11 | > pretxncommit.tip = hg -q tip | |
14 |
|
|
12 | > pre-identify = python "$TESTDIR/printenv.py" pre-identify 1 | |
15 |
|
|
13 | > pre-cat = python "$TESTDIR/printenv.py" pre-cat | |
|
14 | > post-cat = python "$TESTDIR/printenv.py" post-cat | |||
|
15 | > EOF | |||
16 | $ echo a > a |
|
16 | $ echo a > a | |
17 | $ hg add a |
|
17 | $ hg add a | |
18 | $ hg commit -m a |
|
18 | $ hg commit -m a | |
@@ -29,10 +29,12 b' commit hooks can see env vars' | |||||
29 |
|
29 | |||
30 | changegroup hooks can see env vars |
|
30 | changegroup hooks can see env vars | |
31 |
|
31 | |||
32 |
$ |
|
32 | $ cat > .hg/hgrc <<EOF | |
33 | $ echo 'prechangegroup = python "$TESTDIR"/printenv.py prechangegroup' >> .hg/hgrc |
|
33 | > [hooks] | |
34 |
|
|
34 | > prechangegroup = python "$TESTDIR/printenv.py" prechangegroup | |
35 |
|
|
35 | > changegroup = python "$TESTDIR/printenv.py" changegroup | |
|
36 | > incoming = python "$TESTDIR/printenv.py" incoming | |||
|
37 | > EOF | |||
36 |
|
38 | |||
37 | pretxncommit and commit hooks can see both parents of merge |
|
39 | pretxncommit and commit hooks can see both parents of merge | |
38 |
|
40 | |||
@@ -94,8 +96,10 b' test generic hooks' | |||||
94 | tag hooks can see env vars |
|
96 | tag hooks can see env vars | |
95 |
|
97 | |||
96 | $ cd ../a |
|
98 | $ cd ../a | |
97 | $ echo 'pretag = python "$TESTDIR"/printenv.py pretag' >> .hg/hgrc |
|
99 | $ cat >> .hg/hgrc <<EOF | |
98 |
|
|
100 | > pretag = python "$TESTDIR/printenv.py" pretag | |
|
101 | > tag = sh -c "HG_PARENT1= HG_PARENT2= python \"$TESTDIR/printenv.py\" tag" | |||
|
102 | > EOF | |||
99 |
$ hg tag -d '3 |
|
103 | $ hg tag -d '3 0' a | |
100 | pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a |
|
104 | pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a | |
101 | precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 |
|
105 | precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 | |
@@ -110,7 +114,7 b' tag hooks can see env vars' | |||||
110 |
|
114 | |||
111 | pretag hook can forbid tagging |
|
115 | pretag hook can forbid tagging | |
112 |
|
116 | |||
113 |
$ |
|
117 | $ echo "pretag.forbid = python \"$TESTDIR/printenv.py\" pretag.forbid 1" >> .hg/hgrc | |
114 | $ hg tag -d '4 0' fa |
|
118 | $ hg tag -d '4 0' fa | |
115 | pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa |
|
119 | pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa | |
116 | pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa |
|
120 | pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa | |
@@ -125,8 +129,8 b' pretag hook can forbid tagging' | |||||
125 | pretxncommit hook can see changeset, can roll back txn, changeset no |
|
129 | pretxncommit hook can see changeset, can roll back txn, changeset no | |
126 | more there after |
|
130 | more there after | |
127 |
|
131 | |||
128 |
$ echo |
|
132 | $ echo "pretxncommit.forbid0 = hg tip -q" >> .hg/hgrc | |
129 |
$ echo |
|
133 | $ echo "pretxncommit.forbid1 = python \"$TESTDIR/printenv.py\" pretxncommit.forbid 1" >> .hg/hgrc | |
130 | $ echo z > z |
|
134 | $ echo z > z | |
131 | $ hg add z |
|
135 | $ hg add z | |
132 | $ hg -q tip |
|
136 | $ hg -q tip | |
@@ -146,7 +150,7 b' more there after' | |||||
146 |
|
150 | |||
147 | precommit hook can prevent commit |
|
151 | precommit hook can prevent commit | |
148 |
|
152 | |||
149 |
$ echo |
|
153 | $ echo "precommit.forbid = python \"$TESTDIR/printenv.py\" precommit.forbid 1" >> .hg/hgrc | |
150 | $ hg commit -m 'fail' -d '4 0' |
|
154 | $ hg commit -m 'fail' -d '4 0' | |
151 | precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 |
|
155 | precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 | |
152 | precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 |
|
156 | precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 | |
@@ -157,14 +161,14 b' precommit hook can prevent commit' | |||||
157 |
|
161 | |||
158 | preupdate hook can prevent update |
|
162 | preupdate hook can prevent update | |
159 |
|
163 | |||
160 |
$ echo |
|
164 | $ echo "preupdate = python \"$TESTDIR/printenv.py\" preupdate" >> .hg/hgrc | |
161 | $ hg update 1 |
|
165 | $ hg update 1 | |
162 | preupdate hook: HG_PARENT1=ab228980c14d |
|
166 | preupdate hook: HG_PARENT1=ab228980c14d | |
163 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
167 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
164 |
|
168 | |||
165 | update hook |
|
169 | update hook | |
166 |
|
170 | |||
167 |
$ echo |
|
171 | $ echo "update = python \"$TESTDIR/printenv.py\" update" >> .hg/hgrc | |
168 | $ hg update |
|
172 | $ hg update | |
169 | preupdate hook: HG_PARENT1=539e4b31b6dc |
|
173 | preupdate hook: HG_PARENT1=539e4b31b6dc | |
170 | update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc |
|
174 | update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc | |
@@ -172,7 +176,7 b' update hook' | |||||
172 |
|
176 | |||
173 | pushkey hook |
|
177 | pushkey hook | |
174 |
|
178 | |||
175 |
$ echo |
|
179 | $ echo "pushkey = python \"$TESTDIR/printenv.py\" pushkey" >> .hg/hgrc | |
176 | $ cd ../b |
|
180 | $ cd ../b | |
177 | $ hg bookmark -r null foo |
|
181 | $ hg bookmark -r null foo | |
178 | $ hg push -B foo ../a |
|
182 | $ hg push -B foo ../a | |
@@ -186,7 +190,7 b' pushkey hook' | |||||
186 |
|
190 | |||
187 | listkeys hook |
|
191 | listkeys hook | |
188 |
|
192 | |||
189 |
$ echo |
|
193 | $ echo "listkeys = python \"$TESTDIR/printenv.py\" listkeys" >> .hg/hgrc | |
190 | $ hg bookmark -r null bar |
|
194 | $ hg bookmark -r null bar | |
191 | $ cd ../b |
|
195 | $ cd ../b | |
192 | $ hg pull -B bar ../a |
|
196 | $ hg pull -B bar ../a | |
@@ -201,7 +205,7 b' listkeys hook' | |||||
201 |
|
205 | |||
202 | test that prepushkey can prevent incoming keys |
|
206 | test that prepushkey can prevent incoming keys | |
203 |
|
207 | |||
204 |
$ echo |
|
208 | $ echo "prepushkey = python \"$TESTDIR/printenv.py\" prepushkey.forbid 1" >> .hg/hgrc | |
205 | $ cd ../b |
|
209 | $ cd ../b | |
206 | $ hg bookmark -r null baz |
|
210 | $ hg bookmark -r null baz | |
207 | $ hg push -B baz ../a |
|
211 | $ hg push -B baz ../a | |
@@ -219,7 +223,7 b' test that prepushkey can prevent incomin' | |||||
219 |
|
223 | |||
220 | test that prelistkeys can prevent listing keys |
|
224 | test that prelistkeys can prevent listing keys | |
221 |
|
225 | |||
222 |
$ echo |
|
226 | $ echo "prelistkeys = python \"$TESTDIR/printenv.py\" prelistkeys.forbid 1" >> .hg/hgrc | |
223 | $ hg bookmark -r null quux |
|
227 | $ hg bookmark -r null quux | |
224 | $ cd ../b |
|
228 | $ cd ../b | |
225 | $ hg pull -B quux ../a |
|
229 | $ hg pull -B quux ../a | |
@@ -234,8 +238,10 b' prechangegroup hook can prevent incoming' | |||||
234 | $ cd ../b |
|
238 | $ cd ../b | |
235 | $ hg -q tip |
|
239 | $ hg -q tip | |
236 | 3:07f3376c1e65 |
|
240 | 3:07f3376c1e65 | |
237 |
$ |
|
241 | $ cat > .hg/hgrc <<EOF | |
238 | $ echo 'prechangegroup.forbid = python "$TESTDIR"/printenv.py prechangegroup.forbid 1' >> .hg/hgrc |
|
242 | > [hooks] | |
|
243 | > prechangegroup.forbid = python "$TESTDIR/printenv.py" prechangegroup.forbid 1 | |||
|
244 | > EOF | |||
239 | $ hg pull ../a |
|
245 | $ hg pull ../a | |
240 | pulling from ../a |
|
246 | pulling from ../a | |
241 | searching for changes |
|
247 | searching for changes | |
@@ -246,9 +252,11 b' prechangegroup hook can prevent incoming' | |||||
246 | pretxnchangegroup hook can see incoming changes, can roll back txn, |
|
252 | pretxnchangegroup hook can see incoming changes, can roll back txn, | |
247 | incoming changes no longer there after |
|
253 | incoming changes no longer there after | |
248 |
|
254 | |||
249 |
$ |
|
255 | $ cat > .hg/hgrc <<EOF | |
250 | $ echo 'pretxnchangegroup.forbid0 = hg tip -q' >> .hg/hgrc |
|
256 | > [hooks] | |
251 | $ echo 'pretxnchangegroup.forbid1 = python "$TESTDIR"/printenv.py pretxnchangegroup.forbid 1' >> .hg/hgrc |
|
257 | > pretxnchangegroup.forbid0 = hg tip -q | |
|
258 | > pretxnchangegroup.forbid1 = python "$TESTDIR/printenv.py" pretxnchangegroup.forbid 1 | |||
|
259 | > EOF | |||
252 | $ hg pull ../a |
|
260 | $ hg pull ../a | |
253 | pulling from ../a |
|
261 | pulling from ../a | |
254 | searching for changes |
|
262 | searching for changes | |
@@ -268,9 +276,11 b' incoming changes no longer there after' | |||||
268 | outgoing hooks can see env vars |
|
276 | outgoing hooks can see env vars | |
269 |
|
277 | |||
270 | $ rm .hg/hgrc |
|
278 | $ rm .hg/hgrc | |
271 |
$ |
|
279 | $ cat > ../a/.hg/hgrc <<EOF | |
272 | $ echo 'preoutgoing = python "$TESTDIR"/printenv.py preoutgoing' >> ../a/.hg/hgrc |
|
280 | > [hooks] | |
273 |
|
|
281 | > preoutgoing = python "$TESTDIR/printenv.py" preoutgoing | |
|
282 | > outgoing = python "$TESTDIR/printenv.py" outgoing | |||
|
283 | > EOF | |||
274 | $ hg pull ../a |
|
284 | $ hg pull ../a | |
275 | pulling from ../a |
|
285 | pulling from ../a | |
276 | searching for changes |
|
286 | searching for changes | |
@@ -287,7 +297,7 b' outgoing hooks can see env vars' | |||||
287 |
|
297 | |||
288 | preoutgoing hook can prevent outgoing changes |
|
298 | preoutgoing hook can prevent outgoing changes | |
289 |
|
299 | |||
290 |
$ |
|
300 | $ echo "preoutgoing.forbid = python \"$TESTDIR/printenv.py\" preoutgoing.forbid 1" >> ../a/.hg/hgrc | |
291 | $ hg pull ../a |
|
301 | $ hg pull ../a | |
292 | pulling from ../a |
|
302 | pulling from ../a | |
293 | searching for changes |
|
303 | searching for changes | |
@@ -299,9 +309,11 b' preoutgoing hook can prevent outgoing ch' | |||||
299 | outgoing hooks work for local clones |
|
309 | outgoing hooks work for local clones | |
300 |
|
310 | |||
301 | $ cd .. |
|
311 | $ cd .. | |
302 |
$ |
|
312 | $ cat > a/.hg/hgrc <<EOF | |
303 | $ echo 'preoutgoing = python "$TESTDIR"/printenv.py preoutgoing' >> a/.hg/hgrc |
|
313 | > [hooks] | |
304 |
|
|
314 | > preoutgoing = python "$TESTDIR/printenv.py" preoutgoing | |
|
315 | > outgoing = python "$TESTDIR/printenv.py" outgoing | |||
|
316 | > EOF | |||
305 | $ hg clone a c |
|
317 | $ hg clone a c | |
306 | preoutgoing hook: HG_SOURCE=clone |
|
318 | preoutgoing hook: HG_SOURCE=clone | |
307 | outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone |
|
319 | outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone | |
@@ -311,13 +323,14 b' outgoing hooks work for local clones' | |||||
311 |
|
323 | |||
312 | preoutgoing hook can prevent outgoing changes for local clones |
|
324 | preoutgoing hook can prevent outgoing changes for local clones | |
313 |
|
325 | |||
314 |
$ |
|
326 | $ echo "preoutgoing.forbid = python \"$TESTDIR/printenv.py\" preoutgoing.forbid 1" >> a/.hg/hgrc | |
315 | $ hg clone a zzz |
|
327 | $ hg clone a zzz | |
316 | preoutgoing hook: HG_SOURCE=clone |
|
328 | preoutgoing hook: HG_SOURCE=clone | |
317 | preoutgoing.forbid hook: HG_SOURCE=clone |
|
329 | preoutgoing.forbid hook: HG_SOURCE=clone | |
318 | abort: preoutgoing.forbid hook exited with status 1 |
|
330 | abort: preoutgoing.forbid hook exited with status 1 | |
319 | [255] |
|
331 | [255] | |
320 | $ cd b |
|
332 | ||
|
333 | $ cd "$TESTTMP/b" | |||
321 |
|
334 | |||
322 | $ cat > hooktests.py <<EOF |
|
335 | $ cat > hooktests.py <<EOF | |
323 | > from mercurial import util |
|
336 | > from mercurial import util | |
@@ -364,7 +377,11 b' preoutgoing hook can prevent outgoing ch' | |||||
364 |
|
377 | |||
365 | test python hooks |
|
378 | test python hooks | |
366 |
|
379 | |||
367 | $ PYTHONPATH="`pwd`:$PYTHONPATH" |
|
380 | #if windows | |
|
381 | $ PYTHONPATH="$TESTTMP/b;$PYTHONPATH" | |||
|
382 | #else | |||
|
383 | $ PYTHONPATH="$TESTTMP/b:$PYTHONPATH" | |||
|
384 | #endif | |||
368 | $ export PYTHONPATH |
|
385 | $ export PYTHONPATH | |
369 |
|
386 | |||
370 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
387 | $ echo '[hooks]' > ../a/.hg/hgrc | |
@@ -597,7 +614,7 b' new commits must be visible in pretxncha' | |||||
597 | $ echo aa >> from/a |
|
614 | $ echo aa >> from/a | |
598 | $ hg --cwd from ci -mb |
|
615 | $ hg --cwd from ci -mb | |
599 | $ hg --cwd from push |
|
616 | $ hg --cwd from push | |
600 | pushing to $TESTTMP/to |
|
617 | pushing to $TESTTMP/to (glob) | |
601 | searching for changes |
|
618 | searching for changes | |
602 | adding changesets |
|
619 | adding changesets | |
603 | adding manifests |
|
620 | adding manifests |
General Comments 0
You need to be logged in to leave comments.
Login now