Show More
@@ -1,465 +1,465 | |||||
1 | $ cp "$TESTDIR"/printenv.py . |
|
1 | $ cp "$TESTDIR"/printenv.py . | |
2 |
|
2 | |||
3 | # commit hooks can see env vars |
|
3 | # commit hooks can see env vars | |
4 |
|
4 | |||
5 | $ hg init a |
|
5 | $ hg init a | |
6 | $ cd a |
|
6 | $ cd a | |
7 | $ echo "[hooks]" > .hg/hgrc |
|
7 | $ echo "[hooks]" > .hg/hgrc | |
8 | $ echo 'commit = unset HG_LOCAL HG_TAG; python ../printenv.py commit' >> .hg/hgrc |
|
8 | $ echo 'commit = unset HG_LOCAL HG_TAG; python ../printenv.py commit' >> .hg/hgrc | |
9 | $ echo 'commit.b = unset HG_LOCAL HG_TAG; python ../printenv.py commit.b' >> .hg/hgrc |
|
9 | $ echo 'commit.b = unset HG_LOCAL HG_TAG; python ../printenv.py commit.b' >> .hg/hgrc | |
10 | $ echo 'precommit = unset HG_LOCAL HG_NODE HG_TAG; python ../printenv.py precommit' >> .hg/hgrc |
|
10 | $ echo 'precommit = unset HG_LOCAL HG_NODE HG_TAG; python ../printenv.py precommit' >> .hg/hgrc | |
11 | $ echo 'pretxncommit = unset HG_LOCAL HG_TAG; python ../printenv.py pretxncommit' >> .hg/hgrc |
|
11 | $ echo 'pretxncommit = unset HG_LOCAL HG_TAG; python ../printenv.py pretxncommit' >> .hg/hgrc | |
12 | $ echo 'pretxncommit.tip = hg -q tip' >> .hg/hgrc |
|
12 | $ echo 'pretxncommit.tip = hg -q tip' >> .hg/hgrc | |
13 | $ echo 'pre-identify = python ../printenv.py pre-identify 1' >> .hg/hgrc |
|
13 | $ echo 'pre-identify = python ../printenv.py pre-identify 1' >> .hg/hgrc | |
14 | $ echo 'pre-cat = python ../printenv.py pre-cat' >> .hg/hgrc |
|
14 | $ echo 'pre-cat = python ../printenv.py pre-cat' >> .hg/hgrc | |
15 | $ echo 'post-cat = python ../printenv.py post-cat' >> .hg/hgrc |
|
15 | $ echo 'post-cat = python ../printenv.py post-cat' >> .hg/hgrc | |
16 | $ echo a > a |
|
16 | $ echo a > a | |
17 | $ hg add a |
|
17 | $ hg add a | |
18 | $ hg commit -m a -d "1000000 0" |
|
18 | $ hg commit -m a -d "1000000 0" | |
19 | precommit hook: HG_PARENT1=0000000000000000000000000000000000000000 |
|
19 | precommit hook: HG_PARENT1=0000000000000000000000000000000000000000 | |
20 | pretxncommit hook: HG_NODE=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$HGTMP/test-hook.t/a |
|
20 | pretxncommit hook: HG_NODE=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$HGTMP/test-hook.t/a | |
21 | 0:29b62aeb769f |
|
21 | 0:29b62aeb769f | |
22 | commit hook: HG_NODE=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT1=0000000000000000000000000000000000000000 |
|
22 | commit hook: HG_NODE=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT1=0000000000000000000000000000000000000000 | |
23 | commit.b hook: HG_NODE=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT1=0000000000000000000000000000000000000000 |
|
23 | commit.b hook: HG_NODE=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT1=0000000000000000000000000000000000000000 | |
24 |
|
24 | |||
25 | $ hg clone . ../b |
|
25 | $ hg clone . ../b | |
26 | updating to branch default |
|
26 | updating to branch default | |
27 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
27 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
28 | $ cd ../b |
|
28 | $ cd ../b | |
29 |
|
29 | |||
30 | # changegroup hooks can see env vars |
|
30 | # changegroup hooks can see env vars | |
31 |
|
31 | |||
32 | $ echo '[hooks]' > .hg/hgrc |
|
32 | $ echo '[hooks]' > .hg/hgrc | |
33 | $ echo 'prechangegroup = python ../printenv.py prechangegroup' >> .hg/hgrc |
|
33 | $ echo 'prechangegroup = python ../printenv.py prechangegroup' >> .hg/hgrc | |
34 | $ echo 'changegroup = python ../printenv.py changegroup' >> .hg/hgrc |
|
34 | $ echo 'changegroup = python ../printenv.py changegroup' >> .hg/hgrc | |
35 | $ echo 'incoming = python ../printenv.py incoming' >> .hg/hgrc |
|
35 | $ echo 'incoming = python ../printenv.py incoming' >> .hg/hgrc | |
36 |
|
36 | |||
37 | # pretxncommit and commit hooks can see both parents of merge |
|
37 | # pretxncommit and commit hooks can see both parents of merge | |
38 |
|
38 | |||
39 | $ cd ../a |
|
39 | $ cd ../a | |
40 | $ echo b >> a |
|
40 | $ echo b >> a | |
41 | $ hg commit -m a1 -d "1 0" |
|
41 | $ hg commit -m a1 -d "1 0" | |
42 | precommit hook: HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
|
42 | precommit hook: HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b | |
43 | pretxncommit hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PENDING=$HGTMP/test-hook.t/a |
|
43 | pretxncommit hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PENDING=$HGTMP/test-hook.t/a | |
44 | 1:b702efe96888 |
|
44 | 1:b702efe96888 | |
45 | commit hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
|
45 | commit hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b | |
46 | commit.b hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
|
46 | commit.b hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b | |
47 | $ hg update -C 0 |
|
47 | $ hg update -C 0 | |
48 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
48 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
49 | $ echo b > b |
|
49 | $ echo b > b | |
50 | $ hg add b |
|
50 | $ hg add b | |
51 | $ hg commit -m b -d '1 0' |
|
51 | $ hg commit -m b -d '1 0' | |
52 | precommit hook: HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
|
52 | precommit hook: HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b | |
53 | pretxncommit hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PENDING=$HGTMP/test-hook.t/a |
|
53 | pretxncommit hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PENDING=$HGTMP/test-hook.t/a | |
54 | 2:1324a5531bac |
|
54 | 2:1324a5531bac | |
55 | commit hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
|
55 | commit hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b | |
56 | commit.b hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
|
56 | commit.b hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b | |
57 | created new head |
|
57 | created new head | |
58 | $ hg merge 1 |
|
58 | $ hg merge 1 | |
59 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
59 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
60 | (branch merge, don't forget to commit) |
|
60 | (branch merge, don't forget to commit) | |
61 | $ hg commit -m merge -d '2 0' |
|
61 | $ hg commit -m merge -d '2 0' | |
62 | precommit hook: HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 |
|
62 | precommit hook: HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 | |
63 | pretxncommit hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PENDING=$HGTMP/test-hook.t/a |
|
63 | pretxncommit hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PENDING=$HGTMP/test-hook.t/a | |
64 | 3:4c52fb2e4022 |
|
64 | 3:4c52fb2e4022 | |
65 | commit hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 |
|
65 | commit hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 | |
66 | commit.b hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 |
|
66 | commit.b hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 | |
67 |
|
67 | |||
68 | # test generic hooks |
|
68 | # test generic hooks | |
69 |
|
69 | |||
70 | $ hg id |
|
70 | $ hg id | |
71 | pre-identify hook: HG_ARGS=id HG_OPTS={'tags': None, 'rev': '', 'num': None, 'branch': None, 'id': None} HG_PATS=[] |
|
71 | pre-identify hook: HG_ARGS=id HG_OPTS={'tags': None, 'rev': '', 'num': None, 'branch': None, 'id': None} HG_PATS=[] | |
72 | warning: pre-identify hook exited with status 1 |
|
72 | warning: pre-identify hook exited with status 1 | |
73 | $ hg cat b |
|
73 | $ hg cat b | |
74 | pre-cat hook: HG_ARGS=cat b HG_OPTS={'rev': '', 'decode': None, 'exclude': [], 'output': '', 'include': []} HG_PATS=['b'] |
|
74 | pre-cat hook: HG_ARGS=cat b HG_OPTS={'rev': '', 'decode': None, 'exclude': [], 'output': '', 'include': []} HG_PATS=['b'] | |
75 | post-cat hook: HG_ARGS=cat b HG_OPTS={'rev': '', 'decode': None, 'exclude': [], 'output': '', 'include': []} HG_PATS=['b'] HG_RESULT=0 |
|
75 | post-cat hook: HG_ARGS=cat b HG_OPTS={'rev': '', 'decode': None, 'exclude': [], 'output': '', 'include': []} HG_PATS=['b'] HG_RESULT=0 | |
76 | b |
|
76 | b | |
77 |
|
77 | |||
78 | $ cd ../b |
|
78 | $ cd ../b | |
79 | $ hg pull ../a |
|
79 | $ hg pull ../a | |
80 | prechangegroup hook: HG_SOURCE=pull HG_URL=file: |
|
80 | prechangegroup hook: HG_SOURCE=pull HG_URL=file: | |
81 | changegroup hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_SOURCE=pull HG_URL=file: |
|
81 | changegroup hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_SOURCE=pull HG_URL=file: | |
82 | incoming hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_SOURCE=pull HG_URL=file: |
|
82 | incoming hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_SOURCE=pull HG_URL=file: | |
83 | incoming hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_SOURCE=pull HG_URL=file: |
|
83 | incoming hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_SOURCE=pull HG_URL=file: | |
84 | incoming hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_SOURCE=pull HG_URL=file: |
|
84 | incoming hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_SOURCE=pull HG_URL=file: | |
85 | pulling from ../a |
|
85 | pulling from ../a | |
86 | searching for changes |
|
86 | searching for changes | |
87 | adding changesets |
|
87 | adding changesets | |
88 | adding manifests |
|
88 | adding manifests | |
89 | adding file changes |
|
89 | adding file changes | |
90 | added 3 changesets with 2 changes to 2 files |
|
90 | added 3 changesets with 2 changes to 2 files | |
91 | (run 'hg update' to get a working copy) |
|
91 | (run 'hg update' to get a working copy) | |
92 |
|
92 | |||
93 | # tag hooks can see env vars |
|
93 | # tag hooks can see env vars | |
94 |
|
94 | |||
95 | $ cd ../a |
|
95 | $ cd ../a | |
96 | $ echo 'pretag = python ../printenv.py pretag' >> .hg/hgrc |
|
96 | $ echo 'pretag = python ../printenv.py pretag' >> .hg/hgrc | |
97 | $ echo 'tag = unset HG_PARENT1 HG_PARENT2; python ../printenv.py tag' >> .hg/hgrc |
|
97 | $ echo 'tag = unset HG_PARENT1 HG_PARENT2; python ../printenv.py tag' >> .hg/hgrc | |
98 | $ hg tag -d '3 0' a |
|
98 | $ hg tag -d '3 0' a | |
99 | pretag hook: HG_LOCAL=0 HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_TAG=a |
|
99 | pretag hook: HG_LOCAL=0 HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_TAG=a | |
100 | precommit hook: HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 |
|
100 | precommit hook: HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 | |
101 | pretxncommit hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 HG_PENDING=$HGTMP/test-hook.t/a |
|
101 | pretxncommit hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 HG_PENDING=$HGTMP/test-hook.t/a | |
102 | 4:8ea2ef7ad3e8 |
|
102 | 4:8ea2ef7ad3e8 | |
103 | commit hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 |
|
103 | commit hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 | |
104 | commit.b hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 |
|
104 | commit.b hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 | |
105 | tag hook: HG_LOCAL=0 HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_TAG=a |
|
105 | tag hook: HG_LOCAL=0 HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_TAG=a | |
106 | $ hg tag -l la |
|
106 | $ hg tag -l la | |
107 | pretag hook: HG_LOCAL=1 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=la |
|
107 | pretag hook: HG_LOCAL=1 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=la | |
108 | tag hook: HG_LOCAL=1 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=la |
|
108 | tag hook: HG_LOCAL=1 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=la | |
109 |
|
109 | |||
110 | # pretag hook can forbid tagging |
|
110 | # pretag hook can forbid tagging | |
111 |
|
111 | |||
112 | $ echo 'pretag.forbid = python ../printenv.py pretag.forbid 1' >> .hg/hgrc |
|
112 | $ echo 'pretag.forbid = python ../printenv.py pretag.forbid 1' >> .hg/hgrc | |
113 | $ hg tag -d '4 0' fa |
|
113 | $ hg tag -d '4 0' fa | |
114 | pretag hook: HG_LOCAL=0 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=fa |
|
114 | pretag hook: HG_LOCAL=0 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=fa | |
115 | pretag.forbid hook: HG_LOCAL=0 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=fa |
|
115 | pretag.forbid hook: HG_LOCAL=0 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=fa | |
116 | abort: pretag.forbid hook exited with status 1 |
|
116 | abort: pretag.forbid hook exited with status 1 | |
117 | $ hg tag -l fla |
|
117 | $ hg tag -l fla | |
118 | pretag hook: HG_LOCAL=1 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=fla |
|
118 | pretag hook: HG_LOCAL=1 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=fla | |
119 | pretag.forbid hook: HG_LOCAL=1 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=fla |
|
119 | pretag.forbid hook: HG_LOCAL=1 HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_TAG=fla | |
120 | abort: pretag.forbid hook exited with status 1 |
|
120 | abort: pretag.forbid hook exited with status 1 | |
121 |
|
121 | |||
122 | # pretxncommit hook can see changeset, can roll back txn, changeset |
|
122 | # pretxncommit hook can see changeset, can roll back txn, changeset | |
123 | # no more there after |
|
123 | # no more there after | |
124 |
|
124 | |||
125 | $ echo 'pretxncommit.forbid0 = hg tip -q' >> .hg/hgrc |
|
125 | $ echo 'pretxncommit.forbid0 = hg tip -q' >> .hg/hgrc | |
126 | $ echo 'pretxncommit.forbid1 = python ../printenv.py pretxncommit.forbid 1' >> .hg/hgrc |
|
126 | $ echo 'pretxncommit.forbid1 = python ../printenv.py pretxncommit.forbid 1' >> .hg/hgrc | |
127 | $ echo z > z |
|
127 | $ echo z > z | |
128 | $ hg add z |
|
128 | $ hg add z | |
129 | $ hg -q tip |
|
129 | $ hg -q tip | |
130 | 4:8ea2ef7ad3e8 |
|
130 | 4:8ea2ef7ad3e8 | |
131 | $ hg commit -m 'fail' -d '4 0' |
|
131 | $ hg commit -m 'fail' -d '4 0' | |
132 | precommit hook: HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 |
|
132 | precommit hook: HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 | |
133 | pretxncommit hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PENDING=$HGTMP/test-hook.t/a |
|
133 | pretxncommit hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PENDING=$HGTMP/test-hook.t/a | |
134 | 5:fad284daf8c0 |
|
134 | 5:fad284daf8c0 | |
135 | 5:fad284daf8c0 |
|
135 | 5:fad284daf8c0 | |
136 | pretxncommit.forbid hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PENDING=$HGTMP/test-hook.t/a |
|
136 | pretxncommit.forbid hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PENDING=$HGTMP/test-hook.t/a | |
137 | transaction abort! |
|
137 | transaction abort! | |
138 | rollback completed |
|
138 | rollback completed | |
139 | abort: pretxncommit.forbid1 hook exited with status 1 |
|
139 | abort: pretxncommit.forbid1 hook exited with status 1 | |
140 | $ hg -q tip |
|
140 | $ hg -q tip | |
141 | 4:8ea2ef7ad3e8 |
|
141 | 4:8ea2ef7ad3e8 | |
142 |
|
142 | |||
143 | # precommit hook can prevent commit |
|
143 | # precommit hook can prevent commit | |
144 |
|
144 | |||
145 | $ echo 'precommit.forbid = python ../printenv.py precommit.forbid 1' >> .hg/hgrc |
|
145 | $ echo 'precommit.forbid = python ../printenv.py precommit.forbid 1' >> .hg/hgrc | |
146 | $ hg commit -m 'fail' -d '4 0' |
|
146 | $ hg commit -m 'fail' -d '4 0' | |
147 | precommit hook: HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 |
|
147 | precommit hook: HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 | |
148 | precommit.forbid hook: HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 |
|
148 | precommit.forbid hook: HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 | |
149 | abort: precommit.forbid hook exited with status 1 |
|
149 | abort: precommit.forbid hook exited with status 1 | |
150 | $ hg -q tip |
|
150 | $ hg -q tip | |
151 | 4:8ea2ef7ad3e8 |
|
151 | 4:8ea2ef7ad3e8 | |
152 |
|
152 | |||
153 | # preupdate hook can prevent update |
|
153 | # preupdate hook can prevent update | |
154 |
|
154 | |||
155 | $ echo 'preupdate = python ../printenv.py preupdate' >> .hg/hgrc |
|
155 | $ echo 'preupdate = python ../printenv.py preupdate' >> .hg/hgrc | |
156 | $ hg update 1 |
|
156 | $ hg update 1 | |
157 | preupdate hook: HG_PARENT1=b702efe96888 |
|
157 | preupdate hook: HG_PARENT1=b702efe96888 | |
158 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
158 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
159 |
|
159 | |||
160 | # update hook |
|
160 | # update hook | |
161 |
|
161 | |||
162 | $ echo 'update = python ../printenv.py update' >> .hg/hgrc |
|
162 | $ echo 'update = python ../printenv.py update' >> .hg/hgrc | |
163 | $ hg update |
|
163 | $ hg update | |
164 | preupdate hook: HG_PARENT1=8ea2ef7ad3e8 |
|
164 | preupdate hook: HG_PARENT1=8ea2ef7ad3e8 | |
165 | update hook: HG_ERROR=0 HG_PARENT1=8ea2ef7ad3e8 |
|
165 | update hook: HG_ERROR=0 HG_PARENT1=8ea2ef7ad3e8 | |
166 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
166 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
167 |
|
167 | |||
168 | # prechangegroup hook can prevent incoming changes |
|
168 | # prechangegroup hook can prevent incoming changes | |
169 |
|
169 | |||
170 | $ cd ../b |
|
170 | $ cd ../b | |
171 | $ hg -q tip |
|
171 | $ hg -q tip | |
172 | 3:4c52fb2e4022 |
|
172 | 3:4c52fb2e4022 | |
173 | $ echo '[hooks]' > .hg/hgrc |
|
173 | $ echo '[hooks]' > .hg/hgrc | |
174 | $ echo 'prechangegroup.forbid = python ../printenv.py prechangegroup.forbid 1' >> .hg/hgrc |
|
174 | $ echo 'prechangegroup.forbid = python ../printenv.py prechangegroup.forbid 1' >> .hg/hgrc | |
175 | $ hg pull ../a |
|
175 | $ hg pull ../a | |
176 | prechangegroup.forbid hook: HG_SOURCE=pull HG_URL=file: |
|
176 | prechangegroup.forbid hook: HG_SOURCE=pull HG_URL=file: | |
177 | pulling from ../a |
|
177 | pulling from ../a | |
178 | searching for changes |
|
178 | searching for changes | |
179 | abort: prechangegroup.forbid hook exited with status 1 |
|
179 | abort: prechangegroup.forbid hook exited with status 1 | |
180 |
|
180 | |||
181 | # pretxnchangegroup hook can see incoming changes, can roll back txn, |
|
181 | # pretxnchangegroup hook can see incoming changes, can roll back txn, | |
182 | # incoming changes no longer there after |
|
182 | # incoming changes no longer there after | |
183 |
|
183 | |||
184 | $ echo '[hooks]' > .hg/hgrc |
|
184 | $ echo '[hooks]' > .hg/hgrc | |
185 | $ echo 'pretxnchangegroup.forbid0 = hg tip -q' >> .hg/hgrc |
|
185 | $ echo 'pretxnchangegroup.forbid0 = hg tip -q' >> .hg/hgrc | |
186 | $ echo 'pretxnchangegroup.forbid1 = python ../printenv.py pretxnchangegroup.forbid 1' >> .hg/hgrc |
|
186 | $ echo 'pretxnchangegroup.forbid1 = python ../printenv.py pretxnchangegroup.forbid 1' >> .hg/hgrc | |
187 | $ hg pull ../a |
|
187 | $ hg pull ../a | |
188 | 4:8ea2ef7ad3e8 |
|
188 | 4:8ea2ef7ad3e8 | |
189 | pretxnchangegroup.forbid hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PENDING=$HGTMP/test-hook.t/b HG_SOURCE=pull HG_URL=file: |
|
189 | pretxnchangegroup.forbid hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PENDING=$HGTMP/test-hook.t/b HG_SOURCE=pull HG_URL=file: | |
190 | pulling from ../a |
|
190 | pulling from ../a | |
191 | searching for changes |
|
191 | searching for changes | |
192 | adding changesets |
|
192 | adding changesets | |
193 | adding manifests |
|
193 | adding manifests | |
194 | adding file changes |
|
194 | adding file changes | |
195 | added 1 changesets with 1 changes to 1 files |
|
195 | added 1 changesets with 1 changes to 1 files | |
196 | transaction abort! |
|
196 | transaction abort! | |
197 | rollback completed |
|
197 | rollback completed | |
198 | abort: pretxnchangegroup.forbid1 hook exited with status 1 |
|
198 | abort: pretxnchangegroup.forbid1 hook exited with status 1 | |
199 | $ hg -q tip |
|
199 | $ hg -q tip | |
200 | 3:4c52fb2e4022 |
|
200 | 3:4c52fb2e4022 | |
201 |
|
201 | |||
202 | # outgoing hooks can see env vars |
|
202 | # outgoing hooks can see env vars | |
203 |
|
203 | |||
204 | $ rm .hg/hgrc |
|
204 | $ rm .hg/hgrc | |
205 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
205 | $ echo '[hooks]' > ../a/.hg/hgrc | |
206 | $ echo 'preoutgoing = python ../printenv.py preoutgoing' >> ../a/.hg/hgrc |
|
206 | $ echo 'preoutgoing = python ../printenv.py preoutgoing' >> ../a/.hg/hgrc | |
207 | $ echo 'outgoing = python ../printenv.py outgoing' >> ../a/.hg/hgrc |
|
207 | $ echo 'outgoing = python ../printenv.py outgoing' >> ../a/.hg/hgrc | |
208 | $ hg pull ../a |
|
208 | $ hg pull ../a | |
209 | preoutgoing hook: HG_SOURCE=pull |
|
209 | preoutgoing hook: HG_SOURCE=pull | |
210 | outgoing hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_SOURCE=pull |
|
210 | outgoing hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_SOURCE=pull | |
211 | pulling from ../a |
|
211 | pulling from ../a | |
212 | searching for changes |
|
212 | searching for changes | |
213 | adding changesets |
|
213 | adding changesets | |
214 | adding manifests |
|
214 | adding manifests | |
215 | adding file changes |
|
215 | adding file changes | |
216 | added 1 changesets with 1 changes to 1 files |
|
216 | added 1 changesets with 1 changes to 1 files | |
217 | (run 'hg update' to get a working copy) |
|
217 | (run 'hg update' to get a working copy) | |
218 | $ hg rollback |
|
218 | $ hg rollback | |
219 | rolling back to revision 3 (undo pull) |
|
219 | rolling back to revision 3 (undo pull) | |
220 |
|
220 | |||
221 | # preoutgoing hook can prevent outgoing changes |
|
221 | # preoutgoing hook can prevent outgoing changes | |
222 |
|
222 | |||
223 | $ echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> ../a/.hg/hgrc |
|
223 | $ echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> ../a/.hg/hgrc | |
224 | $ hg pull ../a |
|
224 | $ hg pull ../a | |
225 | preoutgoing hook: HG_SOURCE=pull |
|
225 | preoutgoing hook: HG_SOURCE=pull | |
226 | preoutgoing.forbid hook: HG_SOURCE=pull |
|
226 | preoutgoing.forbid hook: HG_SOURCE=pull | |
227 | pulling from ../a |
|
227 | pulling from ../a | |
228 | searching for changes |
|
228 | searching for changes | |
229 | abort: preoutgoing.forbid hook exited with status 1 |
|
229 | abort: preoutgoing.forbid hook exited with status 1 | |
230 |
|
230 | |||
231 | # outgoing hooks work for local clones |
|
231 | # outgoing hooks work for local clones | |
232 |
|
232 | |||
233 | $ cd .. |
|
233 | $ cd .. | |
234 | $ echo '[hooks]' > a/.hg/hgrc |
|
234 | $ echo '[hooks]' > a/.hg/hgrc | |
235 | $ echo 'preoutgoing = python ../printenv.py preoutgoing' >> a/.hg/hgrc |
|
235 | $ echo 'preoutgoing = python ../printenv.py preoutgoing' >> a/.hg/hgrc | |
236 | $ echo 'outgoing = python ../printenv.py outgoing' >> a/.hg/hgrc |
|
236 | $ echo 'outgoing = python ../printenv.py outgoing' >> a/.hg/hgrc | |
237 | $ hg clone a c |
|
237 | $ hg clone a c | |
238 | preoutgoing hook: HG_SOURCE=clone |
|
238 | preoutgoing hook: HG_SOURCE=clone | |
239 | outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone |
|
239 | outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone | |
240 | updating to branch default |
|
240 | updating to branch default | |
241 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
241 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
242 | $ rm -rf c |
|
242 | $ rm -rf c | |
243 |
|
243 | |||
244 | # preoutgoing hook can prevent outgoing changes for local clones |
|
244 | # preoutgoing hook can prevent outgoing changes for local clones | |
245 |
|
245 | |||
246 | $ echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> a/.hg/hgrc |
|
246 | $ echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> a/.hg/hgrc | |
247 | $ hg clone a zzz |
|
247 | $ hg clone a zzz | |
248 | preoutgoing hook: HG_SOURCE=clone |
|
248 | preoutgoing hook: HG_SOURCE=clone | |
249 | preoutgoing.forbid hook: HG_SOURCE=clone |
|
249 | preoutgoing.forbid hook: HG_SOURCE=clone | |
250 | abort: preoutgoing.forbid hook exited with status 1 |
|
250 | abort: preoutgoing.forbid hook exited with status 1 | |
251 | $ cd b |
|
251 | $ cd b | |
252 |
|
252 | |||
253 | $ cat > hooktests.py <<EOF |
|
253 | $ cat > hooktests.py <<EOF | |
254 | > from mercurial import util |
|
254 | > from mercurial import util | |
255 | > |
|
255 | > | |
256 | > uncallable = 0 |
|
256 | > uncallable = 0 | |
257 | > |
|
257 | > | |
258 | > def printargs(args): |
|
258 | > def printargs(args): | |
259 | > args.pop('ui', None) |
|
259 | > args.pop('ui', None) | |
260 | > args.pop('repo', None) |
|
260 | > args.pop('repo', None) | |
261 | > a = list(args.items()) |
|
261 | > a = list(args.items()) | |
262 | > a.sort() |
|
262 | > a.sort() | |
263 | > print 'hook args:' |
|
263 | > print 'hook args:' | |
264 | > for k, v in a: |
|
264 | > for k, v in a: | |
265 | > print ' ', k, v |
|
265 | > print ' ', k, v | |
266 | > |
|
266 | > | |
267 | > def passhook(**args): |
|
267 | > def passhook(**args): | |
268 | > printargs(args) |
|
268 | > printargs(args) | |
269 | > |
|
269 | > | |
270 | > def failhook(**args): |
|
270 | > def failhook(**args): | |
271 | > printargs(args) |
|
271 | > printargs(args) | |
272 | > return True |
|
272 | > return True | |
273 | > |
|
273 | > | |
274 | > class LocalException(Exception): |
|
274 | > class LocalException(Exception): | |
275 | > pass |
|
275 | > pass | |
276 | > |
|
276 | > | |
277 | > def raisehook(**args): |
|
277 | > def raisehook(**args): | |
278 | > raise LocalException('exception from hook') |
|
278 | > raise LocalException('exception from hook') | |
279 | > |
|
279 | > | |
280 | > def aborthook(**args): |
|
280 | > def aborthook(**args): | |
281 | > raise util.Abort('raise abort from hook') |
|
281 | > raise util.Abort('raise abort from hook') | |
282 | > |
|
282 | > | |
283 | > def brokenhook(**args): |
|
283 | > def brokenhook(**args): | |
284 | > return 1 + {} |
|
284 | > return 1 + {} | |
285 | > |
|
285 | > | |
286 | > class container: |
|
286 | > class container: | |
287 | > unreachable = 1 |
|
287 | > unreachable = 1 | |
288 | > EOF |
|
288 | > EOF | |
289 |
|
289 | |||
290 | # test python hooks |
|
290 | # test python hooks | |
291 |
|
291 | |||
292 | $ PYTHONPATH="`pwd`:$PYTHONPATH" |
|
292 | $ PYTHONPATH="`pwd`:$PYTHONPATH" | |
293 | $ export PYTHONPATH |
|
293 | $ export PYTHONPATH | |
294 |
|
294 | |||
295 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
295 | $ echo '[hooks]' > ../a/.hg/hgrc | |
296 | $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc |
|
296 | $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc | |
297 | $ hg pull ../a 2>&1 | grep 'raised an exception' |
|
297 | $ hg pull ../a 2>&1 | grep 'raised an exception' | |
298 | error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict' |
|
298 | error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict' | |
299 |
|
299 | |||
300 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
300 | $ echo '[hooks]' > ../a/.hg/hgrc | |
301 | $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc |
|
301 | $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc | |
302 | $ hg pull ../a 2>&1 | grep 'raised an exception' |
|
302 | $ hg pull ../a 2>&1 | grep 'raised an exception' | |
303 | error: preoutgoing.raise hook raised an exception: exception from hook |
|
303 | error: preoutgoing.raise hook raised an exception: exception from hook | |
304 |
|
304 | |||
305 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
305 | $ echo '[hooks]' > ../a/.hg/hgrc | |
306 | $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc |
|
306 | $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc | |
307 | $ hg pull ../a |
|
307 | $ hg pull ../a | |
308 | pulling from ../a |
|
308 | pulling from ../a | |
309 | searching for changes |
|
309 | searching for changes | |
310 | error: preoutgoing.abort hook failed: raise abort from hook |
|
310 | error: preoutgoing.abort hook failed: raise abort from hook | |
311 | abort: raise abort from hook |
|
311 | abort: raise abort from hook | |
312 |
|
312 | |||
313 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
313 | $ echo '[hooks]' > ../a/.hg/hgrc | |
314 | $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc |
|
314 | $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc | |
315 | $ hg pull ../a |
|
315 | $ hg pull ../a | |
316 | pulling from ../a |
|
316 | pulling from ../a | |
317 | searching for changes |
|
317 | searching for changes | |
318 | hook args: |
|
318 | hook args: | |
319 | hooktype preoutgoing |
|
319 | hooktype preoutgoing | |
320 | source pull |
|
320 | source pull | |
321 | abort: preoutgoing.fail hook failed |
|
321 | abort: preoutgoing.fail hook failed | |
322 |
|
322 | |||
323 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
323 | $ echo '[hooks]' > ../a/.hg/hgrc | |
324 | $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc |
|
324 | $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc | |
325 | $ hg pull ../a |
|
325 | $ hg pull ../a | |
326 | pulling from ../a |
|
326 | pulling from ../a | |
327 | searching for changes |
|
327 | searching for changes | |
328 | abort: preoutgoing.uncallable hook is invalid ("hooktests.uncallable" is not callable) |
|
328 | abort: preoutgoing.uncallable hook is invalid ("hooktests.uncallable" is not callable) | |
329 |
|
329 | |||
330 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
330 | $ echo '[hooks]' > ../a/.hg/hgrc | |
331 | $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc |
|
331 | $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc | |
332 | $ hg pull ../a |
|
332 | $ hg pull ../a | |
333 | pulling from ../a |
|
333 | pulling from ../a | |
334 | searching for changes |
|
334 | searching for changes | |
335 | abort: preoutgoing.nohook hook is invalid ("hooktests.nohook" is not defined) |
|
335 | abort: preoutgoing.nohook hook is invalid ("hooktests.nohook" is not defined) | |
336 |
|
336 | |||
337 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
337 | $ echo '[hooks]' > ../a/.hg/hgrc | |
338 | $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc |
|
338 | $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc | |
339 | $ hg pull ../a |
|
339 | $ hg pull ../a | |
340 | pulling from ../a |
|
340 | pulling from ../a | |
341 | searching for changes |
|
341 | searching for changes | |
342 | abort: preoutgoing.nomodule hook is invalid ("nomodule" not in a module) |
|
342 | abort: preoutgoing.nomodule hook is invalid ("nomodule" not in a module) | |
343 |
|
343 | |||
344 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
344 | $ echo '[hooks]' > ../a/.hg/hgrc | |
345 | $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc |
|
345 | $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc | |
346 | $ hg pull ../a |
|
346 | $ hg pull ../a | |
347 | pulling from ../a |
|
347 | pulling from ../a | |
348 | searching for changes |
|
348 | searching for changes | |
349 | abort: preoutgoing.badmodule hook is invalid (import of "nomodule" failed) |
|
349 | abort: preoutgoing.badmodule hook is invalid (import of "nomodule" failed) | |
350 |
|
350 | |||
351 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
351 | $ echo '[hooks]' > ../a/.hg/hgrc | |
352 | $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc |
|
352 | $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc | |
353 | $ hg pull ../a |
|
353 | $ hg pull ../a | |
354 | pulling from ../a |
|
354 | pulling from ../a | |
355 | searching for changes |
|
355 | searching for changes | |
356 | abort: preoutgoing.unreachable hook is invalid (import of "hooktests.container" failed) |
|
356 | abort: preoutgoing.unreachable hook is invalid (import of "hooktests.container" failed) | |
357 |
|
357 | |||
358 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
358 | $ echo '[hooks]' > ../a/.hg/hgrc | |
359 | $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc |
|
359 | $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc | |
360 | $ hg pull ../a |
|
360 | $ hg pull ../a | |
361 | pulling from ../a |
|
361 | pulling from ../a | |
362 | searching for changes |
|
362 | searching for changes | |
363 | hook args: |
|
363 | hook args: | |
364 | hooktype preoutgoing |
|
364 | hooktype preoutgoing | |
365 | source pull |
|
365 | source pull | |
366 | adding changesets |
|
366 | adding changesets | |
367 | adding manifests |
|
367 | adding manifests | |
368 | adding file changes |
|
368 | adding file changes | |
369 | added 1 changesets with 1 changes to 1 files |
|
369 | added 1 changesets with 1 changes to 1 files | |
370 | (run 'hg update' to get a working copy) |
|
370 | (run 'hg update' to get a working copy) | |
371 |
|
371 | |||
372 | # make sure --traceback works |
|
372 | # make sure --traceback works | |
373 |
|
373 | |||
374 | $ echo '[hooks]' > .hg/hgrc |
|
374 | $ echo '[hooks]' > .hg/hgrc | |
375 | $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc |
|
375 | $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc | |
376 |
|
376 | |||
377 | $ echo aa > a |
|
377 | $ echo aa > a | |
378 | $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback' |
|
378 | $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback' | |
379 | Traceback (most recent call last): |
|
379 | Traceback (most recent call last): | |
380 |
|
380 | |||
381 | $ cd .. |
|
381 | $ cd .. | |
382 | $ hg init c |
|
382 | $ hg init c | |
383 | $ cd c |
|
383 | $ cd c | |
384 |
|
384 | |||
385 | $ cat > hookext.py <<EOF |
|
385 | $ cat > hookext.py <<EOF | |
386 | > def autohook(**args): |
|
386 | > def autohook(**args): | |
387 | > print "Automatically installed hook" |
|
387 | > print "Automatically installed hook" | |
388 | > |
|
388 | > | |
389 | > def reposetup(ui, repo): |
|
389 | > def reposetup(ui, repo): | |
390 | > repo.ui.setconfig("hooks", "commit.auto", autohook) |
|
390 | > repo.ui.setconfig("hooks", "commit.auto", autohook) | |
391 | > EOF |
|
391 | > EOF | |
392 | $ echo '[extensions]' >> .hg/hgrc |
|
392 | $ echo '[extensions]' >> .hg/hgrc | |
393 | $ echo 'hookext = hookext.py' >> .hg/hgrc |
|
393 | $ echo 'hookext = hookext.py' >> .hg/hgrc | |
394 |
|
394 | |||
395 | $ touch foo |
|
395 | $ touch foo | |
396 | $ hg add foo |
|
396 | $ hg add foo | |
397 | $ hg ci -d '0 0' -m 'add foo' |
|
397 | $ hg ci -d '0 0' -m 'add foo' | |
398 | Automatically installed hook |
|
398 | Automatically installed hook | |
399 | $ echo >> foo |
|
399 | $ echo >> foo | |
400 |
$ hg ci --debug -d '0 0' -m 'change foo' |
|
400 | $ hg ci --debug -d '0 0' -m 'change foo' | |
401 | foo |
|
401 | foo | |
402 | calling hook commit.auto: <function autohook> |
|
402 | calling hook commit.auto: <function autohook at .*> | |
403 | Automatically installed hook |
|
403 | Automatically installed hook | |
404 | committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708 |
|
404 | committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708 | |
405 |
|
405 | |||
406 |
$ hg showconfig hooks |
|
406 | $ hg showconfig hooks | |
407 | hooks.commit.auto=<function autohook> |
|
407 | hooks.commit.auto=<function autohook at .*> | |
408 |
|
408 | |||
409 | # test python hook configured with python:[file]:[hook] syntax |
|
409 | # test python hook configured with python:[file]:[hook] syntax | |
410 |
|
410 | |||
411 | $ cd .. |
|
411 | $ cd .. | |
412 | $ mkdir d |
|
412 | $ mkdir d | |
413 | $ cd d |
|
413 | $ cd d | |
414 | $ hg init repo |
|
414 | $ hg init repo | |
415 | $ mkdir hooks |
|
415 | $ mkdir hooks | |
416 |
|
416 | |||
417 | $ cd hooks |
|
417 | $ cd hooks | |
418 | $ cat > testhooks.py <<EOF |
|
418 | $ cat > testhooks.py <<EOF | |
419 | > def testhook(**args): |
|
419 | > def testhook(**args): | |
420 | > print 'hook works' |
|
420 | > print 'hook works' | |
421 | > EOF |
|
421 | > EOF | |
422 | $ echo '[hooks]' > ../repo/.hg/hgrc |
|
422 | $ echo '[hooks]' > ../repo/.hg/hgrc | |
423 | $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc |
|
423 | $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc | |
424 |
|
424 | |||
425 | $ cd ../repo |
|
425 | $ cd ../repo | |
426 | $ hg commit -d '0 0' |
|
426 | $ hg commit -d '0 0' | |
427 | hook works |
|
427 | hook works | |
428 | nothing changed |
|
428 | nothing changed | |
429 |
|
429 | |||
430 | $ cd ../../b |
|
430 | $ cd ../../b | |
431 |
|
431 | |||
432 | # make sure --traceback works on hook import failure |
|
432 | # make sure --traceback works on hook import failure | |
433 |
|
433 | |||
434 | $ cat > importfail.py <<EOF |
|
434 | $ cat > importfail.py <<EOF | |
435 | > import somebogusmodule |
|
435 | > import somebogusmodule | |
436 | > # dereference something in the module to force demandimport to load it |
|
436 | > # dereference something in the module to force demandimport to load it | |
437 | > somebogusmodule.whatever |
|
437 | > somebogusmodule.whatever | |
438 | > EOF |
|
438 | > EOF | |
439 |
|
439 | |||
440 | $ echo '[hooks]' > .hg/hgrc |
|
440 | $ echo '[hooks]' > .hg/hgrc | |
441 | $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc |
|
441 | $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc | |
442 |
|
442 | |||
443 | $ echo a >> a |
|
443 | $ echo a >> a | |
444 | $ hg --traceback commit -d '0 0' -ma 2>&1 | egrep '^(exception|Traceback|ImportError)' |
|
444 | $ hg --traceback commit -d '0 0' -ma 2>&1 | egrep '^(exception|Traceback|ImportError)' | |
445 | exception from first failed import attempt: |
|
445 | exception from first failed import attempt: | |
446 | Traceback (most recent call last): |
|
446 | Traceback (most recent call last): | |
447 | ImportError: No module named somebogusmodule |
|
447 | ImportError: No module named somebogusmodule | |
448 | exception from second failed import attempt: |
|
448 | exception from second failed import attempt: | |
449 | Traceback (most recent call last): |
|
449 | Traceback (most recent call last): | |
450 | ImportError: No module named hgext_importfail |
|
450 | ImportError: No module named hgext_importfail | |
451 | Traceback (most recent call last): |
|
451 | Traceback (most recent call last): | |
452 |
|
452 | |||
453 | # commit and update hooks should run after command completion (issue 1827) |
|
453 | # commit and update hooks should run after command completion (issue 1827) | |
454 |
|
454 | |||
455 | $ echo '[hooks]' > .hg/hgrc |
|
455 | $ echo '[hooks]' > .hg/hgrc | |
456 | $ echo 'commit = hg id' >> .hg/hgrc |
|
456 | $ echo 'commit = hg id' >> .hg/hgrc | |
457 | $ echo 'update = hg id' >> .hg/hgrc |
|
457 | $ echo 'update = hg id' >> .hg/hgrc | |
458 | $ echo bb > a |
|
458 | $ echo bb > a | |
459 | $ hg ci -d '0 0' -ma |
|
459 | $ hg ci -d '0 0' -ma | |
460 | 8da618c33484 tip |
|
460 | 8da618c33484 tip | |
461 | $ hg up 0 |
|
461 | $ hg up 0 | |
462 | 29b62aeb769f |
|
462 | 29b62aeb769f | |
463 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
463 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
464 |
|
464 | |||
465 | $ exit 0 |
|
465 | $ exit 0 |
General Comments 0
You need to be logged in to leave comments.
Login now