##// END OF EJS Templates
hooks: add some test about HGPLAIN setting and hooks...
marmoute -
r47241:07602829 stable
parent child Browse files
Show More
@@ -1,1392 +1,1419 b''
1 commit hooks can see env vars
1 commit hooks can see env vars
2 (and post-transaction one are run unlocked)
2 (and post-transaction one are run unlocked)
3
3
4
4
5 $ cat > $TESTTMP/txnabort.checkargs.py <<EOF
5 $ cat > $TESTTMP/txnabort.checkargs.py <<EOF
6 > from mercurial import pycompat
6 > from mercurial import pycompat
7 > def showargs(ui, repo, hooktype, **kwargs):
7 > def showargs(ui, repo, hooktype, **kwargs):
8 > kwargs = pycompat.byteskwargs(kwargs)
8 > kwargs = pycompat.byteskwargs(kwargs)
9 > ui.write(b'%s Python hook: %s\n' % (hooktype,
9 > ui.write(b'%s Python hook: %s\n' % (hooktype,
10 > b','.join(sorted(kwargs))))
10 > b','.join(sorted(kwargs))))
11 > EOF
11 > EOF
12
12
13 $ hg init a
13 $ hg init a
14 $ cd a
14 $ cd a
15 $ cat > .hg/hgrc <<EOF
15 $ cat > .hg/hgrc <<EOF
16 > [hooks]
16 > [hooks]
17 > commit = sh -c "HG_LOCAL= HG_TAG= printenv.py --line commit"
17 > commit = sh -c "HG_LOCAL= HG_TAG= printenv.py --line commit"
18 > commit.b = sh -c "HG_LOCAL= HG_TAG= printenv.py --line commit.b"
18 > commit.b = sh -c "HG_LOCAL= HG_TAG= printenv.py --line commit.b"
19 > precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= printenv.py --line precommit"
19 > precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= printenv.py --line precommit"
20 > pretxncommit = sh -c "HG_LOCAL= HG_TAG= printenv.py --line pretxncommit"
20 > pretxncommit = sh -c "HG_LOCAL= HG_TAG= printenv.py --line pretxncommit"
21 > pretxncommit.tip = hg -q tip
21 > pretxncommit.tip = hg -q tip
22 > pre-identify = sh -c "printenv.py --line pre-identify 1"
22 > pre-identify = sh -c "printenv.py --line pre-identify 1"
23 > pre-cat = sh -c "printenv.py --line pre-cat"
23 > pre-cat = sh -c "printenv.py --line pre-cat"
24 > post-cat = sh -c "printenv.py --line post-cat"
24 > post-cat = sh -c "printenv.py --line post-cat"
25 > pretxnopen = sh -c "HG_LOCAL= HG_TAG= printenv.py --line pretxnopen"
25 > pretxnopen = sh -c "HG_LOCAL= HG_TAG= printenv.py --line pretxnopen"
26 > pretxnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py --line pretxnclose"
26 > pretxnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py --line pretxnclose"
27 > txnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py --line txnclose"
27 > txnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py --line txnclose"
28 > txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs
28 > txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs
29 > txnabort.1 = sh -c "HG_LOCAL= HG_TAG= printenv.py --line txnabort"
29 > txnabort.1 = sh -c "HG_LOCAL= HG_TAG= printenv.py --line txnabort"
30 > txnclose.checklock = sh -c "hg debuglock > /dev/null"
30 > txnclose.checklock = sh -c "hg debuglock > /dev/null"
31 > EOF
31 > EOF
32 $ echo a > a
32 $ echo a > a
33 $ hg add a
33 $ hg add a
34 $ hg commit -m a
34 $ hg commit -m a
35 precommit hook: HG_HOOKNAME=precommit
35 precommit hook: HG_HOOKNAME=precommit
36 HG_HOOKTYPE=precommit
36 HG_HOOKTYPE=precommit
37 HG_PARENT1=0000000000000000000000000000000000000000
37 HG_PARENT1=0000000000000000000000000000000000000000
38
38
39 pretxnopen hook: HG_HOOKNAME=pretxnopen
39 pretxnopen hook: HG_HOOKNAME=pretxnopen
40 HG_HOOKTYPE=pretxnopen
40 HG_HOOKTYPE=pretxnopen
41 HG_TXNID=TXN:$ID$
41 HG_TXNID=TXN:$ID$
42 HG_TXNNAME=commit
42 HG_TXNNAME=commit
43
43
44 pretxncommit hook: HG_HOOKNAME=pretxncommit
44 pretxncommit hook: HG_HOOKNAME=pretxncommit
45 HG_HOOKTYPE=pretxncommit
45 HG_HOOKTYPE=pretxncommit
46 HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
46 HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
47 HG_PARENT1=0000000000000000000000000000000000000000
47 HG_PARENT1=0000000000000000000000000000000000000000
48 HG_PENDING=$TESTTMP/a
48 HG_PENDING=$TESTTMP/a
49
49
50 0:cb9a9f314b8b
50 0:cb9a9f314b8b
51 pretxnclose hook: HG_HOOKNAME=pretxnclose
51 pretxnclose hook: HG_HOOKNAME=pretxnclose
52 HG_HOOKTYPE=pretxnclose
52 HG_HOOKTYPE=pretxnclose
53 HG_PENDING=$TESTTMP/a
53 HG_PENDING=$TESTTMP/a
54 HG_PHASES_MOVED=1
54 HG_PHASES_MOVED=1
55 HG_TXNID=TXN:$ID$
55 HG_TXNID=TXN:$ID$
56 HG_TXNNAME=commit
56 HG_TXNNAME=commit
57
57
58 txnclose hook: HG_HOOKNAME=txnclose
58 txnclose hook: HG_HOOKNAME=txnclose
59 HG_HOOKTYPE=txnclose
59 HG_HOOKTYPE=txnclose
60 HG_PHASES_MOVED=1
60 HG_PHASES_MOVED=1
61 HG_TXNID=TXN:$ID$
61 HG_TXNID=TXN:$ID$
62 HG_TXNNAME=commit
62 HG_TXNNAME=commit
63
63
64 commit hook: HG_HOOKNAME=commit
64 commit hook: HG_HOOKNAME=commit
65 HG_HOOKTYPE=commit
65 HG_HOOKTYPE=commit
66 HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
66 HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
67 HG_PARENT1=0000000000000000000000000000000000000000
67 HG_PARENT1=0000000000000000000000000000000000000000
68
68
69 commit.b hook: HG_HOOKNAME=commit.b
69 commit.b hook: HG_HOOKNAME=commit.b
70 HG_HOOKTYPE=commit
70 HG_HOOKTYPE=commit
71 HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
71 HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
72 HG_PARENT1=0000000000000000000000000000000000000000
72 HG_PARENT1=0000000000000000000000000000000000000000
73
73
74
74
75 $ hg clone . ../b
75 $ hg clone . ../b
76 updating to branch default
76 updating to branch default
77 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
77 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
78 $ cd ../b
78 $ cd ../b
79
79
80 changegroup hooks can see env vars
80 changegroup hooks can see env vars
81
81
82 $ cat > .hg/hgrc <<EOF
82 $ cat > .hg/hgrc <<EOF
83 > [hooks]
83 > [hooks]
84 > prechangegroup = sh -c "printenv.py --line prechangegroup"
84 > prechangegroup = sh -c "printenv.py --line prechangegroup"
85 > changegroup = sh -c "printenv.py --line changegroup"
85 > changegroup = sh -c "printenv.py --line changegroup"
86 > incoming = sh -c "printenv.py --line incoming"
86 > incoming = sh -c "printenv.py --line incoming"
87 > EOF
87 > EOF
88
88
89 pretxncommit and commit hooks can see both parents of merge
89 pretxncommit and commit hooks can see both parents of merge
90
90
91 $ cd ../a
91 $ cd ../a
92 $ echo b >> a
92 $ echo b >> a
93 $ hg commit -m a1 -d "1 0"
93 $ hg commit -m a1 -d "1 0"
94 precommit hook: HG_HOOKNAME=precommit
94 precommit hook: HG_HOOKNAME=precommit
95 HG_HOOKTYPE=precommit
95 HG_HOOKTYPE=precommit
96 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
96 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
97
97
98 pretxnopen hook: HG_HOOKNAME=pretxnopen
98 pretxnopen hook: HG_HOOKNAME=pretxnopen
99 HG_HOOKTYPE=pretxnopen
99 HG_HOOKTYPE=pretxnopen
100 HG_TXNID=TXN:$ID$
100 HG_TXNID=TXN:$ID$
101 HG_TXNNAME=commit
101 HG_TXNNAME=commit
102
102
103 pretxncommit hook: HG_HOOKNAME=pretxncommit
103 pretxncommit hook: HG_HOOKNAME=pretxncommit
104 HG_HOOKTYPE=pretxncommit
104 HG_HOOKTYPE=pretxncommit
105 HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd
105 HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd
106 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
106 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
107 HG_PENDING=$TESTTMP/a
107 HG_PENDING=$TESTTMP/a
108
108
109 1:ab228980c14d
109 1:ab228980c14d
110 pretxnclose hook: HG_HOOKNAME=pretxnclose
110 pretxnclose hook: HG_HOOKNAME=pretxnclose
111 HG_HOOKTYPE=pretxnclose
111 HG_HOOKTYPE=pretxnclose
112 HG_PENDING=$TESTTMP/a
112 HG_PENDING=$TESTTMP/a
113 HG_TXNID=TXN:$ID$
113 HG_TXNID=TXN:$ID$
114 HG_TXNNAME=commit
114 HG_TXNNAME=commit
115
115
116 txnclose hook: HG_HOOKNAME=txnclose
116 txnclose hook: HG_HOOKNAME=txnclose
117 HG_HOOKTYPE=txnclose
117 HG_HOOKTYPE=txnclose
118 HG_TXNID=TXN:$ID$
118 HG_TXNID=TXN:$ID$
119 HG_TXNNAME=commit
119 HG_TXNNAME=commit
120
120
121 commit hook: HG_HOOKNAME=commit
121 commit hook: HG_HOOKNAME=commit
122 HG_HOOKTYPE=commit
122 HG_HOOKTYPE=commit
123 HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd
123 HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd
124 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
124 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
125
125
126 commit.b hook: HG_HOOKNAME=commit.b
126 commit.b hook: HG_HOOKNAME=commit.b
127 HG_HOOKTYPE=commit
127 HG_HOOKTYPE=commit
128 HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd
128 HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd
129 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
129 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
130
130
131 $ hg update -C 0
131 $ hg update -C 0
132 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
132 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
133 $ echo b > b
133 $ echo b > b
134 $ hg add b
134 $ hg add b
135 $ hg commit -m b -d '1 0'
135 $ hg commit -m b -d '1 0'
136 precommit hook: HG_HOOKNAME=precommit
136 precommit hook: HG_HOOKNAME=precommit
137 HG_HOOKTYPE=precommit
137 HG_HOOKTYPE=precommit
138 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
138 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
139
139
140 pretxnopen hook: HG_HOOKNAME=pretxnopen
140 pretxnopen hook: HG_HOOKNAME=pretxnopen
141 HG_HOOKTYPE=pretxnopen
141 HG_HOOKTYPE=pretxnopen
142 HG_TXNID=TXN:$ID$
142 HG_TXNID=TXN:$ID$
143 HG_TXNNAME=commit
143 HG_TXNNAME=commit
144
144
145 pretxncommit hook: HG_HOOKNAME=pretxncommit
145 pretxncommit hook: HG_HOOKNAME=pretxncommit
146 HG_HOOKTYPE=pretxncommit
146 HG_HOOKTYPE=pretxncommit
147 HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
147 HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
148 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
148 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
149 HG_PENDING=$TESTTMP/a
149 HG_PENDING=$TESTTMP/a
150
150
151 2:ee9deb46ab31
151 2:ee9deb46ab31
152 pretxnclose hook: HG_HOOKNAME=pretxnclose
152 pretxnclose hook: HG_HOOKNAME=pretxnclose
153 HG_HOOKTYPE=pretxnclose
153 HG_HOOKTYPE=pretxnclose
154 HG_PENDING=$TESTTMP/a
154 HG_PENDING=$TESTTMP/a
155 HG_TXNID=TXN:$ID$
155 HG_TXNID=TXN:$ID$
156 HG_TXNNAME=commit
156 HG_TXNNAME=commit
157
157
158 created new head
158 created new head
159 txnclose hook: HG_HOOKNAME=txnclose
159 txnclose hook: HG_HOOKNAME=txnclose
160 HG_HOOKTYPE=txnclose
160 HG_HOOKTYPE=txnclose
161 HG_TXNID=TXN:$ID$
161 HG_TXNID=TXN:$ID$
162 HG_TXNNAME=commit
162 HG_TXNNAME=commit
163
163
164 commit hook: HG_HOOKNAME=commit
164 commit hook: HG_HOOKNAME=commit
165 HG_HOOKTYPE=commit
165 HG_HOOKTYPE=commit
166 HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
166 HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
167 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
167 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
168
168
169 commit.b hook: HG_HOOKNAME=commit.b
169 commit.b hook: HG_HOOKNAME=commit.b
170 HG_HOOKTYPE=commit
170 HG_HOOKTYPE=commit
171 HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
171 HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
172 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
172 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
173
173
174 $ hg merge 1
174 $ hg merge 1
175 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
175 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
176 (branch merge, don't forget to commit)
176 (branch merge, don't forget to commit)
177 $ hg commit -m merge -d '2 0'
177 $ hg commit -m merge -d '2 0'
178 precommit hook: HG_HOOKNAME=precommit
178 precommit hook: HG_HOOKNAME=precommit
179 HG_HOOKTYPE=precommit
179 HG_HOOKTYPE=precommit
180 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
180 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
181 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
181 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
182
182
183 pretxnopen hook: HG_HOOKNAME=pretxnopen
183 pretxnopen hook: HG_HOOKNAME=pretxnopen
184 HG_HOOKTYPE=pretxnopen
184 HG_HOOKTYPE=pretxnopen
185 HG_TXNID=TXN:$ID$
185 HG_TXNID=TXN:$ID$
186 HG_TXNNAME=commit
186 HG_TXNNAME=commit
187
187
188 pretxncommit hook: HG_HOOKNAME=pretxncommit
188 pretxncommit hook: HG_HOOKNAME=pretxncommit
189 HG_HOOKTYPE=pretxncommit
189 HG_HOOKTYPE=pretxncommit
190 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2
190 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2
191 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
191 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
192 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
192 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
193 HG_PENDING=$TESTTMP/a
193 HG_PENDING=$TESTTMP/a
194
194
195 3:07f3376c1e65
195 3:07f3376c1e65
196 pretxnclose hook: HG_HOOKNAME=pretxnclose
196 pretxnclose hook: HG_HOOKNAME=pretxnclose
197 HG_HOOKTYPE=pretxnclose
197 HG_HOOKTYPE=pretxnclose
198 HG_PENDING=$TESTTMP/a
198 HG_PENDING=$TESTTMP/a
199 HG_TXNID=TXN:$ID$
199 HG_TXNID=TXN:$ID$
200 HG_TXNNAME=commit
200 HG_TXNNAME=commit
201
201
202 txnclose hook: HG_HOOKNAME=txnclose
202 txnclose hook: HG_HOOKNAME=txnclose
203 HG_HOOKTYPE=txnclose
203 HG_HOOKTYPE=txnclose
204 HG_TXNID=TXN:$ID$
204 HG_TXNID=TXN:$ID$
205 HG_TXNNAME=commit
205 HG_TXNNAME=commit
206
206
207 commit hook: HG_HOOKNAME=commit
207 commit hook: HG_HOOKNAME=commit
208 HG_HOOKTYPE=commit
208 HG_HOOKTYPE=commit
209 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2
209 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2
210 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
210 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
211 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
211 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
212
212
213 commit.b hook: HG_HOOKNAME=commit.b
213 commit.b hook: HG_HOOKNAME=commit.b
214 HG_HOOKTYPE=commit
214 HG_HOOKTYPE=commit
215 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2
215 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2
216 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
216 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
217 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
217 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
218
218
219
219
220 test generic hooks
220 test generic hooks
221
221
222 $ hg id
222 $ hg id
223 pre-identify hook: HG_ARGS=id
223 pre-identify hook: HG_ARGS=id
224 HG_HOOKNAME=pre-identify
224 HG_HOOKNAME=pre-identify
225 HG_HOOKTYPE=pre-identify
225 HG_HOOKTYPE=pre-identify
226 HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'insecure': None, 'num': None, 'remotecmd': '', 'rev': '', 'ssh': '', 'tags': None, 'template': ''}
226 HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'insecure': None, 'num': None, 'remotecmd': '', 'rev': '', 'ssh': '', 'tags': None, 'template': ''}
227 HG_PATS=[]
227 HG_PATS=[]
228
228
229 abort: pre-identify hook exited with status 1
229 abort: pre-identify hook exited with status 1
230 [255]
230 [255]
231 $ hg cat b
231 $ hg cat b
232 pre-cat hook: HG_ARGS=cat b
232 pre-cat hook: HG_ARGS=cat b
233 HG_HOOKNAME=pre-cat
233 HG_HOOKNAME=pre-cat
234 HG_HOOKTYPE=pre-cat
234 HG_HOOKTYPE=pre-cat
235 HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': '', 'template': ''}
235 HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': '', 'template': ''}
236 HG_PATS=['b']
236 HG_PATS=['b']
237
237
238 b
238 b
239 post-cat hook: HG_ARGS=cat b
239 post-cat hook: HG_ARGS=cat b
240 HG_HOOKNAME=post-cat
240 HG_HOOKNAME=post-cat
241 HG_HOOKTYPE=post-cat
241 HG_HOOKTYPE=post-cat
242 HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': '', 'template': ''}
242 HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': '', 'template': ''}
243 HG_PATS=['b']
243 HG_PATS=['b']
244 HG_RESULT=0
244 HG_RESULT=0
245
245
246
246
247 $ cd ../b
247 $ cd ../b
248 $ hg pull ../a
248 $ hg pull ../a
249 pulling from ../a
249 pulling from ../a
250 searching for changes
250 searching for changes
251 prechangegroup hook: HG_HOOKNAME=prechangegroup
251 prechangegroup hook: HG_HOOKNAME=prechangegroup
252 HG_HOOKTYPE=prechangegroup
252 HG_HOOKTYPE=prechangegroup
253 HG_SOURCE=pull
253 HG_SOURCE=pull
254 HG_TXNID=TXN:$ID$
254 HG_TXNID=TXN:$ID$
255 HG_TXNNAME=pull
255 HG_TXNNAME=pull
256 file:/*/$TESTTMP/a (glob)
256 file:/*/$TESTTMP/a (glob)
257 HG_URL=file:$TESTTMP/a
257 HG_URL=file:$TESTTMP/a
258
258
259 adding changesets
259 adding changesets
260 adding manifests
260 adding manifests
261 adding file changes
261 adding file changes
262 added 3 changesets with 2 changes to 2 files
262 added 3 changesets with 2 changes to 2 files
263 new changesets ab228980c14d:07f3376c1e65
263 new changesets ab228980c14d:07f3376c1e65
264 changegroup hook: HG_HOOKNAME=changegroup
264 changegroup hook: HG_HOOKNAME=changegroup
265 HG_HOOKTYPE=changegroup
265 HG_HOOKTYPE=changegroup
266 HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd
266 HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd
267 HG_NODE_LAST=07f3376c1e655977439df2a814e3cc14b27abac2
267 HG_NODE_LAST=07f3376c1e655977439df2a814e3cc14b27abac2
268 HG_SOURCE=pull
268 HG_SOURCE=pull
269 HG_TXNID=TXN:$ID$
269 HG_TXNID=TXN:$ID$
270 HG_TXNNAME=pull
270 HG_TXNNAME=pull
271 file:/*/$TESTTMP/a (glob)
271 file:/*/$TESTTMP/a (glob)
272 HG_URL=file:$TESTTMP/a
272 HG_URL=file:$TESTTMP/a
273
273
274 incoming hook: HG_HOOKNAME=incoming
274 incoming hook: HG_HOOKNAME=incoming
275 HG_HOOKTYPE=incoming
275 HG_HOOKTYPE=incoming
276 HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd
276 HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd
277 HG_SOURCE=pull
277 HG_SOURCE=pull
278 HG_TXNID=TXN:$ID$
278 HG_TXNID=TXN:$ID$
279 HG_TXNNAME=pull
279 HG_TXNNAME=pull
280 file:/*/$TESTTMP/a (glob)
280 file:/*/$TESTTMP/a (glob)
281 HG_URL=file:$TESTTMP/a
281 HG_URL=file:$TESTTMP/a
282
282
283 incoming hook: HG_HOOKNAME=incoming
283 incoming hook: HG_HOOKNAME=incoming
284 HG_HOOKTYPE=incoming
284 HG_HOOKTYPE=incoming
285 HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
285 HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2
286 HG_SOURCE=pull
286 HG_SOURCE=pull
287 HG_TXNID=TXN:$ID$
287 HG_TXNID=TXN:$ID$
288 HG_TXNNAME=pull
288 HG_TXNNAME=pull
289 file:/*/$TESTTMP/a (glob)
289 file:/*/$TESTTMP/a (glob)
290 HG_URL=file:$TESTTMP/a
290 HG_URL=file:$TESTTMP/a
291
291
292 incoming hook: HG_HOOKNAME=incoming
292 incoming hook: HG_HOOKNAME=incoming
293 HG_HOOKTYPE=incoming
293 HG_HOOKTYPE=incoming
294 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2
294 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2
295 HG_SOURCE=pull
295 HG_SOURCE=pull
296 HG_TXNID=TXN:$ID$
296 HG_TXNID=TXN:$ID$
297 HG_TXNNAME=pull
297 HG_TXNNAME=pull
298 file:/*/$TESTTMP/a (glob)
298 file:/*/$TESTTMP/a (glob)
299 HG_URL=file:$TESTTMP/a
299 HG_URL=file:$TESTTMP/a
300
300
301 (run 'hg update' to get a working copy)
301 (run 'hg update' to get a working copy)
302
302
303 tag hooks can see env vars
303 tag hooks can see env vars
304
304
305 $ cd ../a
305 $ cd ../a
306 $ cat >> .hg/hgrc <<EOF
306 $ cat >> .hg/hgrc <<EOF
307 > pretag = sh -c "printenv.py --line pretag"
307 > pretag = sh -c "printenv.py --line pretag"
308 > tag = sh -c "HG_PARENT1= HG_PARENT2= printenv.py --line tag"
308 > tag = sh -c "HG_PARENT1= HG_PARENT2= printenv.py --line tag"
309 > EOF
309 > EOF
310 $ hg tag -d '3 0' a
310 $ hg tag -d '3 0' a
311 pretag hook: HG_HOOKNAME=pretag
311 pretag hook: HG_HOOKNAME=pretag
312 HG_HOOKTYPE=pretag
312 HG_HOOKTYPE=pretag
313 HG_LOCAL=0
313 HG_LOCAL=0
314 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2
314 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2
315 HG_TAG=a
315 HG_TAG=a
316
316
317 precommit hook: HG_HOOKNAME=precommit
317 precommit hook: HG_HOOKNAME=precommit
318 HG_HOOKTYPE=precommit
318 HG_HOOKTYPE=precommit
319 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
319 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
320
320
321 pretxnopen hook: HG_HOOKNAME=pretxnopen
321 pretxnopen hook: HG_HOOKNAME=pretxnopen
322 HG_HOOKTYPE=pretxnopen
322 HG_HOOKTYPE=pretxnopen
323 HG_TXNID=TXN:$ID$
323 HG_TXNID=TXN:$ID$
324 HG_TXNNAME=commit
324 HG_TXNNAME=commit
325
325
326 pretxncommit hook: HG_HOOKNAME=pretxncommit
326 pretxncommit hook: HG_HOOKNAME=pretxncommit
327 HG_HOOKTYPE=pretxncommit
327 HG_HOOKTYPE=pretxncommit
328 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
328 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
329 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
329 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
330 HG_PENDING=$TESTTMP/a
330 HG_PENDING=$TESTTMP/a
331
331
332 4:539e4b31b6dc
332 4:539e4b31b6dc
333 pretxnclose hook: HG_HOOKNAME=pretxnclose
333 pretxnclose hook: HG_HOOKNAME=pretxnclose
334 HG_HOOKTYPE=pretxnclose
334 HG_HOOKTYPE=pretxnclose
335 HG_PENDING=$TESTTMP/a
335 HG_PENDING=$TESTTMP/a
336 HG_TXNID=TXN:$ID$
336 HG_TXNID=TXN:$ID$
337 HG_TXNNAME=commit
337 HG_TXNNAME=commit
338
338
339 tag hook: HG_HOOKNAME=tag
339 tag hook: HG_HOOKNAME=tag
340 HG_HOOKTYPE=tag
340 HG_HOOKTYPE=tag
341 HG_LOCAL=0
341 HG_LOCAL=0
342 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2
342 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2
343 HG_TAG=a
343 HG_TAG=a
344
344
345 txnclose hook: HG_HOOKNAME=txnclose
345 txnclose hook: HG_HOOKNAME=txnclose
346 HG_HOOKTYPE=txnclose
346 HG_HOOKTYPE=txnclose
347 HG_TXNID=TXN:$ID$
347 HG_TXNID=TXN:$ID$
348 HG_TXNNAME=commit
348 HG_TXNNAME=commit
349
349
350 commit hook: HG_HOOKNAME=commit
350 commit hook: HG_HOOKNAME=commit
351 HG_HOOKTYPE=commit
351 HG_HOOKTYPE=commit
352 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
352 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
353 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
353 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
354
354
355 commit.b hook: HG_HOOKNAME=commit.b
355 commit.b hook: HG_HOOKNAME=commit.b
356 HG_HOOKTYPE=commit
356 HG_HOOKTYPE=commit
357 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
357 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
358 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
358 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
359
359
360 $ hg tag -l la
360 $ hg tag -l la
361 pretag hook: HG_HOOKNAME=pretag
361 pretag hook: HG_HOOKNAME=pretag
362 HG_HOOKTYPE=pretag
362 HG_HOOKTYPE=pretag
363 HG_LOCAL=1
363 HG_LOCAL=1
364 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
364 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
365 HG_TAG=la
365 HG_TAG=la
366
366
367 tag hook: HG_HOOKNAME=tag
367 tag hook: HG_HOOKNAME=tag
368 HG_HOOKTYPE=tag
368 HG_HOOKTYPE=tag
369 HG_LOCAL=1
369 HG_LOCAL=1
370 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
370 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
371 HG_TAG=la
371 HG_TAG=la
372
372
373
373
374 pretag hook can forbid tagging
374 pretag hook can forbid tagging
375
375
376 $ cat >> .hg/hgrc <<EOF
376 $ cat >> .hg/hgrc <<EOF
377 > pretag.forbid = sh -c "printenv.py --line pretag.forbid 1"
377 > pretag.forbid = sh -c "printenv.py --line pretag.forbid 1"
378 > EOF
378 > EOF
379 $ hg tag -d '4 0' fa
379 $ hg tag -d '4 0' fa
380 pretag hook: HG_HOOKNAME=pretag
380 pretag hook: HG_HOOKNAME=pretag
381 HG_HOOKTYPE=pretag
381 HG_HOOKTYPE=pretag
382 HG_LOCAL=0
382 HG_LOCAL=0
383 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
383 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
384 HG_TAG=fa
384 HG_TAG=fa
385
385
386 pretag.forbid hook: HG_HOOKNAME=pretag.forbid
386 pretag.forbid hook: HG_HOOKNAME=pretag.forbid
387 HG_HOOKTYPE=pretag
387 HG_HOOKTYPE=pretag
388 HG_LOCAL=0
388 HG_LOCAL=0
389 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
389 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
390 HG_TAG=fa
390 HG_TAG=fa
391
391
392 abort: pretag.forbid hook exited with status 1
392 abort: pretag.forbid hook exited with status 1
393 [255]
393 [255]
394 $ hg tag -l fla
394 $ hg tag -l fla
395 pretag hook: HG_HOOKNAME=pretag
395 pretag hook: HG_HOOKNAME=pretag
396 HG_HOOKTYPE=pretag
396 HG_HOOKTYPE=pretag
397 HG_LOCAL=1
397 HG_LOCAL=1
398 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
398 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
399 HG_TAG=fla
399 HG_TAG=fla
400
400
401 pretag.forbid hook: HG_HOOKNAME=pretag.forbid
401 pretag.forbid hook: HG_HOOKNAME=pretag.forbid
402 HG_HOOKTYPE=pretag
402 HG_HOOKTYPE=pretag
403 HG_LOCAL=1
403 HG_LOCAL=1
404 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
404 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
405 HG_TAG=fla
405 HG_TAG=fla
406
406
407 abort: pretag.forbid hook exited with status 1
407 abort: pretag.forbid hook exited with status 1
408 [255]
408 [255]
409
409
410 pretxncommit hook can see changeset, can roll back txn, changeset no
410 pretxncommit hook can see changeset, can roll back txn, changeset no
411 more there after
411 more there after
412
412
413 $ cat >> .hg/hgrc <<EOF
413 $ cat >> .hg/hgrc <<EOF
414 > pretxncommit.forbid0 = sh -c "hg tip -q"
414 > pretxncommit.forbid0 = sh -c "hg tip -q"
415 > pretxncommit.forbid1 = sh -c "printenv.py --line pretxncommit.forbid 1"
415 > pretxncommit.forbid1 = sh -c "printenv.py --line pretxncommit.forbid 1"
416 > EOF
416 > EOF
417 $ echo z > z
417 $ echo z > z
418 $ hg add z
418 $ hg add z
419 $ hg -q tip
419 $ hg -q tip
420 4:539e4b31b6dc
420 4:539e4b31b6dc
421 $ hg commit -m 'fail' -d '4 0'
421 $ hg commit -m 'fail' -d '4 0'
422 precommit hook: HG_HOOKNAME=precommit
422 precommit hook: HG_HOOKNAME=precommit
423 HG_HOOKTYPE=precommit
423 HG_HOOKTYPE=precommit
424 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
424 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
425
425
426 pretxnopen hook: HG_HOOKNAME=pretxnopen
426 pretxnopen hook: HG_HOOKNAME=pretxnopen
427 HG_HOOKTYPE=pretxnopen
427 HG_HOOKTYPE=pretxnopen
428 HG_TXNID=TXN:$ID$
428 HG_TXNID=TXN:$ID$
429 HG_TXNNAME=commit
429 HG_TXNNAME=commit
430
430
431 pretxncommit hook: HG_HOOKNAME=pretxncommit
431 pretxncommit hook: HG_HOOKNAME=pretxncommit
432 HG_HOOKTYPE=pretxncommit
432 HG_HOOKTYPE=pretxncommit
433 HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567
433 HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567
434 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
434 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
435 HG_PENDING=$TESTTMP/a
435 HG_PENDING=$TESTTMP/a
436
436
437 5:6f611f8018c1
437 5:6f611f8018c1
438 5:6f611f8018c1
438 5:6f611f8018c1
439 pretxncommit.forbid hook: HG_HOOKNAME=pretxncommit.forbid1
439 pretxncommit.forbid hook: HG_HOOKNAME=pretxncommit.forbid1
440 HG_HOOKTYPE=pretxncommit
440 HG_HOOKTYPE=pretxncommit
441 HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567
441 HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567
442 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
442 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
443 HG_PENDING=$TESTTMP/a
443 HG_PENDING=$TESTTMP/a
444
444
445 transaction abort!
445 transaction abort!
446 txnabort Python hook: changes,txnid,txnname
446 txnabort Python hook: changes,txnid,txnname
447 txnabort hook: HG_HOOKNAME=txnabort.1
447 txnabort hook: HG_HOOKNAME=txnabort.1
448 HG_HOOKTYPE=txnabort
448 HG_HOOKTYPE=txnabort
449 HG_TXNID=TXN:$ID$
449 HG_TXNID=TXN:$ID$
450 HG_TXNNAME=commit
450 HG_TXNNAME=commit
451
451
452 rollback completed
452 rollback completed
453 abort: pretxncommit.forbid1 hook exited with status 1
453 abort: pretxncommit.forbid1 hook exited with status 1
454 [255]
454 [255]
455 $ hg -q tip
455 $ hg -q tip
456 4:539e4b31b6dc
456 4:539e4b31b6dc
457
457
458 (Check that no 'changelog.i.a' file were left behind)
458 (Check that no 'changelog.i.a' file were left behind)
459
459
460 $ ls -1 .hg/store/
460 $ ls -1 .hg/store/
461 00changelog.i
461 00changelog.i
462 00manifest.i
462 00manifest.i
463 data
463 data
464 fncache (repofncache !)
464 fncache (repofncache !)
465 journal.phaseroots
465 journal.phaseroots
466 phaseroots
466 phaseroots
467 undo
467 undo
468 undo.backup.fncache (repofncache !)
468 undo.backup.fncache (repofncache !)
469 undo.backupfiles
469 undo.backupfiles
470 undo.phaseroots
470 undo.phaseroots
471
471
472
472
473 precommit hook can prevent commit
473 precommit hook can prevent commit
474
474
475 $ cat >> .hg/hgrc <<EOF
475 $ cat >> .hg/hgrc <<EOF
476 > precommit.forbid = sh -c "printenv.py --line precommit.forbid 1"
476 > precommit.forbid = sh -c "printenv.py --line precommit.forbid 1"
477 > EOF
477 > EOF
478 $ hg commit -m 'fail' -d '4 0'
478 $ hg commit -m 'fail' -d '4 0'
479 precommit hook: HG_HOOKNAME=precommit
479 precommit hook: HG_HOOKNAME=precommit
480 HG_HOOKTYPE=precommit
480 HG_HOOKTYPE=precommit
481 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
481 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
482
482
483 precommit.forbid hook: HG_HOOKNAME=precommit.forbid
483 precommit.forbid hook: HG_HOOKNAME=precommit.forbid
484 HG_HOOKTYPE=precommit
484 HG_HOOKTYPE=precommit
485 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
485 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
486
486
487 abort: precommit.forbid hook exited with status 1
487 abort: precommit.forbid hook exited with status 1
488 [255]
488 [255]
489 $ hg -q tip
489 $ hg -q tip
490 4:539e4b31b6dc
490 4:539e4b31b6dc
491
491
492 preupdate hook can prevent update
492 preupdate hook can prevent update
493
493
494 $ cat >> .hg/hgrc <<EOF
494 $ cat >> .hg/hgrc <<EOF
495 > preupdate = sh -c "printenv.py --line preupdate"
495 > preupdate = sh -c "printenv.py --line preupdate"
496 > EOF
496 > EOF
497 $ hg update 1
497 $ hg update 1
498 preupdate hook: HG_HOOKNAME=preupdate
498 preupdate hook: HG_HOOKNAME=preupdate
499 HG_HOOKTYPE=preupdate
499 HG_HOOKTYPE=preupdate
500 HG_PARENT1=ab228980c14d
500 HG_PARENT1=ab228980c14d
501
501
502 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
502 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
503
503
504 update hook
504 update hook
505
505
506 $ cat >> .hg/hgrc <<EOF
506 $ cat >> .hg/hgrc <<EOF
507 > update = sh -c "printenv.py --line update"
507 > update = sh -c "printenv.py --line update"
508 > EOF
508 > EOF
509 $ hg update
509 $ hg update
510 preupdate hook: HG_HOOKNAME=preupdate
510 preupdate hook: HG_HOOKNAME=preupdate
511 HG_HOOKTYPE=preupdate
511 HG_HOOKTYPE=preupdate
512 HG_PARENT1=539e4b31b6dc
512 HG_PARENT1=539e4b31b6dc
513
513
514 update hook: HG_ERROR=0
514 update hook: HG_ERROR=0
515 HG_HOOKNAME=update
515 HG_HOOKNAME=update
516 HG_HOOKTYPE=update
516 HG_HOOKTYPE=update
517 HG_PARENT1=539e4b31b6dc
517 HG_PARENT1=539e4b31b6dc
518
518
519 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
519 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
520
520
521 pushkey hook
521 pushkey hook
522
522
523 $ cat >> .hg/hgrc <<EOF
523 $ cat >> .hg/hgrc <<EOF
524 > pushkey = sh -c "printenv.py --line pushkey"
524 > pushkey = sh -c "printenv.py --line pushkey"
525 > EOF
525 > EOF
526 $ cd ../b
526 $ cd ../b
527 $ hg bookmark -r null foo
527 $ hg bookmark -r null foo
528 $ hg push -B foo ../a
528 $ hg push -B foo ../a
529 pushing to ../a
529 pushing to ../a
530 searching for changes
530 searching for changes
531 no changes found
531 no changes found
532 pretxnopen hook: HG_HOOKNAME=pretxnopen
532 pretxnopen hook: HG_HOOKNAME=pretxnopen
533 HG_HOOKTYPE=pretxnopen
533 HG_HOOKTYPE=pretxnopen
534 HG_TXNID=TXN:$ID$
534 HG_TXNID=TXN:$ID$
535 HG_TXNNAME=push
535 HG_TXNNAME=push
536
536
537 pretxnclose hook: HG_BOOKMARK_MOVED=1
537 pretxnclose hook: HG_BOOKMARK_MOVED=1
538 HG_BUNDLE2=1
538 HG_BUNDLE2=1
539 HG_HOOKNAME=pretxnclose
539 HG_HOOKNAME=pretxnclose
540 HG_HOOKTYPE=pretxnclose
540 HG_HOOKTYPE=pretxnclose
541 HG_PENDING=$TESTTMP/a
541 HG_PENDING=$TESTTMP/a
542 HG_SOURCE=push
542 HG_SOURCE=push
543 HG_TXNID=TXN:$ID$
543 HG_TXNID=TXN:$ID$
544 HG_TXNNAME=push
544 HG_TXNNAME=push
545 HG_URL=file:$TESTTMP/a
545 HG_URL=file:$TESTTMP/a
546
546
547 pushkey hook: HG_BUNDLE2=1
547 pushkey hook: HG_BUNDLE2=1
548 HG_HOOKNAME=pushkey
548 HG_HOOKNAME=pushkey
549 HG_HOOKTYPE=pushkey
549 HG_HOOKTYPE=pushkey
550 HG_KEY=foo
550 HG_KEY=foo
551 HG_NAMESPACE=bookmarks
551 HG_NAMESPACE=bookmarks
552 HG_NEW=0000000000000000000000000000000000000000
552 HG_NEW=0000000000000000000000000000000000000000
553 HG_PUSHKEYCOMPAT=1
553 HG_PUSHKEYCOMPAT=1
554 HG_SOURCE=push
554 HG_SOURCE=push
555 HG_TXNID=TXN:$ID$
555 HG_TXNID=TXN:$ID$
556 HG_TXNNAME=push
556 HG_TXNNAME=push
557 HG_URL=file:$TESTTMP/a
557 HG_URL=file:$TESTTMP/a
558
558
559 txnclose hook: HG_BOOKMARK_MOVED=1
559 txnclose hook: HG_BOOKMARK_MOVED=1
560 HG_BUNDLE2=1
560 HG_BUNDLE2=1
561 HG_HOOKNAME=txnclose
561 HG_HOOKNAME=txnclose
562 HG_HOOKTYPE=txnclose
562 HG_HOOKTYPE=txnclose
563 HG_SOURCE=push
563 HG_SOURCE=push
564 HG_TXNID=TXN:$ID$
564 HG_TXNID=TXN:$ID$
565 HG_TXNNAME=push
565 HG_TXNNAME=push
566 HG_URL=file:$TESTTMP/a
566 HG_URL=file:$TESTTMP/a
567
567
568 exporting bookmark foo
568 exporting bookmark foo
569 [1]
569 [1]
570 $ cd ../a
570 $ cd ../a
571
571
572 listkeys hook
572 listkeys hook
573
573
574 $ cat >> .hg/hgrc <<EOF
574 $ cat >> .hg/hgrc <<EOF
575 > listkeys = sh -c "printenv.py --line listkeys"
575 > listkeys = sh -c "printenv.py --line listkeys"
576 > EOF
576 > EOF
577 $ hg bookmark -r null bar
577 $ hg bookmark -r null bar
578 pretxnopen hook: HG_HOOKNAME=pretxnopen
578 pretxnopen hook: HG_HOOKNAME=pretxnopen
579 HG_HOOKTYPE=pretxnopen
579 HG_HOOKTYPE=pretxnopen
580 HG_TXNID=TXN:$ID$
580 HG_TXNID=TXN:$ID$
581 HG_TXNNAME=bookmark
581 HG_TXNNAME=bookmark
582
582
583 pretxnclose hook: HG_BOOKMARK_MOVED=1
583 pretxnclose hook: HG_BOOKMARK_MOVED=1
584 HG_HOOKNAME=pretxnclose
584 HG_HOOKNAME=pretxnclose
585 HG_HOOKTYPE=pretxnclose
585 HG_HOOKTYPE=pretxnclose
586 HG_PENDING=$TESTTMP/a
586 HG_PENDING=$TESTTMP/a
587 HG_TXNID=TXN:$ID$
587 HG_TXNID=TXN:$ID$
588 HG_TXNNAME=bookmark
588 HG_TXNNAME=bookmark
589
589
590 txnclose hook: HG_BOOKMARK_MOVED=1
590 txnclose hook: HG_BOOKMARK_MOVED=1
591 HG_HOOKNAME=txnclose
591 HG_HOOKNAME=txnclose
592 HG_HOOKTYPE=txnclose
592 HG_HOOKTYPE=txnclose
593 HG_TXNID=TXN:$ID$
593 HG_TXNID=TXN:$ID$
594 HG_TXNNAME=bookmark
594 HG_TXNNAME=bookmark
595
595
596 $ cd ../b
596 $ cd ../b
597 $ hg pull -B bar ../a
597 $ hg pull -B bar ../a
598 pulling from ../a
598 pulling from ../a
599 listkeys hook: HG_HOOKNAME=listkeys
599 listkeys hook: HG_HOOKNAME=listkeys
600 HG_HOOKTYPE=listkeys
600 HG_HOOKTYPE=listkeys
601 HG_NAMESPACE=bookmarks
601 HG_NAMESPACE=bookmarks
602 HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
602 HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
603
603
604 no changes found
604 no changes found
605 adding remote bookmark bar
605 adding remote bookmark bar
606 $ cd ../a
606 $ cd ../a
607
607
608 test that prepushkey can prevent incoming keys
608 test that prepushkey can prevent incoming keys
609
609
610 $ cat >> .hg/hgrc <<EOF
610 $ cat >> .hg/hgrc <<EOF
611 > prepushkey = sh -c "printenv.py --line prepushkey.forbid 1"
611 > prepushkey = sh -c "printenv.py --line prepushkey.forbid 1"
612 > EOF
612 > EOF
613 $ cd ../b
613 $ cd ../b
614 $ hg bookmark -r null baz
614 $ hg bookmark -r null baz
615 $ hg push -B baz ../a
615 $ hg push -B baz ../a
616 pushing to ../a
616 pushing to ../a
617 searching for changes
617 searching for changes
618 listkeys hook: HG_HOOKNAME=listkeys
618 listkeys hook: HG_HOOKNAME=listkeys
619 HG_HOOKTYPE=listkeys
619 HG_HOOKTYPE=listkeys
620 HG_NAMESPACE=phases
620 HG_NAMESPACE=phases
621 HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
621 HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
622
622
623 listkeys hook: HG_HOOKNAME=listkeys
623 listkeys hook: HG_HOOKNAME=listkeys
624 HG_HOOKTYPE=listkeys
624 HG_HOOKTYPE=listkeys
625 HG_NAMESPACE=bookmarks
625 HG_NAMESPACE=bookmarks
626 HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
626 HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
627
627
628 no changes found
628 no changes found
629 pretxnopen hook: HG_HOOKNAME=pretxnopen
629 pretxnopen hook: HG_HOOKNAME=pretxnopen
630 HG_HOOKTYPE=pretxnopen
630 HG_HOOKTYPE=pretxnopen
631 HG_TXNID=TXN:$ID$
631 HG_TXNID=TXN:$ID$
632 HG_TXNNAME=push
632 HG_TXNNAME=push
633
633
634 prepushkey.forbid hook: HG_BUNDLE2=1
634 prepushkey.forbid hook: HG_BUNDLE2=1
635 HG_HOOKNAME=prepushkey
635 HG_HOOKNAME=prepushkey
636 HG_HOOKTYPE=prepushkey
636 HG_HOOKTYPE=prepushkey
637 HG_KEY=baz
637 HG_KEY=baz
638 HG_NAMESPACE=bookmarks
638 HG_NAMESPACE=bookmarks
639 HG_NEW=0000000000000000000000000000000000000000
639 HG_NEW=0000000000000000000000000000000000000000
640 HG_PUSHKEYCOMPAT=1
640 HG_PUSHKEYCOMPAT=1
641 HG_SOURCE=push
641 HG_SOURCE=push
642 HG_TXNID=TXN:$ID$
642 HG_TXNID=TXN:$ID$
643 HG_TXNNAME=push
643 HG_TXNNAME=push
644 HG_URL=file:$TESTTMP/a
644 HG_URL=file:$TESTTMP/a
645
645
646 abort: prepushkey hook exited with status 1
646 abort: prepushkey hook exited with status 1
647 [255]
647 [255]
648 $ cd ../a
648 $ cd ../a
649
649
650 test that prelistkeys can prevent listing keys
650 test that prelistkeys can prevent listing keys
651
651
652 $ cat >> .hg/hgrc <<EOF
652 $ cat >> .hg/hgrc <<EOF
653 > prelistkeys = sh -c "printenv.py --line prelistkeys.forbid 1"
653 > prelistkeys = sh -c "printenv.py --line prelistkeys.forbid 1"
654 > EOF
654 > EOF
655 $ hg bookmark -r null quux
655 $ hg bookmark -r null quux
656 pretxnopen hook: HG_HOOKNAME=pretxnopen
656 pretxnopen hook: HG_HOOKNAME=pretxnopen
657 HG_HOOKTYPE=pretxnopen
657 HG_HOOKTYPE=pretxnopen
658 HG_TXNID=TXN:$ID$
658 HG_TXNID=TXN:$ID$
659 HG_TXNNAME=bookmark
659 HG_TXNNAME=bookmark
660
660
661 pretxnclose hook: HG_BOOKMARK_MOVED=1
661 pretxnclose hook: HG_BOOKMARK_MOVED=1
662 HG_HOOKNAME=pretxnclose
662 HG_HOOKNAME=pretxnclose
663 HG_HOOKTYPE=pretxnclose
663 HG_HOOKTYPE=pretxnclose
664 HG_PENDING=$TESTTMP/a
664 HG_PENDING=$TESTTMP/a
665 HG_TXNID=TXN:$ID$
665 HG_TXNID=TXN:$ID$
666 HG_TXNNAME=bookmark
666 HG_TXNNAME=bookmark
667
667
668 txnclose hook: HG_BOOKMARK_MOVED=1
668 txnclose hook: HG_BOOKMARK_MOVED=1
669 HG_HOOKNAME=txnclose
669 HG_HOOKNAME=txnclose
670 HG_HOOKTYPE=txnclose
670 HG_HOOKTYPE=txnclose
671 HG_TXNID=TXN:$ID$
671 HG_TXNID=TXN:$ID$
672 HG_TXNNAME=bookmark
672 HG_TXNNAME=bookmark
673
673
674 $ cd ../b
674 $ cd ../b
675 $ hg pull -B quux ../a
675 $ hg pull -B quux ../a
676 pulling from ../a
676 pulling from ../a
677 prelistkeys.forbid hook: HG_HOOKNAME=prelistkeys
677 prelistkeys.forbid hook: HG_HOOKNAME=prelistkeys
678 HG_HOOKTYPE=prelistkeys
678 HG_HOOKTYPE=prelistkeys
679 HG_NAMESPACE=bookmarks
679 HG_NAMESPACE=bookmarks
680
680
681 abort: prelistkeys hook exited with status 1
681 abort: prelistkeys hook exited with status 1
682 [255]
682 [255]
683 $ cd ../a
683 $ cd ../a
684 $ rm .hg/hgrc
684 $ rm .hg/hgrc
685
685
686 prechangegroup hook can prevent incoming changes
686 prechangegroup hook can prevent incoming changes
687
687
688 $ cd ../b
688 $ cd ../b
689 $ hg -q tip
689 $ hg -q tip
690 3:07f3376c1e65
690 3:07f3376c1e65
691 $ cat > .hg/hgrc <<EOF
691 $ cat > .hg/hgrc <<EOF
692 > [hooks]
692 > [hooks]
693 > prechangegroup.forbid = sh -c "printenv.py --line prechangegroup.forbid 1"
693 > prechangegroup.forbid = sh -c "printenv.py --line prechangegroup.forbid 1"
694 > EOF
694 > EOF
695 $ hg pull ../a
695 $ hg pull ../a
696 pulling from ../a
696 pulling from ../a
697 searching for changes
697 searching for changes
698 prechangegroup.forbid hook: HG_HOOKNAME=prechangegroup.forbid
698 prechangegroup.forbid hook: HG_HOOKNAME=prechangegroup.forbid
699 HG_HOOKTYPE=prechangegroup
699 HG_HOOKTYPE=prechangegroup
700 HG_SOURCE=pull
700 HG_SOURCE=pull
701 HG_TXNID=TXN:$ID$
701 HG_TXNID=TXN:$ID$
702 HG_TXNNAME=pull
702 HG_TXNNAME=pull
703 file:/*/$TESTTMP/a (glob)
703 file:/*/$TESTTMP/a (glob)
704 HG_URL=file:$TESTTMP/a
704 HG_URL=file:$TESTTMP/a
705
705
706 abort: prechangegroup.forbid hook exited with status 1
706 abort: prechangegroup.forbid hook exited with status 1
707 [255]
707 [255]
708
708
709 pretxnchangegroup hook can see incoming changes, can roll back txn,
709 pretxnchangegroup hook can see incoming changes, can roll back txn,
710 incoming changes no longer there after
710 incoming changes no longer there after
711
711
712 $ cat > .hg/hgrc <<EOF
712 $ cat > .hg/hgrc <<EOF
713 > [hooks]
713 > [hooks]
714 > pretxnchangegroup.forbid0 = hg tip -q
714 > pretxnchangegroup.forbid0 = hg tip -q
715 > pretxnchangegroup.forbid1 = sh -c "printenv.py --line pretxnchangegroup.forbid 1"
715 > pretxnchangegroup.forbid1 = sh -c "printenv.py --line pretxnchangegroup.forbid 1"
716 > EOF
716 > EOF
717 $ hg pull ../a
717 $ hg pull ../a
718 pulling from ../a
718 pulling from ../a
719 searching for changes
719 searching for changes
720 adding changesets
720 adding changesets
721 adding manifests
721 adding manifests
722 adding file changes
722 adding file changes
723 4:539e4b31b6dc
723 4:539e4b31b6dc
724 pretxnchangegroup.forbid hook: HG_HOOKNAME=pretxnchangegroup.forbid1
724 pretxnchangegroup.forbid hook: HG_HOOKNAME=pretxnchangegroup.forbid1
725 HG_HOOKTYPE=pretxnchangegroup
725 HG_HOOKTYPE=pretxnchangegroup
726 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
726 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
727 HG_NODE_LAST=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
727 HG_NODE_LAST=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
728 HG_PENDING=$TESTTMP/b
728 HG_PENDING=$TESTTMP/b
729 HG_SOURCE=pull
729 HG_SOURCE=pull
730 HG_TXNID=TXN:$ID$
730 HG_TXNID=TXN:$ID$
731 HG_TXNNAME=pull
731 HG_TXNNAME=pull
732 file:/*/$TESTTMP/a (glob)
732 file:/*/$TESTTMP/a (glob)
733 HG_URL=file:$TESTTMP/a
733 HG_URL=file:$TESTTMP/a
734
734
735 transaction abort!
735 transaction abort!
736 rollback completed
736 rollback completed
737 abort: pretxnchangegroup.forbid1 hook exited with status 1
737 abort: pretxnchangegroup.forbid1 hook exited with status 1
738 [255]
738 [255]
739 $ hg -q tip
739 $ hg -q tip
740 3:07f3376c1e65
740 3:07f3376c1e65
741
741
742 outgoing hooks can see env vars
742 outgoing hooks can see env vars
743
743
744 $ rm .hg/hgrc
744 $ rm .hg/hgrc
745 $ cat > ../a/.hg/hgrc <<EOF
745 $ cat > ../a/.hg/hgrc <<EOF
746 > [hooks]
746 > [hooks]
747 > preoutgoing = sh -c "printenv.py --line preoutgoing"
747 > preoutgoing = sh -c "printenv.py --line preoutgoing"
748 > outgoing = sh -c "printenv.py --line outgoing"
748 > outgoing = sh -c "printenv.py --line outgoing"
749 > EOF
749 > EOF
750 $ hg pull ../a
750 $ hg pull ../a
751 pulling from ../a
751 pulling from ../a
752 searching for changes
752 searching for changes
753 preoutgoing hook: HG_HOOKNAME=preoutgoing
753 preoutgoing hook: HG_HOOKNAME=preoutgoing
754 HG_HOOKTYPE=preoutgoing
754 HG_HOOKTYPE=preoutgoing
755 HG_SOURCE=pull
755 HG_SOURCE=pull
756
756
757 outgoing hook: HG_HOOKNAME=outgoing
757 outgoing hook: HG_HOOKNAME=outgoing
758 HG_HOOKTYPE=outgoing
758 HG_HOOKTYPE=outgoing
759 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
759 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
760 HG_SOURCE=pull
760 HG_SOURCE=pull
761
761
762 adding changesets
762 adding changesets
763 adding manifests
763 adding manifests
764 adding file changes
764 adding file changes
765 adding remote bookmark quux
765 adding remote bookmark quux
766 added 1 changesets with 1 changes to 1 files
766 added 1 changesets with 1 changes to 1 files
767 new changesets 539e4b31b6dc
767 new changesets 539e4b31b6dc
768 (run 'hg update' to get a working copy)
768 (run 'hg update' to get a working copy)
769 $ hg rollback
769 $ hg rollback
770 repository tip rolled back to revision 3 (undo pull)
770 repository tip rolled back to revision 3 (undo pull)
771
771
772 preoutgoing hook can prevent outgoing changes
772 preoutgoing hook can prevent outgoing changes
773
773
774 $ cat >> ../a/.hg/hgrc <<EOF
774 $ cat >> ../a/.hg/hgrc <<EOF
775 > preoutgoing.forbid = sh -c "printenv.py --line preoutgoing.forbid 1"
775 > preoutgoing.forbid = sh -c "printenv.py --line preoutgoing.forbid 1"
776 > EOF
776 > EOF
777 $ hg pull ../a
777 $ hg pull ../a
778 pulling from ../a
778 pulling from ../a
779 searching for changes
779 searching for changes
780 preoutgoing hook: HG_HOOKNAME=preoutgoing
780 preoutgoing hook: HG_HOOKNAME=preoutgoing
781 HG_HOOKTYPE=preoutgoing
781 HG_HOOKTYPE=preoutgoing
782 HG_SOURCE=pull
782 HG_SOURCE=pull
783
783
784 preoutgoing.forbid hook: HG_HOOKNAME=preoutgoing.forbid
784 preoutgoing.forbid hook: HG_HOOKNAME=preoutgoing.forbid
785 HG_HOOKTYPE=preoutgoing
785 HG_HOOKTYPE=preoutgoing
786 HG_SOURCE=pull
786 HG_SOURCE=pull
787
787
788 abort: preoutgoing.forbid hook exited with status 1
788 abort: preoutgoing.forbid hook exited with status 1
789 [255]
789 [255]
790
790
791 outgoing hooks work for local clones
791 outgoing hooks work for local clones
792
792
793 $ cd ..
793 $ cd ..
794 $ cat > a/.hg/hgrc <<EOF
794 $ cat > a/.hg/hgrc <<EOF
795 > [hooks]
795 > [hooks]
796 > preoutgoing = sh -c "printenv.py --line preoutgoing"
796 > preoutgoing = sh -c "printenv.py --line preoutgoing"
797 > outgoing = sh -c "printenv.py --line outgoing"
797 > outgoing = sh -c "printenv.py --line outgoing"
798 > EOF
798 > EOF
799 $ hg clone a c
799 $ hg clone a c
800 preoutgoing hook: HG_HOOKNAME=preoutgoing
800 preoutgoing hook: HG_HOOKNAME=preoutgoing
801 HG_HOOKTYPE=preoutgoing
801 HG_HOOKTYPE=preoutgoing
802 HG_SOURCE=clone
802 HG_SOURCE=clone
803
803
804 outgoing hook: HG_HOOKNAME=outgoing
804 outgoing hook: HG_HOOKNAME=outgoing
805 HG_HOOKTYPE=outgoing
805 HG_HOOKTYPE=outgoing
806 HG_NODE=0000000000000000000000000000000000000000
806 HG_NODE=0000000000000000000000000000000000000000
807 HG_SOURCE=clone
807 HG_SOURCE=clone
808
808
809 updating to branch default
809 updating to branch default
810 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
810 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
811 $ rm -rf c
811 $ rm -rf c
812
812
813 preoutgoing hook can prevent outgoing changes for local clones
813 preoutgoing hook can prevent outgoing changes for local clones
814
814
815 $ cat >> a/.hg/hgrc <<EOF
815 $ cat >> a/.hg/hgrc <<EOF
816 > preoutgoing.forbid = sh -c "printenv.py --line preoutgoing.forbid 1"
816 > preoutgoing.forbid = sh -c "printenv.py --line preoutgoing.forbid 1"
817 > EOF
817 > EOF
818 $ hg clone a zzz
818 $ hg clone a zzz
819 preoutgoing hook: HG_HOOKNAME=preoutgoing
819 preoutgoing hook: HG_HOOKNAME=preoutgoing
820 HG_HOOKTYPE=preoutgoing
820 HG_HOOKTYPE=preoutgoing
821 HG_SOURCE=clone
821 HG_SOURCE=clone
822
822
823 preoutgoing.forbid hook: HG_HOOKNAME=preoutgoing.forbid
823 preoutgoing.forbid hook: HG_HOOKNAME=preoutgoing.forbid
824 HG_HOOKTYPE=preoutgoing
824 HG_HOOKTYPE=preoutgoing
825 HG_SOURCE=clone
825 HG_SOURCE=clone
826
826
827 abort: preoutgoing.forbid hook exited with status 1
827 abort: preoutgoing.forbid hook exited with status 1
828 [255]
828 [255]
829
829
830 $ cd "$TESTTMP/b"
830 $ cd "$TESTTMP/b"
831
831
832 $ cat > hooktests.py <<EOF
832 $ cat > hooktests.py <<EOF
833 > from __future__ import print_function
833 > from __future__ import print_function
834 > from mercurial import (
834 > from mercurial import (
835 > error,
835 > error,
836 > pycompat,
836 > pycompat,
837 > )
837 > )
838 >
838 >
839 > uncallable = 0
839 > uncallable = 0
840 >
840 >
841 > def printargs(ui, args):
841 > def printargs(ui, args):
842 > a = list(pycompat.byteskwargs(args).items())
842 > a = list(pycompat.byteskwargs(args).items())
843 > a.sort()
843 > a.sort()
844 > ui.write(b'hook args:\n')
844 > ui.write(b'hook args:\n')
845 > for k, v in a:
845 > for k, v in a:
846 > ui.write(b' %s %s\n' % (k, v))
846 > ui.write(b' %s %s\n' % (k, v))
847 >
847 >
848 > def passhook(ui, repo, **args):
848 > def passhook(ui, repo, **args):
849 > printargs(ui, args)
849 > printargs(ui, args)
850 >
850 >
851 > def failhook(ui, repo, **args):
851 > def failhook(ui, repo, **args):
852 > printargs(ui, args)
852 > printargs(ui, args)
853 > return True
853 > return True
854 >
854 >
855 > class LocalException(Exception):
855 > class LocalException(Exception):
856 > pass
856 > pass
857 >
857 >
858 > def raisehook(**args):
858 > def raisehook(**args):
859 > raise LocalException('exception from hook')
859 > raise LocalException('exception from hook')
860 >
860 >
861 > def aborthook(**args):
861 > def aborthook(**args):
862 > raise error.Abort(b'raise abort from hook')
862 > raise error.Abort(b'raise abort from hook')
863 >
863 >
864 > def brokenhook(**args):
864 > def brokenhook(**args):
865 > return 1 + {}
865 > return 1 + {}
866 >
866 >
867 > def verbosehook(ui, **args):
867 > def verbosehook(ui, **args):
868 > ui.note(b'verbose output from hook\n')
868 > ui.note(b'verbose output from hook\n')
869 >
869 >
870 > def printtags(ui, repo, **args):
870 > def printtags(ui, repo, **args):
871 > ui.write(b'[%s]\n' % b', '.join(sorted(repo.tags())))
871 > ui.write(b'[%s]\n' % b', '.join(sorted(repo.tags())))
872 >
872 >
873 > class container(object):
873 > class container(object):
874 > unreachable = 1
874 > unreachable = 1
875 > EOF
875 > EOF
876
876
877 $ cat > syntaxerror.py << NO_CHECK_EOF
877 $ cat > syntaxerror.py << NO_CHECK_EOF
878 > (foo
878 > (foo
879 > NO_CHECK_EOF
879 > NO_CHECK_EOF
880
880
881 test python hooks
881 test python hooks
882
882
883 #if windows
883 #if windows
884 $ PYTHONPATH="$TESTTMP/b;$PYTHONPATH"
884 $ PYTHONPATH="$TESTTMP/b;$PYTHONPATH"
885 #else
885 #else
886 $ PYTHONPATH="$TESTTMP/b:$PYTHONPATH"
886 $ PYTHONPATH="$TESTTMP/b:$PYTHONPATH"
887 #endif
887 #endif
888 $ export PYTHONPATH
888 $ export PYTHONPATH
889
889
890 $ echo '[hooks]' > ../a/.hg/hgrc
890 $ echo '[hooks]' > ../a/.hg/hgrc
891 $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
891 $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
892 $ hg pull ../a 2>&1 | grep 'raised an exception'
892 $ hg pull ../a 2>&1 | grep 'raised an exception'
893 error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
893 error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
894
894
895 $ echo '[hooks]' > ../a/.hg/hgrc
895 $ echo '[hooks]' > ../a/.hg/hgrc
896 $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
896 $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
897 $ hg pull ../a 2>&1 | grep 'raised an exception'
897 $ hg pull ../a 2>&1 | grep 'raised an exception'
898 error: preoutgoing.raise hook raised an exception: exception from hook
898 error: preoutgoing.raise hook raised an exception: exception from hook
899
899
900 $ echo '[hooks]' > ../a/.hg/hgrc
900 $ echo '[hooks]' > ../a/.hg/hgrc
901 $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
901 $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
902 $ hg pull ../a
902 $ hg pull ../a
903 pulling from ../a
903 pulling from ../a
904 searching for changes
904 searching for changes
905 error: preoutgoing.abort hook failed: raise abort from hook
905 error: preoutgoing.abort hook failed: raise abort from hook
906 abort: raise abort from hook
906 abort: raise abort from hook
907 [255]
907 [255]
908
908
909 $ echo '[hooks]' > ../a/.hg/hgrc
909 $ echo '[hooks]' > ../a/.hg/hgrc
910 $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
910 $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
911 $ hg pull ../a
911 $ hg pull ../a
912 pulling from ../a
912 pulling from ../a
913 searching for changes
913 searching for changes
914 hook args:
914 hook args:
915 hooktype preoutgoing
915 hooktype preoutgoing
916 source pull
916 source pull
917 abort: preoutgoing.fail hook failed
917 abort: preoutgoing.fail hook failed
918 [255]
918 [255]
919
919
920 $ echo '[hooks]' > ../a/.hg/hgrc
920 $ echo '[hooks]' > ../a/.hg/hgrc
921 $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
921 $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
922 $ hg pull ../a
922 $ hg pull ../a
923 pulling from ../a
923 pulling from ../a
924 searching for changes
924 searching for changes
925 abort: preoutgoing.uncallable hook is invalid: "hooktests.uncallable" is not callable
925 abort: preoutgoing.uncallable hook is invalid: "hooktests.uncallable" is not callable
926 [255]
926 [255]
927
927
928 $ echo '[hooks]' > ../a/.hg/hgrc
928 $ echo '[hooks]' > ../a/.hg/hgrc
929 $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
929 $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
930 $ hg pull ../a
930 $ hg pull ../a
931 pulling from ../a
931 pulling from ../a
932 searching for changes
932 searching for changes
933 abort: preoutgoing.nohook hook is invalid: "hooktests.nohook" is not defined
933 abort: preoutgoing.nohook hook is invalid: "hooktests.nohook" is not defined
934 [255]
934 [255]
935
935
936 $ echo '[hooks]' > ../a/.hg/hgrc
936 $ echo '[hooks]' > ../a/.hg/hgrc
937 $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
937 $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
938 $ hg pull ../a
938 $ hg pull ../a
939 pulling from ../a
939 pulling from ../a
940 searching for changes
940 searching for changes
941 abort: preoutgoing.nomodule hook is invalid: "nomodule" not in a module
941 abort: preoutgoing.nomodule hook is invalid: "nomodule" not in a module
942 [255]
942 [255]
943
943
944 $ echo '[hooks]' > ../a/.hg/hgrc
944 $ echo '[hooks]' > ../a/.hg/hgrc
945 $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
945 $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
946 $ hg pull ../a
946 $ hg pull ../a
947 pulling from ../a
947 pulling from ../a
948 searching for changes
948 searching for changes
949 abort: preoutgoing.badmodule hook is invalid: import of "nomodule" failed
949 abort: preoutgoing.badmodule hook is invalid: import of "nomodule" failed
950 (run with --traceback for stack trace)
950 (run with --traceback for stack trace)
951 [255]
951 [255]
952
952
953 $ echo '[hooks]' > ../a/.hg/hgrc
953 $ echo '[hooks]' > ../a/.hg/hgrc
954 $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
954 $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
955 $ hg pull ../a
955 $ hg pull ../a
956 pulling from ../a
956 pulling from ../a
957 searching for changes
957 searching for changes
958 abort: preoutgoing.unreachable hook is invalid: import of "hooktests.container" failed
958 abort: preoutgoing.unreachable hook is invalid: import of "hooktests.container" failed
959 (run with --traceback for stack trace)
959 (run with --traceback for stack trace)
960 [255]
960 [255]
961
961
962 $ echo '[hooks]' > ../a/.hg/hgrc
962 $ echo '[hooks]' > ../a/.hg/hgrc
963 $ echo 'preoutgoing.syntaxerror = python:syntaxerror.syntaxerror' >> ../a/.hg/hgrc
963 $ echo 'preoutgoing.syntaxerror = python:syntaxerror.syntaxerror' >> ../a/.hg/hgrc
964 $ hg pull ../a
964 $ hg pull ../a
965 pulling from ../a
965 pulling from ../a
966 searching for changes
966 searching for changes
967 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
967 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
968 (run with --traceback for stack trace)
968 (run with --traceback for stack trace)
969 [255]
969 [255]
970
970
971 $ hg pull ../a --traceback 2>&1 | egrep 'pulling|searching|^exception|Traceback|SyntaxError|ImportError|ModuleNotFoundError|HookLoadError|abort'
971 $ hg pull ../a --traceback 2>&1 | egrep 'pulling|searching|^exception|Traceback|SyntaxError|ImportError|ModuleNotFoundError|HookLoadError|abort'
972 pulling from ../a
972 pulling from ../a
973 searching for changes
973 searching for changes
974 exception from first failed import attempt:
974 exception from first failed import attempt:
975 Traceback (most recent call last):
975 Traceback (most recent call last):
976 SyntaxError: * (glob)
976 SyntaxError: * (glob)
977 exception from second failed import attempt:
977 exception from second failed import attempt:
978 Traceback (most recent call last): (py3 !)
978 Traceback (most recent call last): (py3 !)
979 SyntaxError: * (glob) (py3 !)
979 SyntaxError: * (glob) (py3 !)
980 Traceback (most recent call last):
980 Traceback (most recent call last):
981 ImportError: No module named hgext_syntaxerror (no-py3 !)
981 ImportError: No module named hgext_syntaxerror (no-py3 !)
982 ImportError: No module named 'hgext_syntaxerror' (py3 no-py36 !)
982 ImportError: No module named 'hgext_syntaxerror' (py3 no-py36 !)
983 ModuleNotFoundError: No module named 'hgext_syntaxerror' (py36 !)
983 ModuleNotFoundError: No module named 'hgext_syntaxerror' (py36 !)
984 Traceback (most recent call last):
984 Traceback (most recent call last):
985 SyntaxError: * (glob) (py3 !)
985 SyntaxError: * (glob) (py3 !)
986 Traceback (most recent call last): (py3 !)
986 Traceback (most recent call last): (py3 !)
987 ImportError: No module named 'hgext_syntaxerror' (py3 no-py36 !)
987 ImportError: No module named 'hgext_syntaxerror' (py3 no-py36 !)
988 ModuleNotFoundError: No module named 'hgext_syntaxerror' (py36 !)
988 ModuleNotFoundError: No module named 'hgext_syntaxerror' (py36 !)
989 Traceback (most recent call last): (py3 !)
989 Traceback (most recent call last): (py3 !)
990 HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed (no-py3 !)
990 HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed (no-py3 !)
991 raise error.HookLoadError( (py38 !)
991 raise error.HookLoadError( (py38 !)
992 mercurial.error.HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed (py3 !)
992 mercurial.error.HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed (py3 !)
993 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
993 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
994
994
995 $ echo '[hooks]' > ../a/.hg/hgrc
995 $ echo '[hooks]' > ../a/.hg/hgrc
996 $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
996 $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
997 $ hg pull ../a
997 $ hg pull ../a
998 pulling from ../a
998 pulling from ../a
999 searching for changes
999 searching for changes
1000 hook args:
1000 hook args:
1001 hooktype preoutgoing
1001 hooktype preoutgoing
1002 source pull
1002 source pull
1003 adding changesets
1003 adding changesets
1004 adding manifests
1004 adding manifests
1005 adding file changes
1005 adding file changes
1006 adding remote bookmark quux
1006 adding remote bookmark quux
1007 added 1 changesets with 1 changes to 1 files
1007 added 1 changesets with 1 changes to 1 files
1008 new changesets 539e4b31b6dc
1008 new changesets 539e4b31b6dc
1009 (run 'hg update' to get a working copy)
1009 (run 'hg update' to get a working copy)
1010
1010
1011 post- python hooks that fail to *run* don't cause an abort
1011 post- python hooks that fail to *run* don't cause an abort
1012 $ rm ../a/.hg/hgrc
1012 $ rm ../a/.hg/hgrc
1013 $ echo '[hooks]' > .hg/hgrc
1013 $ echo '[hooks]' > .hg/hgrc
1014 $ echo 'post-pull.broken = python:hooktests.brokenhook' >> .hg/hgrc
1014 $ echo 'post-pull.broken = python:hooktests.brokenhook' >> .hg/hgrc
1015 $ hg pull ../a
1015 $ hg pull ../a
1016 pulling from ../a
1016 pulling from ../a
1017 searching for changes
1017 searching for changes
1018 no changes found
1018 no changes found
1019 error: post-pull.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
1019 error: post-pull.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
1020 (run with --traceback for stack trace)
1020 (run with --traceback for stack trace)
1021
1021
1022 but post- python hooks that fail to *load* do
1022 but post- python hooks that fail to *load* do
1023 $ echo '[hooks]' > .hg/hgrc
1023 $ echo '[hooks]' > .hg/hgrc
1024 $ echo 'post-pull.nomodule = python:nomodule' >> .hg/hgrc
1024 $ echo 'post-pull.nomodule = python:nomodule' >> .hg/hgrc
1025 $ hg pull ../a
1025 $ hg pull ../a
1026 pulling from ../a
1026 pulling from ../a
1027 searching for changes
1027 searching for changes
1028 no changes found
1028 no changes found
1029 abort: post-pull.nomodule hook is invalid: "nomodule" not in a module
1029 abort: post-pull.nomodule hook is invalid: "nomodule" not in a module
1030 [255]
1030 [255]
1031
1031
1032 $ echo '[hooks]' > .hg/hgrc
1032 $ echo '[hooks]' > .hg/hgrc
1033 $ echo 'post-pull.badmodule = python:nomodule.nowhere' >> .hg/hgrc
1033 $ echo 'post-pull.badmodule = python:nomodule.nowhere' >> .hg/hgrc
1034 $ hg pull ../a
1034 $ hg pull ../a
1035 pulling from ../a
1035 pulling from ../a
1036 searching for changes
1036 searching for changes
1037 no changes found
1037 no changes found
1038 abort: post-pull.badmodule hook is invalid: import of "nomodule" failed
1038 abort: post-pull.badmodule hook is invalid: import of "nomodule" failed
1039 (run with --traceback for stack trace)
1039 (run with --traceback for stack trace)
1040 [255]
1040 [255]
1041
1041
1042 $ echo '[hooks]' > .hg/hgrc
1042 $ echo '[hooks]' > .hg/hgrc
1043 $ echo 'post-pull.nohook = python:hooktests.nohook' >> .hg/hgrc
1043 $ echo 'post-pull.nohook = python:hooktests.nohook' >> .hg/hgrc
1044 $ hg pull ../a
1044 $ hg pull ../a
1045 pulling from ../a
1045 pulling from ../a
1046 searching for changes
1046 searching for changes
1047 no changes found
1047 no changes found
1048 abort: post-pull.nohook hook is invalid: "hooktests.nohook" is not defined
1048 abort: post-pull.nohook hook is invalid: "hooktests.nohook" is not defined
1049 [255]
1049 [255]
1050
1050
1051 make sure --traceback works
1051 make sure --traceback works
1052
1052
1053 $ echo '[hooks]' > .hg/hgrc
1053 $ echo '[hooks]' > .hg/hgrc
1054 $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
1054 $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
1055
1055
1056 $ echo aa > a
1056 $ echo aa > a
1057 $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback'
1057 $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback'
1058 Traceback (most recent call last):
1058 Traceback (most recent call last):
1059
1059
1060 $ cd ..
1060 $ cd ..
1061 $ hg init c
1061 $ hg init c
1062 $ cd c
1062 $ cd c
1063
1063
1064 $ cat > hookext.py <<EOF
1064 $ cat > hookext.py <<EOF
1065 > def autohook(ui, **args):
1065 > def autohook(ui, **args):
1066 > ui.write(b'Automatically installed hook\n')
1066 > ui.write(b'Automatically installed hook\n')
1067 >
1067 >
1068 > def reposetup(ui, repo):
1068 > def reposetup(ui, repo):
1069 > repo.ui.setconfig(b"hooks", b"commit.auto", autohook)
1069 > repo.ui.setconfig(b"hooks", b"commit.auto", autohook)
1070 > EOF
1070 > EOF
1071 $ echo '[extensions]' >> .hg/hgrc
1071 $ echo '[extensions]' >> .hg/hgrc
1072 $ echo 'hookext = hookext.py' >> .hg/hgrc
1072 $ echo 'hookext = hookext.py' >> .hg/hgrc
1073
1073
1074 $ touch foo
1074 $ touch foo
1075 $ hg add foo
1075 $ hg add foo
1076 $ hg ci -d '0 0' -m 'add foo'
1076 $ hg ci -d '0 0' -m 'add foo'
1077 Automatically installed hook
1077 Automatically installed hook
1078 $ echo >> foo
1078 $ echo >> foo
1079 $ hg ci --debug -d '0 0' -m 'change foo'
1079 $ hg ci --debug -d '0 0' -m 'change foo'
1080 committing files:
1080 committing files:
1081 foo
1081 foo
1082 committing manifest
1082 committing manifest
1083 committing changelog
1083 committing changelog
1084 updating the branch cache
1084 updating the branch cache
1085 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
1085 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
1086 calling hook commit.auto: hgext_hookext.autohook
1086 calling hook commit.auto: hgext_hookext.autohook
1087 Automatically installed hook
1087 Automatically installed hook
1088
1088
1089 $ hg showconfig hooks
1089 $ hg showconfig hooks
1090 hooks.commit.auto=<function autohook at *> (glob)
1090 hooks.commit.auto=<function autohook at *> (glob)
1091
1091
1092 test python hook configured with python:[file]:[hook] syntax
1092 test python hook configured with python:[file]:[hook] syntax
1093
1093
1094 $ cd ..
1094 $ cd ..
1095 $ mkdir d
1095 $ mkdir d
1096 $ cd d
1096 $ cd d
1097 $ hg init repo
1097 $ hg init repo
1098 $ mkdir hooks
1098 $ mkdir hooks
1099
1099
1100 $ cd hooks
1100 $ cd hooks
1101 $ cat > testhooks.py <<EOF
1101 $ cat > testhooks.py <<EOF
1102 > def testhook(ui, **args):
1102 > def testhook(ui, **args):
1103 > ui.write(b'hook works\n')
1103 > ui.write(b'hook works\n')
1104 > EOF
1104 > EOF
1105 $ echo '[hooks]' > ../repo/.hg/hgrc
1105 $ echo '[hooks]' > ../repo/.hg/hgrc
1106 $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
1106 $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
1107
1107
1108 $ cd ../repo
1108 $ cd ../repo
1109 $ hg commit -d '0 0'
1109 $ hg commit -d '0 0'
1110 hook works
1110 hook works
1111 nothing changed
1111 nothing changed
1112 [1]
1112 [1]
1113
1113
1114 $ echo '[hooks]' > .hg/hgrc
1114 $ echo '[hooks]' > .hg/hgrc
1115 $ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc
1115 $ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc
1116 $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc
1116 $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc
1117
1117
1118 $ hg up null
1118 $ hg up null
1119 loading update.ne hook failed:
1119 loading update.ne hook failed:
1120 abort: $ENOENT$: '$TESTTMP/d/repo/nonexistent.py'
1120 abort: $ENOENT$: '$TESTTMP/d/repo/nonexistent.py'
1121 [255]
1121 [255]
1122
1122
1123 $ hg id
1123 $ hg id
1124 loading pre-identify.npmd hook failed:
1124 loading pre-identify.npmd hook failed:
1125 abort: No module named repo (no-py3 !)
1125 abort: No module named repo (no-py3 !)
1126 abort: No module named 'repo' (py3 !)
1126 abort: No module named 'repo' (py3 !)
1127 [255]
1127 [255]
1128
1128
1129 $ cd ../../b
1129 $ cd ../../b
1130
1130
1131 make sure --traceback works on hook import failure
1131 make sure --traceback works on hook import failure
1132
1132
1133 $ cat > importfail.py <<EOF
1133 $ cat > importfail.py <<EOF
1134 > import somebogusmodule
1134 > import somebogusmodule
1135 > # dereference something in the module to force demandimport to load it
1135 > # dereference something in the module to force demandimport to load it
1136 > somebogusmodule.whatever
1136 > somebogusmodule.whatever
1137 > EOF
1137 > EOF
1138
1138
1139 $ echo '[hooks]' > .hg/hgrc
1139 $ echo '[hooks]' > .hg/hgrc
1140 $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
1140 $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
1141
1141
1142 $ echo a >> a
1142 $ echo a >> a
1143 $ hg --traceback commit -ma 2>&1 | egrep '^exception|ImportError|ModuleNotFoundError|Traceback|HookLoadError|abort'
1143 $ hg --traceback commit -ma 2>&1 | egrep '^exception|ImportError|ModuleNotFoundError|Traceback|HookLoadError|abort'
1144 exception from first failed import attempt:
1144 exception from first failed import attempt:
1145 Traceback (most recent call last):
1145 Traceback (most recent call last):
1146 ImportError: No module named somebogusmodule (no-py3 !)
1146 ImportError: No module named somebogusmodule (no-py3 !)
1147 ImportError: No module named 'somebogusmodule' (py3 no-py36 !)
1147 ImportError: No module named 'somebogusmodule' (py3 no-py36 !)
1148 ModuleNotFoundError: No module named 'somebogusmodule' (py36 !)
1148 ModuleNotFoundError: No module named 'somebogusmodule' (py36 !)
1149 exception from second failed import attempt:
1149 exception from second failed import attempt:
1150 Traceback (most recent call last): (py3 !)
1150 Traceback (most recent call last): (py3 !)
1151 ImportError: No module named 'somebogusmodule' (py3 no-py36 !)
1151 ImportError: No module named 'somebogusmodule' (py3 no-py36 !)
1152 ModuleNotFoundError: No module named 'somebogusmodule' (py36 !)
1152 ModuleNotFoundError: No module named 'somebogusmodule' (py36 !)
1153 Traceback (most recent call last): (py3 !)
1153 Traceback (most recent call last): (py3 !)
1154 ImportError: No module named 'hgext_importfail' (py3 no-py36 !)
1154 ImportError: No module named 'hgext_importfail' (py3 no-py36 !)
1155 ModuleNotFoundError: No module named 'hgext_importfail' (py36 !)
1155 ModuleNotFoundError: No module named 'hgext_importfail' (py36 !)
1156 Traceback (most recent call last): (py3 !)
1156 Traceback (most recent call last): (py3 !)
1157 ImportError: No module named 'somebogusmodule' (py3 no-py36 !)
1157 ImportError: No module named 'somebogusmodule' (py3 no-py36 !)
1158 ModuleNotFoundError: No module named 'somebogusmodule' (py36 !)
1158 ModuleNotFoundError: No module named 'somebogusmodule' (py36 !)
1159 Traceback (most recent call last):
1159 Traceback (most recent call last):
1160 ImportError: No module named hgext_importfail (no-py3 !)
1160 ImportError: No module named hgext_importfail (no-py3 !)
1161 ImportError: No module named 'hgext_importfail' (py3 no-py36 !)
1161 ImportError: No module named 'hgext_importfail' (py3 no-py36 !)
1162 ModuleNotFoundError: No module named 'hgext_importfail' (py36 !)
1162 ModuleNotFoundError: No module named 'hgext_importfail' (py36 !)
1163 Traceback (most recent call last):
1163 Traceback (most recent call last):
1164 HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed (no-py3 !)
1164 HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed (no-py3 !)
1165 raise error.HookLoadError( (py38 !)
1165 raise error.HookLoadError( (py38 !)
1166 mercurial.error.HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed (py3 !)
1166 mercurial.error.HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed (py3 !)
1167 abort: precommit.importfail hook is invalid: import of "importfail" failed
1167 abort: precommit.importfail hook is invalid: import of "importfail" failed
1168
1168
1169 Issue1827: Hooks Update & Commit not completely post operation
1169 Issue1827: Hooks Update & Commit not completely post operation
1170
1170
1171 commit and update hooks should run after command completion. The largefiles
1171 commit and update hooks should run after command completion. The largefiles
1172 use demonstrates a recursive wlock, showing the hook doesn't run until the
1172 use demonstrates a recursive wlock, showing the hook doesn't run until the
1173 final release (and dirstate flush).
1173 final release (and dirstate flush).
1174
1174
1175 $ echo '[hooks]' > .hg/hgrc
1175 $ echo '[hooks]' > .hg/hgrc
1176 $ echo 'commit = hg id' >> .hg/hgrc
1176 $ echo 'commit = hg id' >> .hg/hgrc
1177 $ echo 'update = hg id' >> .hg/hgrc
1177 $ echo 'update = hg id' >> .hg/hgrc
1178 $ echo bb > a
1178 $ echo bb > a
1179 $ hg ci -ma
1179 $ hg ci -ma
1180 223eafe2750c tip
1180 223eafe2750c tip
1181 $ hg up 0 --config extensions.largefiles=
1181 $ hg up 0 --config extensions.largefiles=
1182 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
1182 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
1183 cb9a9f314b8b
1183 cb9a9f314b8b
1184 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1184 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1185
1185
1186 make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui
1186 make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui
1187 that is passed to pre/post hooks
1187 that is passed to pre/post hooks
1188
1188
1189 $ echo '[hooks]' > .hg/hgrc
1189 $ echo '[hooks]' > .hg/hgrc
1190 $ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc
1190 $ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc
1191 $ hg id
1191 $ hg id
1192 cb9a9f314b8b
1192 cb9a9f314b8b
1193 $ hg id --verbose
1193 $ hg id --verbose
1194 calling hook pre-identify: hooktests.verbosehook
1194 calling hook pre-identify: hooktests.verbosehook
1195 verbose output from hook
1195 verbose output from hook
1196 cb9a9f314b8b
1196 cb9a9f314b8b
1197
1197
1198 Ensure hooks can be prioritized
1198 Ensure hooks can be prioritized
1199
1199
1200 $ echo '[hooks]' > .hg/hgrc
1200 $ echo '[hooks]' > .hg/hgrc
1201 $ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc
1201 $ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc
1202 $ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc
1202 $ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc
1203 $ echo 'priority.pre-identify.b = 1' >> .hg/hgrc
1203 $ echo 'priority.pre-identify.b = 1' >> .hg/hgrc
1204 $ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc
1204 $ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc
1205 $ hg id --verbose
1205 $ hg id --verbose
1206 calling hook pre-identify.b: hooktests.verbosehook
1206 calling hook pre-identify.b: hooktests.verbosehook
1207 verbose output from hook
1207 verbose output from hook
1208 calling hook pre-identify.a: hooktests.verbosehook
1208 calling hook pre-identify.a: hooktests.verbosehook
1209 verbose output from hook
1209 verbose output from hook
1210 calling hook pre-identify.c: hooktests.verbosehook
1210 calling hook pre-identify.c: hooktests.verbosehook
1211 verbose output from hook
1211 verbose output from hook
1212 cb9a9f314b8b
1212 cb9a9f314b8b
1213
1213
1214 new tags must be visible in pretxncommit (issue3210)
1214 new tags must be visible in pretxncommit (issue3210)
1215
1215
1216 $ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc
1216 $ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc
1217 $ hg tag -f foo
1217 $ hg tag -f foo
1218 [a, foo, tip]
1218 [a, foo, tip]
1219
1219
1220 post-init hooks must not crash (issue4983)
1220 post-init hooks must not crash (issue4983)
1221 This also creates the `to` repo for the next test block.
1221 This also creates the `to` repo for the next test block.
1222
1222
1223 $ cd ..
1223 $ cd ..
1224 $ cat << EOF >> hgrc-with-post-init-hook
1224 $ cat << EOF >> hgrc-with-post-init-hook
1225 > [hooks]
1225 > [hooks]
1226 > post-init = sh -c "printenv.py --line post-init"
1226 > post-init = sh -c "printenv.py --line post-init"
1227 > EOF
1227 > EOF
1228 $ HGRCPATH=hgrc-with-post-init-hook hg init to
1228 $ HGRCPATH=hgrc-with-post-init-hook hg init to
1229 post-init hook: HG_ARGS=init to
1229 post-init hook: HG_ARGS=init to
1230 HG_HOOKNAME=post-init
1230 HG_HOOKNAME=post-init
1231 HG_HOOKTYPE=post-init
1231 HG_HOOKTYPE=post-init
1232 HG_OPTS={'insecure': None, 'remotecmd': '', 'ssh': ''}
1232 HG_OPTS={'insecure': None, 'remotecmd': '', 'ssh': ''}
1233 HG_PATS=['to']
1233 HG_PATS=['to']
1234 HG_RESULT=0
1234 HG_RESULT=0
1235
1235
1236
1236
1237 new commits must be visible in pretxnchangegroup (issue3428)
1237 new commits must be visible in pretxnchangegroup (issue3428)
1238
1238
1239 $ echo '[hooks]' >> to/.hg/hgrc
1239 $ echo '[hooks]' >> to/.hg/hgrc
1240 $ echo 'prechangegroup = hg --traceback tip' >> to/.hg/hgrc
1240 $ echo 'prechangegroup = hg --traceback tip' >> to/.hg/hgrc
1241 $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc
1241 $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc
1242 $ echo a >> to/a
1242 $ echo a >> to/a
1243 $ hg --cwd to ci -Ama
1243 $ hg --cwd to ci -Ama
1244 adding a
1244 adding a
1245 $ hg clone to from
1245 $ hg clone to from
1246 updating to branch default
1246 updating to branch default
1247 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1247 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1248 $ echo aa >> from/a
1248 $ echo aa >> from/a
1249 $ hg --cwd from ci -mb
1249 $ hg --cwd from ci -mb
1250 $ hg --cwd from push
1250 $ hg --cwd from push
1251 pushing to $TESTTMP/to
1251 pushing to $TESTTMP/to
1252 searching for changes
1252 searching for changes
1253 changeset: 0:cb9a9f314b8b
1253 changeset: 0:cb9a9f314b8b
1254 tag: tip
1254 tag: tip
1255 user: test
1255 user: test
1256 date: Thu Jan 01 00:00:00 1970 +0000
1256 date: Thu Jan 01 00:00:00 1970 +0000
1257 summary: a
1257 summary: a
1258
1258
1259 adding changesets
1259 adding changesets
1260 adding manifests
1260 adding manifests
1261 adding file changes
1261 adding file changes
1262 changeset: 1:9836a07b9b9d
1262 changeset: 1:9836a07b9b9d
1263 tag: tip
1263 tag: tip
1264 user: test
1264 user: test
1265 date: Thu Jan 01 00:00:00 1970 +0000
1265 date: Thu Jan 01 00:00:00 1970 +0000
1266 summary: b
1266 summary: b
1267
1267
1268 added 1 changesets with 1 changes to 1 files
1268 added 1 changesets with 1 changes to 1 files
1269
1269
1270 pretxnclose hook failure should abort the transaction
1270 pretxnclose hook failure should abort the transaction
1271
1271
1272 $ hg init txnfailure
1272 $ hg init txnfailure
1273 $ cd txnfailure
1273 $ cd txnfailure
1274 $ touch a && hg commit -Aqm a
1274 $ touch a && hg commit -Aqm a
1275 $ cat >> .hg/hgrc <<EOF
1275 $ cat >> .hg/hgrc <<EOF
1276 > [hooks]
1276 > [hooks]
1277 > pretxnclose.error = exit 1
1277 > pretxnclose.error = exit 1
1278 > EOF
1278 > EOF
1279 $ hg strip -r 0 --config extensions.strip=
1279 $ hg strip -r 0 --config extensions.strip=
1280 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1280 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1281 saved backup bundle to * (glob)
1281 saved backup bundle to * (glob)
1282 transaction abort!
1282 transaction abort!
1283 rollback completed
1283 rollback completed
1284 strip failed, backup bundle stored in * (glob)
1284 strip failed, backup bundle stored in * (glob)
1285 abort: pretxnclose.error hook exited with status 1
1285 abort: pretxnclose.error hook exited with status 1
1286 [255]
1286 [255]
1287 $ hg recover
1287 $ hg recover
1288 no interrupted transaction available
1288 no interrupted transaction available
1289 [1]
1289 [1]
1290 $ cd ..
1290 $ cd ..
1291
1291
1292 check whether HG_PENDING makes pending changes only in related
1292 check whether HG_PENDING makes pending changes only in related
1293 repositories visible to an external hook.
1293 repositories visible to an external hook.
1294
1294
1295 (emulate a transaction running concurrently by copied
1295 (emulate a transaction running concurrently by copied
1296 .hg/store/00changelog.i.a in subsequent test)
1296 .hg/store/00changelog.i.a in subsequent test)
1297
1297
1298 $ cat > $TESTTMP/savepending.sh <<EOF
1298 $ cat > $TESTTMP/savepending.sh <<EOF
1299 > cp .hg/store/00changelog.i.a .hg/store/00changelog.i.a.saved
1299 > cp .hg/store/00changelog.i.a .hg/store/00changelog.i.a.saved
1300 > exit 1 # to avoid adding new revision for subsequent tests
1300 > exit 1 # to avoid adding new revision for subsequent tests
1301 > EOF
1301 > EOF
1302 $ cd a
1302 $ cd a
1303 $ hg tip -q
1303 $ hg tip -q
1304 4:539e4b31b6dc
1304 4:539e4b31b6dc
1305 $ hg --config hooks.pretxnclose="sh $TESTTMP/savepending.sh" commit -m "invisible"
1305 $ hg --config hooks.pretxnclose="sh $TESTTMP/savepending.sh" commit -m "invisible"
1306 transaction abort!
1306 transaction abort!
1307 rollback completed
1307 rollback completed
1308 abort: pretxnclose hook exited with status 1
1308 abort: pretxnclose hook exited with status 1
1309 [255]
1309 [255]
1310 $ cp .hg/store/00changelog.i.a.saved .hg/store/00changelog.i.a
1310 $ cp .hg/store/00changelog.i.a.saved .hg/store/00changelog.i.a
1311
1311
1312 (check (in)visibility of new changeset while transaction running in
1312 (check (in)visibility of new changeset while transaction running in
1313 repo)
1313 repo)
1314
1314
1315 $ cat > $TESTTMP/checkpending.sh <<EOF
1315 $ cat > $TESTTMP/checkpending.sh <<EOF
1316 > echo '@a'
1316 > echo '@a'
1317 > hg -R "$TESTTMP/a" tip -q
1317 > hg -R "$TESTTMP/a" tip -q
1318 > echo '@a/nested'
1318 > echo '@a/nested'
1319 > hg -R "$TESTTMP/a/nested" tip -q
1319 > hg -R "$TESTTMP/a/nested" tip -q
1320 > exit 1 # to avoid adding new revision for subsequent tests
1320 > exit 1 # to avoid adding new revision for subsequent tests
1321 > EOF
1321 > EOF
1322 $ hg init nested
1322 $ hg init nested
1323 $ cd nested
1323 $ cd nested
1324 $ echo a > a
1324 $ echo a > a
1325 $ hg add a
1325 $ hg add a
1326 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkpending.sh" commit -m '#0'
1326 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkpending.sh" commit -m '#0'
1327 @a
1327 @a
1328 4:539e4b31b6dc
1328 4:539e4b31b6dc
1329 @a/nested
1329 @a/nested
1330 0:bf5e395ced2c
1330 0:bf5e395ced2c
1331 transaction abort!
1331 transaction abort!
1332 rollback completed
1332 rollback completed
1333 abort: pretxnclose hook exited with status 1
1333 abort: pretxnclose hook exited with status 1
1334 [255]
1334 [255]
1335
1335
1336 Hook from untrusted hgrc are reported as failure
1336 Hook from untrusted hgrc are reported as failure
1337 ================================================
1337 ================================================
1338
1338
1339 $ cat << EOF > $TESTTMP/untrusted.py
1339 $ cat << EOF > $TESTTMP/untrusted.py
1340 > from mercurial import scmutil, util
1340 > from mercurial import scmutil, util
1341 > def uisetup(ui):
1341 > def uisetup(ui):
1342 > class untrustedui(ui.__class__):
1342 > class untrustedui(ui.__class__):
1343 > def _trusted(self, fp, f):
1343 > def _trusted(self, fp, f):
1344 > if util.normpath(fp.name).endswith(b'untrusted/.hg/hgrc'):
1344 > if util.normpath(fp.name).endswith(b'untrusted/.hg/hgrc'):
1345 > return False
1345 > return False
1346 > return super(untrustedui, self)._trusted(fp, f)
1346 > return super(untrustedui, self)._trusted(fp, f)
1347 > ui.__class__ = untrustedui
1347 > ui.__class__ = untrustedui
1348 > EOF
1348 > EOF
1349 $ cat << EOF >> $HGRCPATH
1349 $ cat << EOF >> $HGRCPATH
1350 > [extensions]
1350 > [extensions]
1351 > untrusted=$TESTTMP/untrusted.py
1351 > untrusted=$TESTTMP/untrusted.py
1352 > EOF
1352 > EOF
1353 $ hg init untrusted
1353 $ hg init untrusted
1354 $ cd untrusted
1354 $ cd untrusted
1355
1355
1356 Non-blocking hook
1356 Non-blocking hook
1357 -----------------
1357 -----------------
1358
1358
1359 $ cat << EOF >> .hg/hgrc
1359 $ cat << EOF >> .hg/hgrc
1360 > [hooks]
1360 > [hooks]
1361 > txnclose.testing=echo txnclose hook called
1361 > txnclose.testing=echo txnclose hook called
1362 > EOF
1362 > EOF
1363 $ touch a && hg commit -Aqm a
1363 $ touch a && hg commit -Aqm a
1364 warning: untrusted hook txnclose.testing not executed
1364 warning: untrusted hook txnclose.testing not executed
1365 $ hg log
1365 $ hg log
1366 changeset: 0:3903775176ed
1366 changeset: 0:3903775176ed
1367 tag: tip
1367 tag: tip
1368 user: test
1368 user: test
1369 date: Thu Jan 01 00:00:00 1970 +0000
1369 date: Thu Jan 01 00:00:00 1970 +0000
1370 summary: a
1370 summary: a
1371
1371
1372
1372
1373 Non-blocking hook
1373 Non-blocking hook
1374 -----------------
1374 -----------------
1375
1375
1376 $ cat << EOF >> .hg/hgrc
1376 $ cat << EOF >> .hg/hgrc
1377 > [hooks]
1377 > [hooks]
1378 > pretxnclose.testing=echo pre-txnclose hook called
1378 > pretxnclose.testing=echo pre-txnclose hook called
1379 > EOF
1379 > EOF
1380 $ touch b && hg commit -Aqm a
1380 $ touch b && hg commit -Aqm a
1381 transaction abort!
1381 transaction abort!
1382 rollback completed
1382 rollback completed
1383 abort: untrusted hook pretxnclose.testing not executed
1383 abort: untrusted hook pretxnclose.testing not executed
1384 (see 'hg help config.trusted')
1384 (see 'hg help config.trusted')
1385 [255]
1385 [255]
1386 $ hg log
1386 $ hg log
1387 changeset: 0:3903775176ed
1387 changeset: 0:3903775176ed
1388 tag: tip
1388 tag: tip
1389 user: test
1389 user: test
1390 date: Thu Jan 01 00:00:00 1970 +0000
1390 date: Thu Jan 01 00:00:00 1970 +0000
1391 summary: a
1391 summary: a
1392
1392
1393
1394 unsetup the test
1395 ----------------
1396
1397 # touch the file to unconfuse chg with a diffrent mtime
1398 $ sleep 1
1399 $ touch $TESTTMP/untrusted.py
1400 $ cat << EOF >> $HGRCPATH
1401 > [extensions]
1402 > untrusted=!
1403 > EOF
1404
1405 HGPLAIN setting in hooks
1406 ========================
1407
1408 $ cat << EOF >> .hg/hgrc
1409 > [hooks]
1410 > pre-version.testing-default=echo '### default ###' plain: \$HGPLAIN
1411 > EOF
1412
1413 $ (unset HGPLAIN; hg version --quiet)
1414 ### default ### plain: 1
1415 Mercurial Distributed SCM (*) (glob)
1416
1417 $ HGPLAIN=1 hg version --quiet
1418 ### default ### plain: 1
1419 Mercurial Distributed SCM (*) (glob)
General Comments 0
You need to be logged in to leave comments. Login now