Show More
@@ -1,13 +1,16 b'' | |||||
1 | #!/bin/sh |
|
1 | #!/bin/sh | |
2 |
|
2 | |||
|
3 | cp "$TESTDIR"/printenv.py . | |||
|
4 | ||||
3 | # commit hooks can see env vars |
|
5 | # commit hooks can see env vars | |
4 | hg init a |
|
6 | hg init a | |
5 | cd a |
|
7 | cd a | |
6 | echo "[hooks]" > .hg/hgrc |
|
8 | echo "[hooks]" > .hg/hgrc | |
7 | echo 'commit = echo commit hook: n=$HG_NODE p1=$HG_PARENT1 p2=$HG_PARENT2' >> .hg/hgrc |
|
9 | echo 'commit = python ../printenv.py commit' >> .hg/hgrc | |
8 |
echo 'commit.b = |
|
10 | echo 'commit.b = python ../printenv.py commit.b' >> .hg/hgrc | |
9 |
echo 'precommit = |
|
11 | echo 'precommit = python ../printenv.py precommit' >> .hg/hgrc | |
10 | echo 'pretxncommit = echo pretxncommit hook: n=$HG_NODE p1=$HG_PARENT1 p2=$HG_PARENT2; hg -q tip' >> .hg/hgrc |
|
12 | echo 'pretxncommit = python ../printenv.py pretxncommit' >> .hg/hgrc | |
|
13 | echo 'pretxncommit.tip = hg -q tip' >> .hg/hgrc | |||
11 | echo a > a |
|
14 | echo a > a | |
12 | hg add a |
|
15 | hg add a | |
13 | hg commit -m a -d "1000000 0" |
|
16 | hg commit -m a -d "1000000 0" | |
@@ -17,9 +20,9 b' cd ../b' | |||||
17 |
|
20 | |||
18 | # changegroup hooks can see env vars |
|
21 | # changegroup hooks can see env vars | |
19 | echo '[hooks]' > .hg/hgrc |
|
22 | echo '[hooks]' > .hg/hgrc | |
20 |
echo 'prechangegroup = |
|
23 | echo 'prechangegroup = python ../printenv.py prechangegroup' >> .hg/hgrc | |
21 | echo 'changegroup = echo changegroup hook: n=$HG_NODE u=`echo $HG_URL | sed s,file:.*,file:,`' >> .hg/hgrc |
|
24 | echo 'changegroup = python ../printenv.py changegroup' >> .hg/hgrc | |
22 | echo 'incoming = echo incoming hook: n=$HG_NODE u=`echo $HG_URL | sed s,file:.*,file:,`' >> .hg/hgrc |
|
25 | echo 'incoming = python ../printenv.py incoming' >> .hg/hgrc | |
23 |
|
26 | |||
24 | # pretxncommit and commit hooks can see both parents of merge |
|
27 | # pretxncommit and commit hooks can see both parents of merge | |
25 | cd ../a |
|
28 | cd ../a | |
@@ -37,19 +40,20 b' hg pull ../a' | |||||
37 |
|
40 | |||
38 | # tag hooks can see env vars |
|
41 | # tag hooks can see env vars | |
39 | cd ../a |
|
42 | cd ../a | |
40 | echo 'pretag = echo pretag hook: t=$HG_TAG n=$HG_NODE l=$HG_LOCAL' >> .hg/hgrc |
|
43 | echo 'pretag = python ../printenv.py pretag' >> .hg/hgrc | |
41 | echo 'tag = echo tag hook: t=$HG_TAG n=$HG_NODE l=$HG_LOCAL' >> .hg/hgrc |
|
44 | echo 'tag = python ../printenv.py tag' >> .hg/hgrc | |
42 | hg tag -d '3 0' a |
|
45 | hg tag -d '3 0' a | |
43 | hg tag -l la |
|
46 | hg tag -l la | |
44 |
|
47 | |||
45 | # pretag hook can forbid tagging |
|
48 | # pretag hook can forbid tagging | |
46 |
echo 'pretag.forbid = |
|
49 | echo 'pretag.forbid = python ../printenv.py pretag.forbid 1' >> .hg/hgrc | |
47 | hg tag -d '4 0' fa |
|
50 | hg tag -d '4 0' fa | |
48 | hg tag -l fla |
|
51 | hg tag -l fla | |
49 |
|
52 | |||
50 | # pretxncommit hook can see changeset, can roll back txn, changeset |
|
53 | # pretxncommit hook can see changeset, can roll back txn, changeset | |
51 | # no more there after |
|
54 | # no more there after | |
52 |
echo 'pretxncommit.forbid |
|
55 | echo 'pretxncommit.forbid0 = hg tip -q' >> .hg/hgrc | |
|
56 | echo 'pretxncommit.forbid1 = python ../printenv.py pretxncommit.forbid 1' >> .hg/hgrc | |||
53 | echo z > z |
|
57 | echo z > z | |
54 | hg add z |
|
58 | hg add z | |
55 | hg -q tip |
|
59 | hg -q tip | |
@@ -57,42 +61,43 b" hg commit -m 'fail' -d '4 0'" | |||||
57 | hg -q tip |
|
61 | hg -q tip | |
58 |
|
62 | |||
59 | # precommit hook can prevent commit |
|
63 | # precommit hook can prevent commit | |
60 |
echo 'precommit.forbid = |
|
64 | echo 'precommit.forbid = python ../printenv.py precommit.forbid 1' >> .hg/hgrc | |
61 | hg commit -m 'fail' -d '4 0' |
|
65 | hg commit -m 'fail' -d '4 0' | |
62 | hg -q tip |
|
66 | hg -q tip | |
63 |
|
67 | |||
64 | # preupdate hook can prevent update |
|
68 | # preupdate hook can prevent update | |
65 |
echo 'preupdate = |
|
69 | echo 'preupdate = python ../printenv.py preupdate' >> .hg/hgrc | |
66 | hg update 1 |
|
70 | hg update 1 | |
67 |
|
71 | |||
68 | # update hook |
|
72 | # update hook | |
69 | echo 'update = echo update hook: p1=$HG_PARENT1 p2=$HG_PARENT2 err=$HG_ERROR' >> .hg/hgrc |
|
73 | echo 'update = python ../printenv.py update' >> .hg/hgrc | |
70 | hg update |
|
74 | hg update | |
71 |
|
75 | |||
72 | # prechangegroup hook can prevent incoming changes |
|
76 | # prechangegroup hook can prevent incoming changes | |
73 | cd ../b |
|
77 | cd ../b | |
74 | hg -q tip |
|
78 | hg -q tip | |
75 | echo '[hooks]' > .hg/hgrc |
|
79 | echo '[hooks]' > .hg/hgrc | |
76 |
echo 'prechangegroup.forbid = |
|
80 | echo 'prechangegroup.forbid = python ../printenv.py prechangegroup.forbid 1' >> .hg/hgrc | |
77 | hg pull ../a |
|
81 | hg pull ../a | |
78 |
|
82 | |||
79 | # pretxnchangegroup hook can see incoming changes, can roll back txn, |
|
83 | # pretxnchangegroup hook can see incoming changes, can roll back txn, | |
80 | # incoming changes no longer there after |
|
84 | # incoming changes no longer there after | |
81 | echo '[hooks]' > .hg/hgrc |
|
85 | echo '[hooks]' > .hg/hgrc | |
82 |
echo 'pretxnchangegroup.forbid = |
|
86 | echo 'pretxnchangegroup.forbid0 = hg tip -q' >> .hg/hgrc | |
|
87 | echo 'pretxnchangegroup.forbid1 = python ../printenv.py pretxnchangegroup.forbid 1' >> .hg/hgrc | |||
83 | hg pull ../a |
|
88 | hg pull ../a | |
84 | hg -q tip |
|
89 | hg -q tip | |
85 |
|
90 | |||
86 | # outgoing hooks can see env vars |
|
91 | # outgoing hooks can see env vars | |
87 | rm .hg/hgrc |
|
92 | rm .hg/hgrc | |
88 | echo '[hooks]' > ../a/.hg/hgrc |
|
93 | echo '[hooks]' > ../a/.hg/hgrc | |
89 |
echo 'preoutgoing = |
|
94 | echo 'preoutgoing = python ../printenv.py preoutgoing' >> ../a/.hg/hgrc | |
90 |
echo 'outgoing = |
|
95 | echo 'outgoing = python ../printenv.py outgoing' >> ../a/.hg/hgrc | |
91 | hg pull ../a |
|
96 | hg pull ../a | |
92 | hg rollback |
|
97 | hg rollback | |
93 |
|
98 | |||
94 | # preoutgoing hook can prevent outgoing changes |
|
99 | # preoutgoing hook can prevent outgoing changes | |
95 |
echo 'preoutgoing.forbid = |
|
100 | echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> ../a/.hg/hgrc | |
96 | hg pull ../a |
|
101 | hg pull ../a | |
97 |
|
102 | |||
98 | cat > hooktests.py <<EOF |
|
103 | cat > hooktests.py <<EOF |
@@ -1,32 +1,32 b'' | |||||
1 |
precommit hook: |
|
1 | precommit hook: HG_PARENT1=0000000000000000000000000000000000000000 HG_PARENT2= | |
2 |
pretxncommit hook: |
|
2 | pretxncommit hook: HG_NODE=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT1=0000000000000000000000000000000000000000 HG_PARENT2= | |
3 | 0:29b62aeb769f |
|
3 | 0:29b62aeb769f | |
4 |
commit hook: |
|
4 | commit hook: HG_NODE=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT1=0000000000000000000000000000000000000000 HG_PARENT2= | |
5 | commit hook b |
|
5 | commit.b hook: HG_NODE=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT1=0000000000000000000000000000000000000000 HG_PARENT2= | |
6 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
6 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
7 |
precommit hook: |
|
7 | precommit hook: HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT2= | |
8 |
pretxncommit hook: |
|
8 | pretxncommit hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT2= | |
9 | 1:b702efe96888 |
|
9 | 1:b702efe96888 | |
10 |
commit hook: |
|
10 | commit hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT2= | |
11 | commit hook b |
|
11 | commit.b hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT2= | |
12 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
12 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
13 |
precommit hook: |
|
13 | precommit hook: HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT2= | |
14 |
pretxncommit hook: |
|
14 | pretxncommit hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT2= | |
15 | 2:1324a5531bac |
|
15 | 2:1324a5531bac | |
16 |
commit hook: |
|
16 | commit hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT2= | |
17 | commit hook b |
|
17 | commit.b hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT2= | |
18 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
18 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
19 | (branch merge, don't forget to commit) |
|
19 | (branch merge, don't forget to commit) | |
20 |
precommit hook: |
|
20 | precommit hook: HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 | |
21 |
pretxncommit hook: |
|
21 | pretxncommit hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 | |
22 | 3:4c52fb2e4022 |
|
22 | 3:4c52fb2e4022 | |
23 |
commit hook: |
|
23 | commit hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 | |
24 | commit hook b |
|
24 | commit.b hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 | |
25 | prechangegroup hook: u=file: |
|
25 | prechangegroup hook: HG_SOURCE=pull HG_URL=file: | |
26 |
changegroup hook: |
|
26 | changegroup hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_SOURCE=pull HG_URL=file: | |
27 |
incoming hook: |
|
27 | incoming hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_SOURCE=pull HG_URL=file: | |
28 |
incoming hook: |
|
28 | incoming hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_SOURCE=pull HG_URL=file: | |
29 |
incoming hook: |
|
29 | incoming hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_SOURCE=pull HG_URL=file: | |
30 | pulling from ../a |
|
30 | pulling from ../a | |
31 | searching for changes |
|
31 | searching for changes | |
32 | adding changesets |
|
32 | adding changesets | |
@@ -34,57 +34,58 b' adding manifests' | |||||
34 | adding file changes |
|
34 | adding file changes | |
35 | added 3 changesets with 2 changes to 2 files |
|
35 | added 3 changesets with 2 changes to 2 files | |
36 | (run 'hg update' to get a working copy) |
|
36 | (run 'hg update' to get a working copy) | |
37 |
pretag hook: |
|
37 | pretag hook: HG_LOCAL=0 HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_TAG=a | |
38 |
precommit hook: |
|
38 | precommit hook: HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT2= | |
39 |
pretxncommit hook: |
|
39 | pretxncommit hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT2= | |
40 | 4:8ea2ef7ad3e8 |
|
40 | 4:8ea2ef7ad3e8 | |
41 |
commit hook: |
|
41 | commit hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT2= | |
42 | commit hook b |
|
42 | commit.b hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT2= | |
43 |
tag hook: |
|
43 | tag hook: HG_LOCAL=0 HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_TAG=a | |
44 |
pretag hook: |
|
44 | pretag hook: HG_LOCAL=1 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=la | |
45 |
tag hook: |
|
45 | tag hook: HG_LOCAL=1 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=la | |
46 |
pretag hook: |
|
46 | pretag hook: HG_LOCAL=0 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=fa | |
47 | pretag.forbid hook |
|
47 | pretag.forbid hook: HG_LOCAL=0 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=fa | |
48 | abort: pretag.forbid hook exited with status 1 |
|
48 | abort: pretag.forbid hook exited with status 1 | |
49 |
pretag hook: |
|
49 | pretag hook: HG_LOCAL=1 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=fla | |
50 | pretag.forbid hook |
|
50 | pretag.forbid hook: HG_LOCAL=1 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=fla | |
51 | abort: pretag.forbid hook exited with status 1 |
|
51 | abort: pretag.forbid hook exited with status 1 | |
52 | 4:8ea2ef7ad3e8 |
|
52 | 4:8ea2ef7ad3e8 | |
53 |
precommit hook: |
|
53 | precommit hook: HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT2= | |
54 |
pretxncommit hook: |
|
54 | pretxncommit hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT2= | |
55 | 5:fad284daf8c0 |
|
55 | 5:fad284daf8c0 | |
56 | pretxncommit.forbid hook: tip=5:fad284daf8c0 |
|
56 | pretxncommit.forbid hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT2= | |
57 | abort: pretxncommit.forbid hook exited with status 1 |
|
57 | abort: pretxncommit.forbid1 hook exited with status 1 | |
58 | transaction abort! |
|
58 | transaction abort! | |
59 | rollback completed |
|
59 | rollback completed | |
60 | 4:8ea2ef7ad3e8 |
|
60 | 4:8ea2ef7ad3e8 | |
61 |
precommit hook: |
|
61 | precommit hook: HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT2= | |
62 | precommit.forbid hook |
|
62 | precommit.forbid hook: HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT2= | |
63 | abort: precommit.forbid hook exited with status 1 |
|
63 | abort: precommit.forbid hook exited with status 1 | |
64 | 4:8ea2ef7ad3e8 |
|
64 | 4:8ea2ef7ad3e8 | |
65 |
preupdate hook: |
|
65 | preupdate hook: HG_PARENT1=b702efe96888 HG_PARENT2= | |
66 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
66 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
67 |
preupdate hook: |
|
67 | preupdate hook: HG_PARENT1=8ea2ef7ad3e8 HG_PARENT2= | |
68 |
update hook: |
|
68 | update hook: HG_ERROR=0 HG_PARENT1=8ea2ef7ad3e8 HG_PARENT2= | |
69 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
69 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
70 | 3:4c52fb2e4022 |
|
70 | 3:4c52fb2e4022 | |
71 | prechangegroup.forbid hook |
|
71 | prechangegroup.forbid hook: HG_SOURCE=pull HG_URL=file: | |
72 | pulling from ../a |
|
72 | pulling from ../a | |
73 | searching for changes |
|
73 | searching for changes | |
74 | abort: prechangegroup.forbid hook exited with status 1 |
|
74 | abort: prechangegroup.forbid hook exited with status 1 | |
75 | pretxnchangegroup.forbid hook: tip=4:8ea2ef7ad3e8 |
|
75 | 4:8ea2ef7ad3e8 | |
|
76 | pretxnchangegroup.forbid hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_SOURCE=pull HG_URL=file: | |||
76 | pulling from ../a |
|
77 | pulling from ../a | |
77 | searching for changes |
|
78 | searching for changes | |
78 | adding changesets |
|
79 | adding changesets | |
79 | adding manifests |
|
80 | adding manifests | |
80 | adding file changes |
|
81 | adding file changes | |
81 | added 1 changesets with 1 changes to 1 files |
|
82 | added 1 changesets with 1 changes to 1 files | |
82 | abort: pretxnchangegroup.forbid hook exited with status 1 |
|
83 | abort: pretxnchangegroup.forbid1 hook exited with status 1 | |
83 | transaction abort! |
|
84 | transaction abort! | |
84 | rollback completed |
|
85 | rollback completed | |
85 | 3:4c52fb2e4022 |
|
86 | 3:4c52fb2e4022 | |
86 |
preoutgoing hook: |
|
87 | preoutgoing hook: HG_SOURCE=pull | |
87 |
outgoing hook: |
|
88 | outgoing hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_SOURCE=pull | |
88 | pulling from ../a |
|
89 | pulling from ../a | |
89 | searching for changes |
|
90 | searching for changes | |
90 | adding changesets |
|
91 | adding changesets | |
@@ -93,8 +94,8 b' adding file changes' | |||||
93 | added 1 changesets with 1 changes to 1 files |
|
94 | added 1 changesets with 1 changes to 1 files | |
94 | (run 'hg update' to get a working copy) |
|
95 | (run 'hg update' to get a working copy) | |
95 | rolling back last transaction |
|
96 | rolling back last transaction | |
96 |
preoutgoing hook: |
|
97 | preoutgoing hook: HG_SOURCE=pull | |
97 | preoutgoing.forbid hook |
|
98 | preoutgoing.forbid hook: HG_SOURCE=pull | |
98 | pulling from ../a |
|
99 | pulling from ../a | |
99 | searching for changes |
|
100 | searching for changes | |
100 | abort: preoutgoing.forbid hook exited with status 1 |
|
101 | abort: preoutgoing.forbid hook exited with status 1 |
General Comments 0
You need to be logged in to leave comments.
Login now