15 |
15 |
16 $ hg init a |
16 $ hg init a |
17 $ cd a |
17 $ cd a |
18 $ cat > .hg/hgrc <<EOF |
18 $ cat > .hg/hgrc <<EOF |
19 > [hooks] |
19 > [hooks] |
20 > commit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit" |
20 > commit = sh -c "HG_LOCAL= HG_TAG= printenv.py commit" |
21 > commit.b = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit.b" |
21 > commit.b = sh -c "HG_LOCAL= HG_TAG= printenv.py commit.b" |
22 > precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= python \"$TESTDIR/printenv.py\" precommit" |
22 > precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= printenv.py precommit" |
23 > pretxncommit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxncommit" |
23 > pretxncommit = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxncommit" |
24 > pretxncommit.tip = hg -q tip |
24 > pretxncommit.tip = hg -q tip |
25 > pre-identify = python "$TESTDIR/printenv.py" pre-identify 1 |
25 > pre-identify = printenv.py pre-identify 1 |
26 > pre-cat = python "$TESTDIR/printenv.py" pre-cat |
26 > pre-cat = printenv.py pre-cat |
27 > post-cat = python "$TESTDIR/printenv.py" post-cat |
27 > post-cat = printenv.py post-cat |
28 > pretxnopen = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxnopen" |
28 > pretxnopen = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnopen" |
29 > pretxnclose = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxnclose" |
29 > pretxnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnclose" |
30 > txnclose = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" txnclose" |
30 > txnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py txnclose" |
31 > txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs |
31 > txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs |
32 > txnabort.1 = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" txnabort" |
32 > txnabort.1 = sh -c "HG_LOCAL= HG_TAG= printenv.py txnabort" |
33 > txnclose.checklock = sh -c "hg debuglock > /dev/null" |
33 > txnclose.checklock = sh -c "hg debuglock > /dev/null" |
34 > EOF |
34 > EOF |
35 $ echo a > a |
35 $ echo a > a |
36 $ hg add a |
36 $ hg add a |
37 $ hg commit -m a |
37 $ hg commit -m a |
51 |
51 |
52 changegroup hooks can see env vars |
52 changegroup hooks can see env vars |
53 |
53 |
54 $ cat > .hg/hgrc <<EOF |
54 $ cat > .hg/hgrc <<EOF |
55 > [hooks] |
55 > [hooks] |
56 > prechangegroup = python "$TESTDIR/printenv.py" prechangegroup |
56 > prechangegroup = printenv.py prechangegroup |
57 > changegroup = python "$TESTDIR/printenv.py" changegroup |
57 > changegroup = printenv.py changegroup |
58 > incoming = python "$TESTDIR/printenv.py" incoming |
58 > incoming = printenv.py incoming |
59 > EOF |
59 > EOF |
60 |
60 |
61 pretxncommit and commit hooks can see both parents of merge |
61 pretxncommit and commit hooks can see both parents of merge |
62 |
62 |
63 $ cd ../a |
63 $ cd ../a |
126 |
126 |
127 tag hooks can see env vars |
127 tag hooks can see env vars |
128 |
128 |
129 $ cd ../a |
129 $ cd ../a |
130 $ cat >> .hg/hgrc <<EOF |
130 $ cat >> .hg/hgrc <<EOF |
131 > pretag = python "$TESTDIR/printenv.py" pretag |
131 > pretag = printenv.py pretag |
132 > tag = sh -c "HG_PARENT1= HG_PARENT2= python \"$TESTDIR/printenv.py\" tag" |
132 > tag = sh -c "HG_PARENT1= HG_PARENT2= printenv.py tag" |
133 > EOF |
133 > EOF |
134 $ hg tag -d '3 0' a |
134 $ hg tag -d '3 0' a |
135 pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a |
135 pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a |
136 precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 |
136 precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 |
137 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
137 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
146 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la |
146 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la |
147 tag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la |
147 tag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la |
148 |
148 |
149 pretag hook can forbid tagging |
149 pretag hook can forbid tagging |
150 |
150 |
151 $ echo "pretag.forbid = python \"$TESTDIR/printenv.py\" pretag.forbid 1" >> .hg/hgrc |
151 $ echo "pretag.forbid = printenv.py pretag.forbid 1" >> .hg/hgrc |
152 $ hg tag -d '4 0' fa |
152 $ hg tag -d '4 0' fa |
153 pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa |
153 pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa |
154 pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa |
154 pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa |
155 abort: pretag.forbid hook exited with status 1 |
155 abort: pretag.forbid hook exited with status 1 |
156 [255] |
156 [255] |
162 |
162 |
163 pretxncommit hook can see changeset, can roll back txn, changeset no |
163 pretxncommit hook can see changeset, can roll back txn, changeset no |
164 more there after |
164 more there after |
165 |
165 |
166 $ echo "pretxncommit.forbid0 = hg tip -q" >> .hg/hgrc |
166 $ echo "pretxncommit.forbid0 = hg tip -q" >> .hg/hgrc |
167 $ echo "pretxncommit.forbid1 = python \"$TESTDIR/printenv.py\" pretxncommit.forbid 1" >> .hg/hgrc |
167 $ echo "pretxncommit.forbid1 = printenv.py pretxncommit.forbid 1" >> .hg/hgrc |
168 $ echo z > z |
168 $ echo z > z |
169 $ hg add z |
169 $ hg add z |
170 $ hg -q tip |
170 $ hg -q tip |
171 4:539e4b31b6dc |
171 4:539e4b31b6dc |
172 $ hg commit -m 'fail' -d '4 0' |
172 $ hg commit -m 'fail' -d '4 0' |
200 undo.phaseroots |
200 undo.phaseroots |
201 |
201 |
202 |
202 |
203 precommit hook can prevent commit |
203 precommit hook can prevent commit |
204 |
204 |
205 $ echo "precommit.forbid = python \"$TESTDIR/printenv.py\" precommit.forbid 1" >> .hg/hgrc |
205 $ echo "precommit.forbid = printenv.py precommit.forbid 1" >> .hg/hgrc |
206 $ hg commit -m 'fail' -d '4 0' |
206 $ hg commit -m 'fail' -d '4 0' |
207 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 |
207 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 |
208 precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 |
208 precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 |
209 abort: precommit.forbid hook exited with status 1 |
209 abort: precommit.forbid hook exited with status 1 |
210 [255] |
210 [255] |
211 $ hg -q tip |
211 $ hg -q tip |
212 4:539e4b31b6dc |
212 4:539e4b31b6dc |
213 |
213 |
214 preupdate hook can prevent update |
214 preupdate hook can prevent update |
215 |
215 |
216 $ echo "preupdate = python \"$TESTDIR/printenv.py\" preupdate" >> .hg/hgrc |
216 $ echo "preupdate = printenv.py preupdate" >> .hg/hgrc |
217 $ hg update 1 |
217 $ hg update 1 |
218 preupdate hook: HG_PARENT1=ab228980c14d |
218 preupdate hook: HG_PARENT1=ab228980c14d |
219 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
219 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
220 |
220 |
221 update hook |
221 update hook |
222 |
222 |
223 $ echo "update = python \"$TESTDIR/printenv.py\" update" >> .hg/hgrc |
223 $ echo "update = printenv.py update" >> .hg/hgrc |
224 $ hg update |
224 $ hg update |
225 preupdate hook: HG_PARENT1=539e4b31b6dc |
225 preupdate hook: HG_PARENT1=539e4b31b6dc |
226 update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc |
226 update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc |
227 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
227 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
228 |
228 |
229 pushkey hook |
229 pushkey hook |
230 |
230 |
231 $ echo "pushkey = python \"$TESTDIR/printenv.py\" pushkey" >> .hg/hgrc |
231 $ echo "pushkey = printenv.py pushkey" >> .hg/hgrc |
232 $ cd ../b |
232 $ cd ../b |
233 $ hg bookmark -r null foo |
233 $ hg bookmark -r null foo |
234 $ hg push -B foo ../a |
234 $ hg push -B foo ../a |
235 pushing to ../a |
235 pushing to ../a |
236 searching for changes |
236 searching for changes |
243 [1] |
243 [1] |
244 $ cd ../a |
244 $ cd ../a |
245 |
245 |
246 listkeys hook |
246 listkeys hook |
247 |
247 |
248 $ echo "listkeys = python \"$TESTDIR/printenv.py\" listkeys" >> .hg/hgrc |
248 $ echo "listkeys = printenv.py listkeys" >> .hg/hgrc |
249 $ hg bookmark -r null bar |
249 $ hg bookmark -r null bar |
250 $ cd ../b |
250 $ cd ../b |
251 $ hg pull -B bar ../a |
251 $ hg pull -B bar ../a |
252 pulling from ../a |
252 pulling from ../a |
253 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'} |
253 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'} |
257 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'} |
257 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'} |
258 $ cd ../a |
258 $ cd ../a |
259 |
259 |
260 test that prepushkey can prevent incoming keys |
260 test that prepushkey can prevent incoming keys |
261 |
261 |
262 $ echo "prepushkey = python \"$TESTDIR/printenv.py\" prepushkey.forbid 1" >> .hg/hgrc |
262 $ echo "prepushkey = printenv.py prepushkey.forbid 1" >> .hg/hgrc |
263 $ cd ../b |
263 $ cd ../b |
264 $ hg bookmark -r null baz |
264 $ hg bookmark -r null baz |
265 $ hg push -B baz ../a |
265 $ hg push -B baz ../a |
266 pushing to ../a |
266 pushing to ../a |
267 searching for changes |
267 searching for changes |
278 [1] |
278 [1] |
279 $ cd ../a |
279 $ cd ../a |
280 |
280 |
281 test that prelistkeys can prevent listing keys |
281 test that prelistkeys can prevent listing keys |
282 |
282 |
283 $ echo "prelistkeys = python \"$TESTDIR/printenv.py\" prelistkeys.forbid 1" >> .hg/hgrc |
283 $ echo "prelistkeys = printenv.py prelistkeys.forbid 1" >> .hg/hgrc |
284 $ hg bookmark -r null quux |
284 $ hg bookmark -r null quux |
285 $ cd ../b |
285 $ cd ../b |
286 $ hg pull -B quux ../a |
286 $ hg pull -B quux ../a |
287 pulling from ../a |
287 pulling from ../a |
288 prelistkeys.forbid hook: HG_NAMESPACE=bookmarks |
288 prelistkeys.forbid hook: HG_NAMESPACE=bookmarks |
311 incoming changes no longer there after |
311 incoming changes no longer there after |
312 |
312 |
313 $ cat > .hg/hgrc <<EOF |
313 $ cat > .hg/hgrc <<EOF |
314 > [hooks] |
314 > [hooks] |
315 > pretxnchangegroup.forbid0 = hg tip -q |
315 > pretxnchangegroup.forbid0 = hg tip -q |
316 > pretxnchangegroup.forbid1 = python "$TESTDIR/printenv.py" pretxnchangegroup.forbid 1 |
316 > pretxnchangegroup.forbid1 = printenv.py pretxnchangegroup.forbid 1 |
317 > EOF |
317 > EOF |
318 $ hg pull ../a |
318 $ hg pull ../a |
319 pulling from ../a |
319 pulling from ../a |
320 searching for changes |
320 searching for changes |
321 adding changesets |
321 adding changesets |
334 outgoing hooks can see env vars |
334 outgoing hooks can see env vars |
335 |
335 |
336 $ rm .hg/hgrc |
336 $ rm .hg/hgrc |
337 $ cat > ../a/.hg/hgrc <<EOF |
337 $ cat > ../a/.hg/hgrc <<EOF |
338 > [hooks] |
338 > [hooks] |
339 > preoutgoing = python "$TESTDIR/printenv.py" preoutgoing |
339 > preoutgoing = printenv.py preoutgoing |
340 > outgoing = python "$TESTDIR/printenv.py" outgoing |
340 > outgoing = printenv.py outgoing |
341 > EOF |
341 > EOF |
342 $ hg pull ../a |
342 $ hg pull ../a |
343 pulling from ../a |
343 pulling from ../a |
344 searching for changes |
344 searching for changes |
345 preoutgoing hook: HG_SOURCE=pull |
345 preoutgoing hook: HG_SOURCE=pull |
353 $ hg rollback |
353 $ hg rollback |
354 repository tip rolled back to revision 3 (undo pull) |
354 repository tip rolled back to revision 3 (undo pull) |
355 |
355 |
356 preoutgoing hook can prevent outgoing changes |
356 preoutgoing hook can prevent outgoing changes |
357 |
357 |
358 $ echo "preoutgoing.forbid = python \"$TESTDIR/printenv.py\" preoutgoing.forbid 1" >> ../a/.hg/hgrc |
358 $ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> ../a/.hg/hgrc |
359 $ hg pull ../a |
359 $ hg pull ../a |
360 pulling from ../a |
360 pulling from ../a |
361 searching for changes |
361 searching for changes |
362 preoutgoing hook: HG_SOURCE=pull |
362 preoutgoing hook: HG_SOURCE=pull |
363 preoutgoing.forbid hook: HG_SOURCE=pull |
363 preoutgoing.forbid hook: HG_SOURCE=pull |
367 outgoing hooks work for local clones |
367 outgoing hooks work for local clones |
368 |
368 |
369 $ cd .. |
369 $ cd .. |
370 $ cat > a/.hg/hgrc <<EOF |
370 $ cat > a/.hg/hgrc <<EOF |
371 > [hooks] |
371 > [hooks] |
372 > preoutgoing = python "$TESTDIR/printenv.py" preoutgoing |
372 > preoutgoing = printenv.py preoutgoing |
373 > outgoing = python "$TESTDIR/printenv.py" outgoing |
373 > outgoing = printenv.py outgoing |
374 > EOF |
374 > EOF |
375 $ hg clone a c |
375 $ hg clone a c |
376 preoutgoing hook: HG_SOURCE=clone |
376 preoutgoing hook: HG_SOURCE=clone |
377 outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone |
377 outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone |
378 updating to branch default |
378 updating to branch default |
379 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
379 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
380 $ rm -rf c |
380 $ rm -rf c |
381 |
381 |
382 preoutgoing hook can prevent outgoing changes for local clones |
382 preoutgoing hook can prevent outgoing changes for local clones |
383 |
383 |
384 $ echo "preoutgoing.forbid = python \"$TESTDIR/printenv.py\" preoutgoing.forbid 1" >> a/.hg/hgrc |
384 $ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> a/.hg/hgrc |
385 $ hg clone a zzz |
385 $ hg clone a zzz |
386 preoutgoing hook: HG_SOURCE=clone |
386 preoutgoing hook: HG_SOURCE=clone |
387 preoutgoing.forbid hook: HG_SOURCE=clone |
387 preoutgoing.forbid hook: HG_SOURCE=clone |
388 abort: preoutgoing.forbid hook exited with status 1 |
388 abort: preoutgoing.forbid hook exited with status 1 |
389 [255] |
389 [255] |