##// END OF EJS Templates
tests: drop py36 conditionals in test-hook.t...
Matt Harbison -
r51178:bcc8b351 default
parent child Browse files
Show More
@@ -1,1432 +1,1425 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 [40]
230 [40]
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 [40]
393 [40]
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 [40]
408 [40]
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 [40]
454 [40]
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 phaseroots
465 phaseroots
466 requires
466 requires
467 undo
467 undo
468 undo.backup.fncache (repofncache !)
468 undo.backup.fncache (repofncache !)
469 undo.backupfiles
469 undo.backupfiles
470
470
471
471
472 precommit hook can prevent commit
472 precommit hook can prevent commit
473
473
474 $ cat >> .hg/hgrc <<EOF
474 $ cat >> .hg/hgrc <<EOF
475 > precommit.forbid = sh -c "printenv.py --line precommit.forbid 1"
475 > precommit.forbid = sh -c "printenv.py --line precommit.forbid 1"
476 > EOF
476 > EOF
477 $ hg commit -m 'fail' -d '4 0'
477 $ hg commit -m 'fail' -d '4 0'
478 precommit hook: HG_HOOKNAME=precommit
478 precommit hook: HG_HOOKNAME=precommit
479 HG_HOOKTYPE=precommit
479 HG_HOOKTYPE=precommit
480 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
480 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
481
481
482 precommit.forbid hook: HG_HOOKNAME=precommit.forbid
482 precommit.forbid hook: HG_HOOKNAME=precommit.forbid
483 HG_HOOKTYPE=precommit
483 HG_HOOKTYPE=precommit
484 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
484 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
485
485
486 abort: precommit.forbid hook exited with status 1
486 abort: precommit.forbid hook exited with status 1
487 [40]
487 [40]
488 $ hg -q tip
488 $ hg -q tip
489 4:539e4b31b6dc
489 4:539e4b31b6dc
490
490
491 preupdate hook can prevent update
491 preupdate hook can prevent update
492
492
493 $ cat >> .hg/hgrc <<EOF
493 $ cat >> .hg/hgrc <<EOF
494 > preupdate = sh -c "printenv.py --line preupdate"
494 > preupdate = sh -c "printenv.py --line preupdate"
495 > EOF
495 > EOF
496 $ hg update 1
496 $ hg update 1
497 preupdate hook: HG_HOOKNAME=preupdate
497 preupdate hook: HG_HOOKNAME=preupdate
498 HG_HOOKTYPE=preupdate
498 HG_HOOKTYPE=preupdate
499 HG_PARENT1=ab228980c14d
499 HG_PARENT1=ab228980c14d
500
500
501 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
501 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
502
502
503 update hook
503 update hook
504
504
505 $ cat >> .hg/hgrc <<EOF
505 $ cat >> .hg/hgrc <<EOF
506 > update = sh -c "printenv.py --line update"
506 > update = sh -c "printenv.py --line update"
507 > EOF
507 > EOF
508 $ hg update
508 $ hg update
509 preupdate hook: HG_HOOKNAME=preupdate
509 preupdate hook: HG_HOOKNAME=preupdate
510 HG_HOOKTYPE=preupdate
510 HG_HOOKTYPE=preupdate
511 HG_PARENT1=539e4b31b6dc
511 HG_PARENT1=539e4b31b6dc
512
512
513 update hook: HG_ERROR=0
513 update hook: HG_ERROR=0
514 HG_HOOKNAME=update
514 HG_HOOKNAME=update
515 HG_HOOKTYPE=update
515 HG_HOOKTYPE=update
516 HG_PARENT1=539e4b31b6dc
516 HG_PARENT1=539e4b31b6dc
517
517
518 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
518 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
519
519
520 pushkey hook
520 pushkey hook
521
521
522 $ cat >> .hg/hgrc <<EOF
522 $ cat >> .hg/hgrc <<EOF
523 > pushkey = sh -c "printenv.py --line pushkey"
523 > pushkey = sh -c "printenv.py --line pushkey"
524 > EOF
524 > EOF
525 $ cd ../b
525 $ cd ../b
526 $ hg bookmark -r null foo
526 $ hg bookmark -r null foo
527 $ hg push -B foo ../a
527 $ hg push -B foo ../a
528 pushing to ../a
528 pushing to ../a
529 searching for changes
529 searching for changes
530 no changes found
530 no changes found
531 pretxnopen hook: HG_HOOKNAME=pretxnopen
531 pretxnopen hook: HG_HOOKNAME=pretxnopen
532 HG_HOOKTYPE=pretxnopen
532 HG_HOOKTYPE=pretxnopen
533 HG_TXNID=TXN:$ID$
533 HG_TXNID=TXN:$ID$
534 HG_TXNNAME=push
534 HG_TXNNAME=push
535
535
536 pretxnclose hook: HG_BOOKMARK_MOVED=1
536 pretxnclose hook: HG_BOOKMARK_MOVED=1
537 HG_BUNDLE2=1
537 HG_BUNDLE2=1
538 HG_HOOKNAME=pretxnclose
538 HG_HOOKNAME=pretxnclose
539 HG_HOOKTYPE=pretxnclose
539 HG_HOOKTYPE=pretxnclose
540 HG_PENDING=$TESTTMP/a
540 HG_PENDING=$TESTTMP/a
541 HG_SOURCE=push
541 HG_SOURCE=push
542 HG_TXNID=TXN:$ID$
542 HG_TXNID=TXN:$ID$
543 HG_TXNNAME=push
543 HG_TXNNAME=push
544 HG_URL=file:$TESTTMP/a
544 HG_URL=file:$TESTTMP/a
545
545
546 pushkey hook: HG_BUNDLE2=1
546 pushkey hook: HG_BUNDLE2=1
547 HG_HOOKNAME=pushkey
547 HG_HOOKNAME=pushkey
548 HG_HOOKTYPE=pushkey
548 HG_HOOKTYPE=pushkey
549 HG_KEY=foo
549 HG_KEY=foo
550 HG_NAMESPACE=bookmarks
550 HG_NAMESPACE=bookmarks
551 HG_NEW=0000000000000000000000000000000000000000
551 HG_NEW=0000000000000000000000000000000000000000
552 HG_PUSHKEYCOMPAT=1
552 HG_PUSHKEYCOMPAT=1
553 HG_SOURCE=push
553 HG_SOURCE=push
554 HG_TXNID=TXN:$ID$
554 HG_TXNID=TXN:$ID$
555 HG_TXNNAME=push
555 HG_TXNNAME=push
556 HG_URL=file:$TESTTMP/a
556 HG_URL=file:$TESTTMP/a
557
557
558 txnclose hook: HG_BOOKMARK_MOVED=1
558 txnclose hook: HG_BOOKMARK_MOVED=1
559 HG_BUNDLE2=1
559 HG_BUNDLE2=1
560 HG_HOOKNAME=txnclose
560 HG_HOOKNAME=txnclose
561 HG_HOOKTYPE=txnclose
561 HG_HOOKTYPE=txnclose
562 HG_SOURCE=push
562 HG_SOURCE=push
563 HG_TXNID=TXN:$ID$
563 HG_TXNID=TXN:$ID$
564 HG_TXNNAME=push
564 HG_TXNNAME=push
565 HG_URL=file:$TESTTMP/a
565 HG_URL=file:$TESTTMP/a
566
566
567 exporting bookmark foo
567 exporting bookmark foo
568 [1]
568 [1]
569 $ cd ../a
569 $ cd ../a
570
570
571 listkeys hook
571 listkeys hook
572
572
573 $ cat >> .hg/hgrc <<EOF
573 $ cat >> .hg/hgrc <<EOF
574 > listkeys = sh -c "printenv.py --line listkeys"
574 > listkeys = sh -c "printenv.py --line listkeys"
575 > EOF
575 > EOF
576 $ hg bookmark -r null bar
576 $ hg bookmark -r null bar
577 pretxnopen hook: HG_HOOKNAME=pretxnopen
577 pretxnopen hook: HG_HOOKNAME=pretxnopen
578 HG_HOOKTYPE=pretxnopen
578 HG_HOOKTYPE=pretxnopen
579 HG_TXNID=TXN:$ID$
579 HG_TXNID=TXN:$ID$
580 HG_TXNNAME=bookmark
580 HG_TXNNAME=bookmark
581
581
582 pretxnclose hook: HG_BOOKMARK_MOVED=1
582 pretxnclose hook: HG_BOOKMARK_MOVED=1
583 HG_HOOKNAME=pretxnclose
583 HG_HOOKNAME=pretxnclose
584 HG_HOOKTYPE=pretxnclose
584 HG_HOOKTYPE=pretxnclose
585 HG_PENDING=$TESTTMP/a
585 HG_PENDING=$TESTTMP/a
586 HG_TXNID=TXN:$ID$
586 HG_TXNID=TXN:$ID$
587 HG_TXNNAME=bookmark
587 HG_TXNNAME=bookmark
588
588
589 txnclose hook: HG_BOOKMARK_MOVED=1
589 txnclose hook: HG_BOOKMARK_MOVED=1
590 HG_HOOKNAME=txnclose
590 HG_HOOKNAME=txnclose
591 HG_HOOKTYPE=txnclose
591 HG_HOOKTYPE=txnclose
592 HG_TXNID=TXN:$ID$
592 HG_TXNID=TXN:$ID$
593 HG_TXNNAME=bookmark
593 HG_TXNNAME=bookmark
594
594
595 $ cd ../b
595 $ cd ../b
596 $ hg pull -B bar ../a
596 $ hg pull -B bar ../a
597 pulling from ../a
597 pulling from ../a
598 listkeys hook: HG_HOOKNAME=listkeys
598 listkeys hook: HG_HOOKNAME=listkeys
599 HG_HOOKTYPE=listkeys
599 HG_HOOKTYPE=listkeys
600 HG_NAMESPACE=bookmarks
600 HG_NAMESPACE=bookmarks
601 HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
601 HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
602
602
603 no changes found
603 no changes found
604 adding remote bookmark bar
604 adding remote bookmark bar
605 $ cd ../a
605 $ cd ../a
606
606
607 test that prepushkey can prevent incoming keys
607 test that prepushkey can prevent incoming keys
608
608
609 $ cat >> .hg/hgrc <<EOF
609 $ cat >> .hg/hgrc <<EOF
610 > prepushkey = sh -c "printenv.py --line prepushkey.forbid 1"
610 > prepushkey = sh -c "printenv.py --line prepushkey.forbid 1"
611 > EOF
611 > EOF
612 $ cd ../b
612 $ cd ../b
613 $ hg bookmark -r null baz
613 $ hg bookmark -r null baz
614 $ hg push -B baz ../a
614 $ hg push -B baz ../a
615 pushing to ../a
615 pushing to ../a
616 searching for changes
616 searching for changes
617 listkeys hook: HG_HOOKNAME=listkeys
617 listkeys hook: HG_HOOKNAME=listkeys
618 HG_HOOKTYPE=listkeys
618 HG_HOOKTYPE=listkeys
619 HG_NAMESPACE=phases
619 HG_NAMESPACE=phases
620 HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
620 HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
621
621
622 listkeys hook: HG_HOOKNAME=listkeys
622 listkeys hook: HG_HOOKNAME=listkeys
623 HG_HOOKTYPE=listkeys
623 HG_HOOKTYPE=listkeys
624 HG_NAMESPACE=bookmarks
624 HG_NAMESPACE=bookmarks
625 HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
625 HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
626
626
627 no changes found
627 no changes found
628 pretxnopen hook: HG_HOOKNAME=pretxnopen
628 pretxnopen hook: HG_HOOKNAME=pretxnopen
629 HG_HOOKTYPE=pretxnopen
629 HG_HOOKTYPE=pretxnopen
630 HG_TXNID=TXN:$ID$
630 HG_TXNID=TXN:$ID$
631 HG_TXNNAME=push
631 HG_TXNNAME=push
632
632
633 prepushkey.forbid hook: HG_BUNDLE2=1
633 prepushkey.forbid hook: HG_BUNDLE2=1
634 HG_HOOKNAME=prepushkey
634 HG_HOOKNAME=prepushkey
635 HG_HOOKTYPE=prepushkey
635 HG_HOOKTYPE=prepushkey
636 HG_KEY=baz
636 HG_KEY=baz
637 HG_NAMESPACE=bookmarks
637 HG_NAMESPACE=bookmarks
638 HG_NEW=0000000000000000000000000000000000000000
638 HG_NEW=0000000000000000000000000000000000000000
639 HG_PUSHKEYCOMPAT=1
639 HG_PUSHKEYCOMPAT=1
640 HG_SOURCE=push
640 HG_SOURCE=push
641 HG_TXNID=TXN:$ID$
641 HG_TXNID=TXN:$ID$
642 HG_TXNNAME=push
642 HG_TXNNAME=push
643 HG_URL=file:$TESTTMP/a
643 HG_URL=file:$TESTTMP/a
644
644
645 txnabort Python hook: bundle2,changes,source,txnid,txnname,url
645 txnabort Python hook: bundle2,changes,source,txnid,txnname,url
646 txnabort hook: HG_BUNDLE2=1
646 txnabort hook: HG_BUNDLE2=1
647 HG_HOOKNAME=txnabort.1
647 HG_HOOKNAME=txnabort.1
648 HG_HOOKTYPE=txnabort
648 HG_HOOKTYPE=txnabort
649 HG_SOURCE=push
649 HG_SOURCE=push
650 HG_TXNID=TXN:$ID$
650 HG_TXNID=TXN:$ID$
651 HG_TXNNAME=push
651 HG_TXNNAME=push
652 HG_URL=file:$TESTTMP/a
652 HG_URL=file:$TESTTMP/a
653
653
654 abort: prepushkey hook exited with status 1
654 abort: prepushkey hook exited with status 1
655 [40]
655 [40]
656 $ cd ../a
656 $ cd ../a
657
657
658 test that prelistkeys can prevent listing keys
658 test that prelistkeys can prevent listing keys
659
659
660 $ cat >> .hg/hgrc <<EOF
660 $ cat >> .hg/hgrc <<EOF
661 > prelistkeys = sh -c "printenv.py --line prelistkeys.forbid 1"
661 > prelistkeys = sh -c "printenv.py --line prelistkeys.forbid 1"
662 > EOF
662 > EOF
663 $ hg bookmark -r null quux
663 $ hg bookmark -r null quux
664 pretxnopen hook: HG_HOOKNAME=pretxnopen
664 pretxnopen hook: HG_HOOKNAME=pretxnopen
665 HG_HOOKTYPE=pretxnopen
665 HG_HOOKTYPE=pretxnopen
666 HG_TXNID=TXN:$ID$
666 HG_TXNID=TXN:$ID$
667 HG_TXNNAME=bookmark
667 HG_TXNNAME=bookmark
668
668
669 pretxnclose hook: HG_BOOKMARK_MOVED=1
669 pretxnclose hook: HG_BOOKMARK_MOVED=1
670 HG_HOOKNAME=pretxnclose
670 HG_HOOKNAME=pretxnclose
671 HG_HOOKTYPE=pretxnclose
671 HG_HOOKTYPE=pretxnclose
672 HG_PENDING=$TESTTMP/a
672 HG_PENDING=$TESTTMP/a
673 HG_TXNID=TXN:$ID$
673 HG_TXNID=TXN:$ID$
674 HG_TXNNAME=bookmark
674 HG_TXNNAME=bookmark
675
675
676 txnclose hook: HG_BOOKMARK_MOVED=1
676 txnclose hook: HG_BOOKMARK_MOVED=1
677 HG_HOOKNAME=txnclose
677 HG_HOOKNAME=txnclose
678 HG_HOOKTYPE=txnclose
678 HG_HOOKTYPE=txnclose
679 HG_TXNID=TXN:$ID$
679 HG_TXNID=TXN:$ID$
680 HG_TXNNAME=bookmark
680 HG_TXNNAME=bookmark
681
681
682 $ cd ../b
682 $ cd ../b
683 $ hg pull -B quux ../a
683 $ hg pull -B quux ../a
684 pulling from ../a
684 pulling from ../a
685 prelistkeys.forbid hook: HG_HOOKNAME=prelistkeys
685 prelistkeys.forbid hook: HG_HOOKNAME=prelistkeys
686 HG_HOOKTYPE=prelistkeys
686 HG_HOOKTYPE=prelistkeys
687 HG_NAMESPACE=bookmarks
687 HG_NAMESPACE=bookmarks
688
688
689 abort: prelistkeys hook exited with status 1
689 abort: prelistkeys hook exited with status 1
690 [40]
690 [40]
691 $ cd ../a
691 $ cd ../a
692 $ rm .hg/hgrc
692 $ rm .hg/hgrc
693
693
694 prechangegroup hook can prevent incoming changes
694 prechangegroup hook can prevent incoming changes
695
695
696 $ cd ../b
696 $ cd ../b
697 $ hg -q tip
697 $ hg -q tip
698 3:07f3376c1e65
698 3:07f3376c1e65
699 $ cat > .hg/hgrc <<EOF
699 $ cat > .hg/hgrc <<EOF
700 > [hooks]
700 > [hooks]
701 > prechangegroup.forbid = sh -c "printenv.py --line prechangegroup.forbid 1"
701 > prechangegroup.forbid = sh -c "printenv.py --line prechangegroup.forbid 1"
702 > EOF
702 > EOF
703 $ hg pull ../a
703 $ hg pull ../a
704 pulling from ../a
704 pulling from ../a
705 searching for changes
705 searching for changes
706 prechangegroup.forbid hook: HG_HOOKNAME=prechangegroup.forbid
706 prechangegroup.forbid hook: HG_HOOKNAME=prechangegroup.forbid
707 HG_HOOKTYPE=prechangegroup
707 HG_HOOKTYPE=prechangegroup
708 HG_SOURCE=pull
708 HG_SOURCE=pull
709 HG_TXNID=TXN:$ID$
709 HG_TXNID=TXN:$ID$
710 HG_TXNNAME=pull
710 HG_TXNNAME=pull
711 file:/*/$TESTTMP/a (glob)
711 file:/*/$TESTTMP/a (glob)
712 HG_URL=file:$TESTTMP/a
712 HG_URL=file:$TESTTMP/a
713
713
714 abort: prechangegroup.forbid hook exited with status 1
714 abort: prechangegroup.forbid hook exited with status 1
715 [40]
715 [40]
716
716
717 pretxnchangegroup hook can see incoming changes, can roll back txn,
717 pretxnchangegroup hook can see incoming changes, can roll back txn,
718 incoming changes no longer there after
718 incoming changes no longer there after
719
719
720 $ cat > .hg/hgrc <<EOF
720 $ cat > .hg/hgrc <<EOF
721 > [hooks]
721 > [hooks]
722 > pretxnchangegroup.forbid0 = hg tip -q
722 > pretxnchangegroup.forbid0 = hg tip -q
723 > pretxnchangegroup.forbid1 = sh -c "printenv.py --line pretxnchangegroup.forbid 1"
723 > pretxnchangegroup.forbid1 = sh -c "printenv.py --line pretxnchangegroup.forbid 1"
724 > EOF
724 > EOF
725 $ hg pull ../a
725 $ hg pull ../a
726 pulling from ../a
726 pulling from ../a
727 searching for changes
727 searching for changes
728 adding changesets
728 adding changesets
729 adding manifests
729 adding manifests
730 adding file changes
730 adding file changes
731 4:539e4b31b6dc
731 4:539e4b31b6dc
732 pretxnchangegroup.forbid hook: HG_HOOKNAME=pretxnchangegroup.forbid1
732 pretxnchangegroup.forbid hook: HG_HOOKNAME=pretxnchangegroup.forbid1
733 HG_HOOKTYPE=pretxnchangegroup
733 HG_HOOKTYPE=pretxnchangegroup
734 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
734 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
735 HG_NODE_LAST=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
735 HG_NODE_LAST=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
736 HG_PENDING=$TESTTMP/b
736 HG_PENDING=$TESTTMP/b
737 HG_SOURCE=pull
737 HG_SOURCE=pull
738 HG_TXNID=TXN:$ID$
738 HG_TXNID=TXN:$ID$
739 HG_TXNNAME=pull
739 HG_TXNNAME=pull
740 file:/*/$TESTTMP/a (glob)
740 file:/*/$TESTTMP/a (glob)
741 HG_URL=file:$TESTTMP/a
741 HG_URL=file:$TESTTMP/a
742
742
743 transaction abort!
743 transaction abort!
744 rollback completed
744 rollback completed
745 abort: pretxnchangegroup.forbid1 hook exited with status 1
745 abort: pretxnchangegroup.forbid1 hook exited with status 1
746 [40]
746 [40]
747 $ hg -q tip
747 $ hg -q tip
748 3:07f3376c1e65
748 3:07f3376c1e65
749
749
750 outgoing hooks can see env vars
750 outgoing hooks can see env vars
751
751
752 $ rm .hg/hgrc
752 $ rm .hg/hgrc
753 $ cat > ../a/.hg/hgrc <<EOF
753 $ cat > ../a/.hg/hgrc <<EOF
754 > [hooks]
754 > [hooks]
755 > preoutgoing = sh -c "printenv.py --line preoutgoing"
755 > preoutgoing = sh -c "printenv.py --line preoutgoing"
756 > outgoing = sh -c "printenv.py --line outgoing"
756 > outgoing = sh -c "printenv.py --line outgoing"
757 > EOF
757 > EOF
758 $ hg pull ../a
758 $ hg pull ../a
759 pulling from ../a
759 pulling from ../a
760 searching for changes
760 searching for changes
761 preoutgoing hook: HG_HOOKNAME=preoutgoing
761 preoutgoing hook: HG_HOOKNAME=preoutgoing
762 HG_HOOKTYPE=preoutgoing
762 HG_HOOKTYPE=preoutgoing
763 HG_SOURCE=pull
763 HG_SOURCE=pull
764
764
765 outgoing hook: HG_HOOKNAME=outgoing
765 outgoing hook: HG_HOOKNAME=outgoing
766 HG_HOOKTYPE=outgoing
766 HG_HOOKTYPE=outgoing
767 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
767 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
768 HG_SOURCE=pull
768 HG_SOURCE=pull
769
769
770 adding changesets
770 adding changesets
771 adding manifests
771 adding manifests
772 adding file changes
772 adding file changes
773 adding remote bookmark quux
773 adding remote bookmark quux
774 added 1 changesets with 1 changes to 1 files
774 added 1 changesets with 1 changes to 1 files
775 new changesets 539e4b31b6dc
775 new changesets 539e4b31b6dc
776 (run 'hg update' to get a working copy)
776 (run 'hg update' to get a working copy)
777 $ hg rollback
777 $ hg rollback
778 repository tip rolled back to revision 3 (undo pull)
778 repository tip rolled back to revision 3 (undo pull)
779
779
780 preoutgoing hook can prevent outgoing changes
780 preoutgoing hook can prevent outgoing changes
781
781
782 $ cat >> ../a/.hg/hgrc <<EOF
782 $ cat >> ../a/.hg/hgrc <<EOF
783 > preoutgoing.forbid = sh -c "printenv.py --line preoutgoing.forbid 1"
783 > preoutgoing.forbid = sh -c "printenv.py --line preoutgoing.forbid 1"
784 > EOF
784 > EOF
785 $ hg pull ../a
785 $ hg pull ../a
786 pulling from ../a
786 pulling from ../a
787 searching for changes
787 searching for changes
788 preoutgoing hook: HG_HOOKNAME=preoutgoing
788 preoutgoing hook: HG_HOOKNAME=preoutgoing
789 HG_HOOKTYPE=preoutgoing
789 HG_HOOKTYPE=preoutgoing
790 HG_SOURCE=pull
790 HG_SOURCE=pull
791
791
792 preoutgoing.forbid hook: HG_HOOKNAME=preoutgoing.forbid
792 preoutgoing.forbid hook: HG_HOOKNAME=preoutgoing.forbid
793 HG_HOOKTYPE=preoutgoing
793 HG_HOOKTYPE=preoutgoing
794 HG_SOURCE=pull
794 HG_SOURCE=pull
795
795
796 abort: preoutgoing.forbid hook exited with status 1
796 abort: preoutgoing.forbid hook exited with status 1
797 [40]
797 [40]
798
798
799 outgoing hooks work for local clones
799 outgoing hooks work for local clones
800
800
801 $ cd ..
801 $ cd ..
802 $ cat > a/.hg/hgrc <<EOF
802 $ cat > a/.hg/hgrc <<EOF
803 > [hooks]
803 > [hooks]
804 > preoutgoing = sh -c "printenv.py --line preoutgoing"
804 > preoutgoing = sh -c "printenv.py --line preoutgoing"
805 > outgoing = sh -c "printenv.py --line outgoing"
805 > outgoing = sh -c "printenv.py --line outgoing"
806 > EOF
806 > EOF
807 $ hg clone a c
807 $ hg clone a c
808 preoutgoing hook: HG_HOOKNAME=preoutgoing
808 preoutgoing hook: HG_HOOKNAME=preoutgoing
809 HG_HOOKTYPE=preoutgoing
809 HG_HOOKTYPE=preoutgoing
810 HG_SOURCE=clone
810 HG_SOURCE=clone
811
811
812 outgoing hook: HG_HOOKNAME=outgoing
812 outgoing hook: HG_HOOKNAME=outgoing
813 HG_HOOKTYPE=outgoing
813 HG_HOOKTYPE=outgoing
814 HG_NODE=0000000000000000000000000000000000000000
814 HG_NODE=0000000000000000000000000000000000000000
815 HG_SOURCE=clone
815 HG_SOURCE=clone
816
816
817 updating to branch default
817 updating to branch default
818 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
818 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
819 $ rm -rf c
819 $ rm -rf c
820
820
821 preoutgoing hook can prevent outgoing changes for local clones
821 preoutgoing hook can prevent outgoing changes for local clones
822
822
823 $ cat >> a/.hg/hgrc <<EOF
823 $ cat >> a/.hg/hgrc <<EOF
824 > preoutgoing.forbid = sh -c "printenv.py --line preoutgoing.forbid 1"
824 > preoutgoing.forbid = sh -c "printenv.py --line preoutgoing.forbid 1"
825 > EOF
825 > EOF
826 $ hg clone a zzz
826 $ hg clone a zzz
827 preoutgoing hook: HG_HOOKNAME=preoutgoing
827 preoutgoing hook: HG_HOOKNAME=preoutgoing
828 HG_HOOKTYPE=preoutgoing
828 HG_HOOKTYPE=preoutgoing
829 HG_SOURCE=clone
829 HG_SOURCE=clone
830
830
831 preoutgoing.forbid hook: HG_HOOKNAME=preoutgoing.forbid
831 preoutgoing.forbid hook: HG_HOOKNAME=preoutgoing.forbid
832 HG_HOOKTYPE=preoutgoing
832 HG_HOOKTYPE=preoutgoing
833 HG_SOURCE=clone
833 HG_SOURCE=clone
834
834
835 abort: preoutgoing.forbid hook exited with status 1
835 abort: preoutgoing.forbid hook exited with status 1
836 [40]
836 [40]
837
837
838 $ cd "$TESTTMP/b"
838 $ cd "$TESTTMP/b"
839
839
840 $ cat > hooktests.py <<EOF
840 $ cat > hooktests.py <<EOF
841 > from mercurial import (
841 > from mercurial import (
842 > error,
842 > error,
843 > pycompat,
843 > pycompat,
844 > )
844 > )
845 >
845 >
846 > uncallable = 0
846 > uncallable = 0
847 >
847 >
848 > def printargs(ui, args):
848 > def printargs(ui, args):
849 > a = list(pycompat.byteskwargs(args).items())
849 > a = list(pycompat.byteskwargs(args).items())
850 > a.sort()
850 > a.sort()
851 > ui.write(b'hook args:\n')
851 > ui.write(b'hook args:\n')
852 > for k, v in a:
852 > for k, v in a:
853 > ui.write(b' %s %s\n' % (k, v))
853 > ui.write(b' %s %s\n' % (k, v))
854 >
854 >
855 > def passhook(ui, repo, **args):
855 > def passhook(ui, repo, **args):
856 > printargs(ui, args)
856 > printargs(ui, args)
857 >
857 >
858 > def failhook(ui, repo, **args):
858 > def failhook(ui, repo, **args):
859 > printargs(ui, args)
859 > printargs(ui, args)
860 > return True
860 > return True
861 >
861 >
862 > class LocalException(Exception):
862 > class LocalException(Exception):
863 > pass
863 > pass
864 >
864 >
865 > def raisehook(**args):
865 > def raisehook(**args):
866 > raise LocalException('exception from hook')
866 > raise LocalException('exception from hook')
867 >
867 >
868 > def aborthook(**args):
868 > def aborthook(**args):
869 > raise error.Abort(b'raise abort from hook')
869 > raise error.Abort(b'raise abort from hook')
870 >
870 >
871 > def brokenhook(**args):
871 > def brokenhook(**args):
872 > return 1 + {}
872 > return 1 + {}
873 >
873 >
874 > def verbosehook(ui, **args):
874 > def verbosehook(ui, **args):
875 > ui.note(b'verbose output from hook\n')
875 > ui.note(b'verbose output from hook\n')
876 >
876 >
877 > def printtags(ui, repo, **args):
877 > def printtags(ui, repo, **args):
878 > ui.write(b'[%s]\n' % b', '.join(sorted(repo.tags())))
878 > ui.write(b'[%s]\n' % b', '.join(sorted(repo.tags())))
879 >
879 >
880 > class container(object):
880 > class container(object):
881 > unreachable = 1
881 > unreachable = 1
882 > EOF
882 > EOF
883
883
884 $ cat > syntaxerror.py << NO_CHECK_EOF
884 $ cat > syntaxerror.py << NO_CHECK_EOF
885 > (foo
885 > (foo
886 > NO_CHECK_EOF
886 > NO_CHECK_EOF
887
887
888 test python hooks
888 test python hooks
889
889
890 #if windows
890 #if windows
891 $ PYTHONPATH="$TESTTMP/b;$PYTHONPATH"
891 $ PYTHONPATH="$TESTTMP/b;$PYTHONPATH"
892 #else
892 #else
893 $ PYTHONPATH="$TESTTMP/b:$PYTHONPATH"
893 $ PYTHONPATH="$TESTTMP/b:$PYTHONPATH"
894 #endif
894 #endif
895 $ export PYTHONPATH
895 $ export PYTHONPATH
896
896
897 $ echo '[hooks]' > ../a/.hg/hgrc
897 $ echo '[hooks]' > ../a/.hg/hgrc
898 $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
898 $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
899 $ hg pull ../a 2>&1 | grep 'raised an exception'
899 $ hg pull ../a 2>&1 | grep 'raised an exception'
900 error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
900 error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
901
901
902 $ echo '[hooks]' > ../a/.hg/hgrc
902 $ echo '[hooks]' > ../a/.hg/hgrc
903 $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
903 $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
904 $ hg pull ../a 2>&1 | grep 'raised an exception'
904 $ hg pull ../a 2>&1 | grep 'raised an exception'
905 error: preoutgoing.raise hook raised an exception: exception from hook
905 error: preoutgoing.raise hook raised an exception: exception from hook
906
906
907 $ echo '[hooks]' > ../a/.hg/hgrc
907 $ echo '[hooks]' > ../a/.hg/hgrc
908 $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
908 $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
909 $ hg pull ../a
909 $ hg pull ../a
910 pulling from ../a
910 pulling from ../a
911 searching for changes
911 searching for changes
912 error: preoutgoing.abort hook failed: raise abort from hook
912 error: preoutgoing.abort hook failed: raise abort from hook
913 abort: raise abort from hook
913 abort: raise abort from hook
914 [255]
914 [255]
915
915
916 $ echo '[hooks]' > ../a/.hg/hgrc
916 $ echo '[hooks]' > ../a/.hg/hgrc
917 $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
917 $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
918 $ hg pull ../a
918 $ hg pull ../a
919 pulling from ../a
919 pulling from ../a
920 searching for changes
920 searching for changes
921 hook args:
921 hook args:
922 hooktype preoutgoing
922 hooktype preoutgoing
923 source pull
923 source pull
924 abort: preoutgoing.fail hook failed
924 abort: preoutgoing.fail hook failed
925 [40]
925 [40]
926
926
927 $ echo '[hooks]' > ../a/.hg/hgrc
927 $ echo '[hooks]' > ../a/.hg/hgrc
928 $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
928 $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
929 $ hg pull ../a
929 $ hg pull ../a
930 pulling from ../a
930 pulling from ../a
931 searching for changes
931 searching for changes
932 abort: preoutgoing.uncallable hook is invalid: "hooktests.uncallable" is not callable
932 abort: preoutgoing.uncallable hook is invalid: "hooktests.uncallable" is not callable
933 [255]
933 [255]
934
934
935 $ echo '[hooks]' > ../a/.hg/hgrc
935 $ echo '[hooks]' > ../a/.hg/hgrc
936 $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
936 $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
937 $ hg pull ../a
937 $ hg pull ../a
938 pulling from ../a
938 pulling from ../a
939 searching for changes
939 searching for changes
940 abort: preoutgoing.nohook hook is invalid: "hooktests.nohook" is not defined
940 abort: preoutgoing.nohook hook is invalid: "hooktests.nohook" is not defined
941 [255]
941 [255]
942
942
943 $ echo '[hooks]' > ../a/.hg/hgrc
943 $ echo '[hooks]' > ../a/.hg/hgrc
944 $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
944 $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
945 $ hg pull ../a
945 $ hg pull ../a
946 pulling from ../a
946 pulling from ../a
947 searching for changes
947 searching for changes
948 abort: preoutgoing.nomodule hook is invalid: "nomodule" not in a module
948 abort: preoutgoing.nomodule hook is invalid: "nomodule" not in a module
949 [255]
949 [255]
950
950
951 $ echo '[hooks]' > ../a/.hg/hgrc
951 $ echo '[hooks]' > ../a/.hg/hgrc
952 $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
952 $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
953 $ hg pull ../a
953 $ hg pull ../a
954 pulling from ../a
954 pulling from ../a
955 searching for changes
955 searching for changes
956 abort: preoutgoing.badmodule hook is invalid: import of "nomodule" failed
956 abort: preoutgoing.badmodule hook is invalid: import of "nomodule" failed
957 (run with --traceback for stack trace)
957 (run with --traceback for stack trace)
958 [255]
958 [255]
959
959
960 $ echo '[hooks]' > ../a/.hg/hgrc
960 $ echo '[hooks]' > ../a/.hg/hgrc
961 $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
961 $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
962 $ hg pull ../a
962 $ hg pull ../a
963 pulling from ../a
963 pulling from ../a
964 searching for changes
964 searching for changes
965 abort: preoutgoing.unreachable hook is invalid: import of "hooktests.container" failed
965 abort: preoutgoing.unreachable hook is invalid: import of "hooktests.container" failed
966 (run with --traceback for stack trace)
966 (run with --traceback for stack trace)
967 [255]
967 [255]
968
968
969 $ echo '[hooks]' > ../a/.hg/hgrc
969 $ echo '[hooks]' > ../a/.hg/hgrc
970 $ echo 'preoutgoing.syntaxerror = python:syntaxerror.syntaxerror' >> ../a/.hg/hgrc
970 $ echo 'preoutgoing.syntaxerror = python:syntaxerror.syntaxerror' >> ../a/.hg/hgrc
971 $ hg pull ../a
971 $ hg pull ../a
972 pulling from ../a
972 pulling from ../a
973 searching for changes
973 searching for changes
974 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
974 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
975 (run with --traceback for stack trace)
975 (run with --traceback for stack trace)
976 [255]
976 [255]
977
977
978 $ hg pull ../a --traceback 2>&1 | egrep 'pulling|searching|^exception|Traceback|SyntaxError|ImportError|ModuleNotFoundError|HookLoadError|abort'
978 $ hg pull ../a --traceback 2>&1 | egrep 'pulling|searching|^exception|Traceback|SyntaxError|ImportError|ModuleNotFoundError|HookLoadError|abort'
979 pulling from ../a
979 pulling from ../a
980 searching for changes
980 searching for changes
981 exception from first failed import attempt:
981 exception from first failed import attempt:
982 Traceback (most recent call last):
982 Traceback (most recent call last):
983 SyntaxError: * (glob)
983 SyntaxError: * (glob)
984 exception from second failed import attempt:
984 exception from second failed import attempt:
985 Traceback (most recent call last):
985 Traceback (most recent call last):
986 SyntaxError: * (glob)
986 SyntaxError: * (glob)
987 Traceback (most recent call last):
987 Traceback (most recent call last):
988 ImportError: No module named 'hgext_syntaxerror' (no-py36 !)
988 ModuleNotFoundError: No module named 'hgext_syntaxerror'
989 ModuleNotFoundError: No module named 'hgext_syntaxerror' (py36 !)
990 Traceback (most recent call last):
989 Traceback (most recent call last):
991 SyntaxError: * (glob)
990 SyntaxError: * (glob)
992 Traceback (most recent call last):
991 Traceback (most recent call last):
993 ImportError: No module named 'hgext_syntaxerror' (no-py36 !)
992 ModuleNotFoundError: No module named 'hgext_syntaxerror'
994 ModuleNotFoundError: No module named 'hgext_syntaxerror' (py36 !)
995 Traceback (most recent call last):
993 Traceback (most recent call last):
996 raise error.HookLoadError( (py38 !)
994 raise error.HookLoadError( (py38 !)
997 mercurial.error.HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
995 mercurial.error.HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
998 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
996 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
999
997
1000 $ echo '[hooks]' > ../a/.hg/hgrc
998 $ echo '[hooks]' > ../a/.hg/hgrc
1001 $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
999 $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
1002 $ hg pull ../a
1000 $ hg pull ../a
1003 pulling from ../a
1001 pulling from ../a
1004 searching for changes
1002 searching for changes
1005 hook args:
1003 hook args:
1006 hooktype preoutgoing
1004 hooktype preoutgoing
1007 source pull
1005 source pull
1008 adding changesets
1006 adding changesets
1009 adding manifests
1007 adding manifests
1010 adding file changes
1008 adding file changes
1011 adding remote bookmark quux
1009 adding remote bookmark quux
1012 added 1 changesets with 1 changes to 1 files
1010 added 1 changesets with 1 changes to 1 files
1013 new changesets 539e4b31b6dc
1011 new changesets 539e4b31b6dc
1014 (run 'hg update' to get a working copy)
1012 (run 'hg update' to get a working copy)
1015
1013
1016 post- python hooks that fail to *run* don't cause an abort
1014 post- python hooks that fail to *run* don't cause an abort
1017 $ rm ../a/.hg/hgrc
1015 $ rm ../a/.hg/hgrc
1018 $ echo '[hooks]' > .hg/hgrc
1016 $ echo '[hooks]' > .hg/hgrc
1019 $ echo 'post-pull.broken = python:hooktests.brokenhook' >> .hg/hgrc
1017 $ echo 'post-pull.broken = python:hooktests.brokenhook' >> .hg/hgrc
1020 $ hg pull ../a
1018 $ hg pull ../a
1021 pulling from ../a
1019 pulling from ../a
1022 searching for changes
1020 searching for changes
1023 no changes found
1021 no changes found
1024 error: post-pull.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
1022 error: post-pull.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
1025 (run with --traceback for stack trace)
1023 (run with --traceback for stack trace)
1026
1024
1027 but post- python hooks that fail to *load* do
1025 but post- python hooks that fail to *load* do
1028 $ echo '[hooks]' > .hg/hgrc
1026 $ echo '[hooks]' > .hg/hgrc
1029 $ echo 'post-pull.nomodule = python:nomodule' >> .hg/hgrc
1027 $ echo 'post-pull.nomodule = python:nomodule' >> .hg/hgrc
1030 $ hg pull ../a
1028 $ hg pull ../a
1031 pulling from ../a
1029 pulling from ../a
1032 searching for changes
1030 searching for changes
1033 no changes found
1031 no changes found
1034 abort: post-pull.nomodule hook is invalid: "nomodule" not in a module
1032 abort: post-pull.nomodule hook is invalid: "nomodule" not in a module
1035 [255]
1033 [255]
1036
1034
1037 $ echo '[hooks]' > .hg/hgrc
1035 $ echo '[hooks]' > .hg/hgrc
1038 $ echo 'post-pull.badmodule = python:nomodule.nowhere' >> .hg/hgrc
1036 $ echo 'post-pull.badmodule = python:nomodule.nowhere' >> .hg/hgrc
1039 $ hg pull ../a
1037 $ hg pull ../a
1040 pulling from ../a
1038 pulling from ../a
1041 searching for changes
1039 searching for changes
1042 no changes found
1040 no changes found
1043 abort: post-pull.badmodule hook is invalid: import of "nomodule" failed
1041 abort: post-pull.badmodule hook is invalid: import of "nomodule" failed
1044 (run with --traceback for stack trace)
1042 (run with --traceback for stack trace)
1045 [255]
1043 [255]
1046
1044
1047 $ echo '[hooks]' > .hg/hgrc
1045 $ echo '[hooks]' > .hg/hgrc
1048 $ echo 'post-pull.nohook = python:hooktests.nohook' >> .hg/hgrc
1046 $ echo 'post-pull.nohook = python:hooktests.nohook' >> .hg/hgrc
1049 $ hg pull ../a
1047 $ hg pull ../a
1050 pulling from ../a
1048 pulling from ../a
1051 searching for changes
1049 searching for changes
1052 no changes found
1050 no changes found
1053 abort: post-pull.nohook hook is invalid: "hooktests.nohook" is not defined
1051 abort: post-pull.nohook hook is invalid: "hooktests.nohook" is not defined
1054 [255]
1052 [255]
1055
1053
1056 make sure --traceback works
1054 make sure --traceback works
1057
1055
1058 $ echo '[hooks]' > .hg/hgrc
1056 $ echo '[hooks]' > .hg/hgrc
1059 $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
1057 $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
1060
1058
1061 $ echo aa > a
1059 $ echo aa > a
1062 $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback'
1060 $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback'
1063 Traceback (most recent call last):
1061 Traceback (most recent call last):
1064
1062
1065 $ cd ..
1063 $ cd ..
1066 $ hg init c
1064 $ hg init c
1067 $ cd c
1065 $ cd c
1068
1066
1069 $ cat > hookext.py <<EOF
1067 $ cat > hookext.py <<EOF
1070 > def autohook(ui, **args):
1068 > def autohook(ui, **args):
1071 > ui.write(b'Automatically installed hook\n')
1069 > ui.write(b'Automatically installed hook\n')
1072 >
1070 >
1073 > def reposetup(ui, repo):
1071 > def reposetup(ui, repo):
1074 > repo.ui.setconfig(b"hooks", b"commit.auto", autohook)
1072 > repo.ui.setconfig(b"hooks", b"commit.auto", autohook)
1075 > EOF
1073 > EOF
1076 $ echo '[extensions]' >> .hg/hgrc
1074 $ echo '[extensions]' >> .hg/hgrc
1077 $ echo 'hookext = hookext.py' >> .hg/hgrc
1075 $ echo 'hookext = hookext.py' >> .hg/hgrc
1078
1076
1079 $ touch foo
1077 $ touch foo
1080 $ hg add foo
1078 $ hg add foo
1081 $ hg ci -d '0 0' -m 'add foo'
1079 $ hg ci -d '0 0' -m 'add foo'
1082 Automatically installed hook
1080 Automatically installed hook
1083 $ echo >> foo
1081 $ echo >> foo
1084 $ hg ci --debug -d '0 0' -m 'change foo'
1082 $ hg ci --debug -d '0 0' -m 'change foo'
1085 committing files:
1083 committing files:
1086 foo
1084 foo
1087 committing manifest
1085 committing manifest
1088 committing changelog
1086 committing changelog
1089 updating the branch cache
1087 updating the branch cache
1090 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
1088 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
1091 calling hook commit.auto: hgext_hookext.autohook
1089 calling hook commit.auto: hgext_hookext.autohook
1092 Automatically installed hook
1090 Automatically installed hook
1093
1091
1094 $ hg showconfig hooks
1092 $ hg showconfig hooks
1095 hooks.commit.auto=<function autohook at *> (glob)
1093 hooks.commit.auto=<function autohook at *> (glob)
1096
1094
1097 test python hook configured with python:[file]:[hook] syntax
1095 test python hook configured with python:[file]:[hook] syntax
1098
1096
1099 $ cd ..
1097 $ cd ..
1100 $ mkdir d
1098 $ mkdir d
1101 $ cd d
1099 $ cd d
1102 $ hg init repo
1100 $ hg init repo
1103 $ mkdir hooks
1101 $ mkdir hooks
1104
1102
1105 $ cd hooks
1103 $ cd hooks
1106 $ cat > testhooks.py <<EOF
1104 $ cat > testhooks.py <<EOF
1107 > def testhook(ui, **args):
1105 > def testhook(ui, **args):
1108 > ui.write(b'hook works\n')
1106 > ui.write(b'hook works\n')
1109 > EOF
1107 > EOF
1110 $ echo '[hooks]' > ../repo/.hg/hgrc
1108 $ echo '[hooks]' > ../repo/.hg/hgrc
1111 $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
1109 $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
1112
1110
1113 $ cd ../repo
1111 $ cd ../repo
1114 $ hg commit -d '0 0'
1112 $ hg commit -d '0 0'
1115 hook works
1113 hook works
1116 nothing changed
1114 nothing changed
1117 [1]
1115 [1]
1118
1116
1119 $ echo '[hooks]' > .hg/hgrc
1117 $ echo '[hooks]' > .hg/hgrc
1120 $ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc
1118 $ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc
1121 $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc
1119 $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc
1122
1120
1123 $ hg up null
1121 $ hg up null
1124 loading update.ne hook failed:
1122 loading update.ne hook failed:
1125 abort: $ENOENT$: '$TESTTMP/d/repo/nonexistent.py'
1123 abort: $ENOENT$: '$TESTTMP/d/repo/nonexistent.py'
1126 [255]
1124 [255]
1127
1125
1128 $ hg id
1126 $ hg id
1129 loading pre-identify.npmd hook failed:
1127 loading pre-identify.npmd hook failed:
1130 abort: No module named 'repo'
1128 abort: No module named 'repo'
1131 [255]
1129 [255]
1132
1130
1133 $ cd ../../b
1131 $ cd ../../b
1134
1132
1135 make sure --traceback works on hook import failure
1133 make sure --traceback works on hook import failure
1136
1134
1137 $ cat > importfail.py <<EOF
1135 $ cat > importfail.py <<EOF
1138 > import somebogusmodule
1136 > import somebogusmodule
1139 > # dereference something in the module to force demandimport to load it
1137 > # dereference something in the module to force demandimport to load it
1140 > somebogusmodule.whatever
1138 > somebogusmodule.whatever
1141 > EOF
1139 > EOF
1142
1140
1143 $ echo '[hooks]' > .hg/hgrc
1141 $ echo '[hooks]' > .hg/hgrc
1144 $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
1142 $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
1145
1143
1146 $ echo a >> a
1144 $ echo a >> a
1147 $ hg --traceback commit -ma 2>&1 | egrep '^exception|ImportError|ModuleNotFoundError|Traceback|HookLoadError|abort'
1145 $ hg --traceback commit -ma 2>&1 | egrep '^exception|ImportError|ModuleNotFoundError|Traceback|HookLoadError|abort'
1148 exception from first failed import attempt:
1146 exception from first failed import attempt:
1149 Traceback (most recent call last):
1147 Traceback (most recent call last):
1150 ImportError: No module named 'somebogusmodule' (no-py36 !)
1148 ModuleNotFoundError: No module named 'somebogusmodule'
1151 ModuleNotFoundError: No module named 'somebogusmodule' (py36 !)
1152 exception from second failed import attempt:
1149 exception from second failed import attempt:
1153 Traceback (most recent call last):
1150 Traceback (most recent call last):
1154 ImportError: No module named 'somebogusmodule' (no-py36 !)
1151 ModuleNotFoundError: No module named 'somebogusmodule'
1155 ModuleNotFoundError: No module named 'somebogusmodule' (py36 !)
1156 Traceback (most recent call last):
1152 Traceback (most recent call last):
1157 ImportError: No module named 'hgext_importfail' (no-py36 !)
1153 ModuleNotFoundError: No module named 'hgext_importfail'
1158 ModuleNotFoundError: No module named 'hgext_importfail' (py36 !)
1159 Traceback (most recent call last):
1154 Traceback (most recent call last):
1160 ImportError: No module named 'somebogusmodule' (no-py36 !)
1155 ModuleNotFoundError: No module named 'somebogusmodule'
1161 ModuleNotFoundError: No module named 'somebogusmodule' (py36 !)
1162 Traceback (most recent call last):
1156 Traceback (most recent call last):
1163 ImportError: No module named 'hgext_importfail' (no-py36 !)
1157 ModuleNotFoundError: No module named 'hgext_importfail'
1164 ModuleNotFoundError: No module named 'hgext_importfail' (py36 !)
1165 Traceback (most recent call last):
1158 Traceback (most recent call last):
1166 raise error.HookLoadError( (py38 !)
1159 raise error.HookLoadError( (py38 !)
1167 mercurial.error.HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed
1160 mercurial.error.HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed
1168 abort: precommit.importfail hook is invalid: import of "importfail" failed
1161 abort: precommit.importfail hook is invalid: import of "importfail" failed
1169
1162
1170 Issue1827: Hooks Update & Commit not completely post operation
1163 Issue1827: Hooks Update & Commit not completely post operation
1171
1164
1172 commit and update hooks should run after command completion. The largefiles
1165 commit and update hooks should run after command completion. The largefiles
1173 use demonstrates a recursive wlock, showing the hook doesn't run until the
1166 use demonstrates a recursive wlock, showing the hook doesn't run until the
1174 final release (and dirstate flush).
1167 final release (and dirstate flush).
1175
1168
1176 $ echo '[hooks]' > .hg/hgrc
1169 $ echo '[hooks]' > .hg/hgrc
1177 $ echo 'commit = hg id' >> .hg/hgrc
1170 $ echo 'commit = hg id' >> .hg/hgrc
1178 $ echo 'update = hg id' >> .hg/hgrc
1171 $ echo 'update = hg id' >> .hg/hgrc
1179 $ echo bb > a
1172 $ echo bb > a
1180 $ hg ci -ma
1173 $ hg ci -ma
1181 223eafe2750c tip
1174 223eafe2750c tip
1182 $ hg up 0 --config extensions.largefiles=
1175 $ hg up 0 --config extensions.largefiles=
1183 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
1176 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
1184 cb9a9f314b8b
1177 cb9a9f314b8b
1185 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1178 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1186
1179
1187 make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui
1180 make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui
1188 that is passed to pre/post hooks
1181 that is passed to pre/post hooks
1189
1182
1190 $ echo '[hooks]' > .hg/hgrc
1183 $ echo '[hooks]' > .hg/hgrc
1191 $ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc
1184 $ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc
1192 $ hg id
1185 $ hg id
1193 cb9a9f314b8b
1186 cb9a9f314b8b
1194 $ hg id --verbose
1187 $ hg id --verbose
1195 calling hook pre-identify: hooktests.verbosehook
1188 calling hook pre-identify: hooktests.verbosehook
1196 verbose output from hook
1189 verbose output from hook
1197 cb9a9f314b8b
1190 cb9a9f314b8b
1198
1191
1199 Ensure hooks can be prioritized
1192 Ensure hooks can be prioritized
1200
1193
1201 $ echo '[hooks]' > .hg/hgrc
1194 $ echo '[hooks]' > .hg/hgrc
1202 $ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc
1195 $ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc
1203 $ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc
1196 $ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc
1204 $ echo 'priority.pre-identify.b = 1' >> .hg/hgrc
1197 $ echo 'priority.pre-identify.b = 1' >> .hg/hgrc
1205 $ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc
1198 $ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc
1206 $ hg id --verbose
1199 $ hg id --verbose
1207 calling hook pre-identify.b: hooktests.verbosehook
1200 calling hook pre-identify.b: hooktests.verbosehook
1208 verbose output from hook
1201 verbose output from hook
1209 calling hook pre-identify.a: hooktests.verbosehook
1202 calling hook pre-identify.a: hooktests.verbosehook
1210 verbose output from hook
1203 verbose output from hook
1211 calling hook pre-identify.c: hooktests.verbosehook
1204 calling hook pre-identify.c: hooktests.verbosehook
1212 verbose output from hook
1205 verbose output from hook
1213 cb9a9f314b8b
1206 cb9a9f314b8b
1214
1207
1215 new tags must be visible in pretxncommit (issue3210)
1208 new tags must be visible in pretxncommit (issue3210)
1216
1209
1217 $ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc
1210 $ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc
1218 $ hg tag -f foo
1211 $ hg tag -f foo
1219 [a, foo, tip]
1212 [a, foo, tip]
1220
1213
1221 post-init hooks must not crash (issue4983)
1214 post-init hooks must not crash (issue4983)
1222 This also creates the `to` repo for the next test block.
1215 This also creates the `to` repo for the next test block.
1223
1216
1224 $ cd ..
1217 $ cd ..
1225 $ cat << EOF >> hgrc-with-post-init-hook
1218 $ cat << EOF >> hgrc-with-post-init-hook
1226 > [hooks]
1219 > [hooks]
1227 > post-init = sh -c "printenv.py --line post-init"
1220 > post-init = sh -c "printenv.py --line post-init"
1228 > EOF
1221 > EOF
1229 $ HGRCPATH=hgrc-with-post-init-hook hg init to
1222 $ HGRCPATH=hgrc-with-post-init-hook hg init to
1230 post-init hook: HG_ARGS=init to
1223 post-init hook: HG_ARGS=init to
1231 HG_HOOKNAME=post-init
1224 HG_HOOKNAME=post-init
1232 HG_HOOKTYPE=post-init
1225 HG_HOOKTYPE=post-init
1233 HG_OPTS={'insecure': None, 'remotecmd': '', 'ssh': ''}
1226 HG_OPTS={'insecure': None, 'remotecmd': '', 'ssh': ''}
1234 HG_PATS=['to']
1227 HG_PATS=['to']
1235 HG_RESULT=0
1228 HG_RESULT=0
1236
1229
1237
1230
1238 new commits must be visible in pretxnchangegroup (issue3428)
1231 new commits must be visible in pretxnchangegroup (issue3428)
1239
1232
1240 $ echo '[hooks]' >> to/.hg/hgrc
1233 $ echo '[hooks]' >> to/.hg/hgrc
1241 $ echo 'prechangegroup = hg --traceback tip' >> to/.hg/hgrc
1234 $ echo 'prechangegroup = hg --traceback tip' >> to/.hg/hgrc
1242 $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc
1235 $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc
1243 $ echo a >> to/a
1236 $ echo a >> to/a
1244 $ hg --cwd to ci -Ama
1237 $ hg --cwd to ci -Ama
1245 adding a
1238 adding a
1246 $ hg clone to from
1239 $ hg clone to from
1247 updating to branch default
1240 updating to branch default
1248 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1241 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1249 $ echo aa >> from/a
1242 $ echo aa >> from/a
1250 $ hg --cwd from ci -mb
1243 $ hg --cwd from ci -mb
1251 $ hg --cwd from push
1244 $ hg --cwd from push
1252 pushing to $TESTTMP/to
1245 pushing to $TESTTMP/to
1253 searching for changes
1246 searching for changes
1254 changeset: 0:cb9a9f314b8b
1247 changeset: 0:cb9a9f314b8b
1255 tag: tip
1248 tag: tip
1256 user: test
1249 user: test
1257 date: Thu Jan 01 00:00:00 1970 +0000
1250 date: Thu Jan 01 00:00:00 1970 +0000
1258 summary: a
1251 summary: a
1259
1252
1260 adding changesets
1253 adding changesets
1261 adding manifests
1254 adding manifests
1262 adding file changes
1255 adding file changes
1263 changeset: 1:9836a07b9b9d
1256 changeset: 1:9836a07b9b9d
1264 tag: tip
1257 tag: tip
1265 user: test
1258 user: test
1266 date: Thu Jan 01 00:00:00 1970 +0000
1259 date: Thu Jan 01 00:00:00 1970 +0000
1267 summary: b
1260 summary: b
1268
1261
1269 added 1 changesets with 1 changes to 1 files
1262 added 1 changesets with 1 changes to 1 files
1270
1263
1271 pretxnclose hook failure should abort the transaction
1264 pretxnclose hook failure should abort the transaction
1272
1265
1273 $ hg init txnfailure
1266 $ hg init txnfailure
1274 $ cd txnfailure
1267 $ cd txnfailure
1275 $ touch a && hg commit -Aqm a
1268 $ touch a && hg commit -Aqm a
1276 $ cat >> .hg/hgrc <<EOF
1269 $ cat >> .hg/hgrc <<EOF
1277 > [hooks]
1270 > [hooks]
1278 > pretxnclose.error = exit 1
1271 > pretxnclose.error = exit 1
1279 > EOF
1272 > EOF
1280 $ hg strip -r 0 --config extensions.strip=
1273 $ hg strip -r 0 --config extensions.strip=
1281 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1274 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1282 saved backup bundle to * (glob)
1275 saved backup bundle to * (glob)
1283 transaction abort!
1276 transaction abort!
1284 rollback completed
1277 rollback completed
1285 strip failed, backup bundle stored in * (glob)
1278 strip failed, backup bundle stored in * (glob)
1286 abort: pretxnclose.error hook exited with status 1
1279 abort: pretxnclose.error hook exited with status 1
1287 [40]
1280 [40]
1288 $ hg recover
1281 $ hg recover
1289 no interrupted transaction available
1282 no interrupted transaction available
1290 [1]
1283 [1]
1291 $ cd ..
1284 $ cd ..
1292
1285
1293 check whether HG_PENDING makes pending changes only in related
1286 check whether HG_PENDING makes pending changes only in related
1294 repositories visible to an external hook.
1287 repositories visible to an external hook.
1295
1288
1296 (emulate a transaction running concurrently by copied
1289 (emulate a transaction running concurrently by copied
1297 .hg/store/00changelog.i.a in subsequent test)
1290 .hg/store/00changelog.i.a in subsequent test)
1298
1291
1299 $ cat > $TESTTMP/savepending.sh <<EOF
1292 $ cat > $TESTTMP/savepending.sh <<EOF
1300 > cp .hg/store/00changelog.i.a .hg/store/00changelog.i.a.saved
1293 > cp .hg/store/00changelog.i.a .hg/store/00changelog.i.a.saved
1301 > exit 1 # to avoid adding new revision for subsequent tests
1294 > exit 1 # to avoid adding new revision for subsequent tests
1302 > EOF
1295 > EOF
1303 $ cd a
1296 $ cd a
1304 $ hg tip -q
1297 $ hg tip -q
1305 4:539e4b31b6dc
1298 4:539e4b31b6dc
1306 $ hg --config hooks.pretxnclose="sh $TESTTMP/savepending.sh" commit -m "invisible"
1299 $ hg --config hooks.pretxnclose="sh $TESTTMP/savepending.sh" commit -m "invisible"
1307 transaction abort!
1300 transaction abort!
1308 rollback completed
1301 rollback completed
1309 abort: pretxnclose hook exited with status 1
1302 abort: pretxnclose hook exited with status 1
1310 [40]
1303 [40]
1311 $ cp .hg/store/00changelog.i.a.saved .hg/store/00changelog.i.a
1304 $ cp .hg/store/00changelog.i.a.saved .hg/store/00changelog.i.a
1312
1305
1313 (check (in)visibility of new changeset while transaction running in
1306 (check (in)visibility of new changeset while transaction running in
1314 repo)
1307 repo)
1315
1308
1316 $ cat > $TESTTMP/checkpending.sh <<EOF
1309 $ cat > $TESTTMP/checkpending.sh <<EOF
1317 > echo '@a'
1310 > echo '@a'
1318 > hg -R "$TESTTMP/a" tip -q
1311 > hg -R "$TESTTMP/a" tip -q
1319 > echo '@a/nested'
1312 > echo '@a/nested'
1320 > hg -R "$TESTTMP/a/nested" tip -q
1313 > hg -R "$TESTTMP/a/nested" tip -q
1321 > exit 1 # to avoid adding new revision for subsequent tests
1314 > exit 1 # to avoid adding new revision for subsequent tests
1322 > EOF
1315 > EOF
1323 $ hg init nested
1316 $ hg init nested
1324 $ cd nested
1317 $ cd nested
1325 $ echo a > a
1318 $ echo a > a
1326 $ hg add a
1319 $ hg add a
1327 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkpending.sh" commit -m '#0'
1320 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkpending.sh" commit -m '#0'
1328 @a
1321 @a
1329 4:539e4b31b6dc
1322 4:539e4b31b6dc
1330 @a/nested
1323 @a/nested
1331 0:bf5e395ced2c
1324 0:bf5e395ced2c
1332 transaction abort!
1325 transaction abort!
1333 rollback completed
1326 rollback completed
1334 abort: pretxnclose hook exited with status 1
1327 abort: pretxnclose hook exited with status 1
1335 [40]
1328 [40]
1336
1329
1337 Hook from untrusted hgrc are reported as failure
1330 Hook from untrusted hgrc are reported as failure
1338 ================================================
1331 ================================================
1339
1332
1340 $ cat << EOF > $TESTTMP/untrusted.py
1333 $ cat << EOF > $TESTTMP/untrusted.py
1341 > from mercurial import scmutil, util
1334 > from mercurial import scmutil, util
1342 > def uisetup(ui):
1335 > def uisetup(ui):
1343 > class untrustedui(ui.__class__):
1336 > class untrustedui(ui.__class__):
1344 > def _trusted(self, fp, f):
1337 > def _trusted(self, fp, f):
1345 > if util.normpath(fp.name).endswith(b'untrusted/.hg/hgrc'):
1338 > if util.normpath(fp.name).endswith(b'untrusted/.hg/hgrc'):
1346 > return False
1339 > return False
1347 > return super(untrustedui, self)._trusted(fp, f)
1340 > return super(untrustedui, self)._trusted(fp, f)
1348 > ui.__class__ = untrustedui
1341 > ui.__class__ = untrustedui
1349 > EOF
1342 > EOF
1350 $ cat << EOF >> $HGRCPATH
1343 $ cat << EOF >> $HGRCPATH
1351 > [extensions]
1344 > [extensions]
1352 > untrusted=$TESTTMP/untrusted.py
1345 > untrusted=$TESTTMP/untrusted.py
1353 > EOF
1346 > EOF
1354 $ hg init untrusted
1347 $ hg init untrusted
1355 $ cd untrusted
1348 $ cd untrusted
1356
1349
1357 Non-blocking hook
1350 Non-blocking hook
1358 -----------------
1351 -----------------
1359
1352
1360 $ cat << EOF >> .hg/hgrc
1353 $ cat << EOF >> .hg/hgrc
1361 > [hooks]
1354 > [hooks]
1362 > txnclose.testing=echo txnclose hook called
1355 > txnclose.testing=echo txnclose hook called
1363 > EOF
1356 > EOF
1364 $ touch a && hg commit -Aqm a
1357 $ touch a && hg commit -Aqm a
1365 warning: untrusted hook txnclose.testing not executed
1358 warning: untrusted hook txnclose.testing not executed
1366 $ hg log
1359 $ hg log
1367 changeset: 0:3903775176ed
1360 changeset: 0:3903775176ed
1368 tag: tip
1361 tag: tip
1369 user: test
1362 user: test
1370 date: Thu Jan 01 00:00:00 1970 +0000
1363 date: Thu Jan 01 00:00:00 1970 +0000
1371 summary: a
1364 summary: a
1372
1365
1373
1366
1374 Non-blocking hook
1367 Non-blocking hook
1375 -----------------
1368 -----------------
1376
1369
1377 $ cat << EOF >> .hg/hgrc
1370 $ cat << EOF >> .hg/hgrc
1378 > [hooks]
1371 > [hooks]
1379 > pretxnclose.testing=echo pre-txnclose hook called
1372 > pretxnclose.testing=echo pre-txnclose hook called
1380 > EOF
1373 > EOF
1381 $ touch b && hg commit -Aqm a
1374 $ touch b && hg commit -Aqm a
1382 transaction abort!
1375 transaction abort!
1383 rollback completed
1376 rollback completed
1384 abort: untrusted hook pretxnclose.testing not executed
1377 abort: untrusted hook pretxnclose.testing not executed
1385 (see 'hg help config.trusted')
1378 (see 'hg help config.trusted')
1386 [40]
1379 [40]
1387 $ hg log
1380 $ hg log
1388 changeset: 0:3903775176ed
1381 changeset: 0:3903775176ed
1389 tag: tip
1382 tag: tip
1390 user: test
1383 user: test
1391 date: Thu Jan 01 00:00:00 1970 +0000
1384 date: Thu Jan 01 00:00:00 1970 +0000
1392 summary: a
1385 summary: a
1393
1386
1394
1387
1395 unsetup the test
1388 unsetup the test
1396 ----------------
1389 ----------------
1397
1390
1398 # touch the file to unconfuse chg with a diffrent mtime
1391 # touch the file to unconfuse chg with a diffrent mtime
1399 $ sleep 1
1392 $ sleep 1
1400 $ touch $TESTTMP/untrusted.py
1393 $ touch $TESTTMP/untrusted.py
1401 $ cat << EOF >> $HGRCPATH
1394 $ cat << EOF >> $HGRCPATH
1402 > [extensions]
1395 > [extensions]
1403 > untrusted=!
1396 > untrusted=!
1404 > EOF
1397 > EOF
1405
1398
1406 HGPLAIN setting in hooks
1399 HGPLAIN setting in hooks
1407 ========================
1400 ========================
1408
1401
1409 $ cat << EOF >> .hg/hgrc
1402 $ cat << EOF >> .hg/hgrc
1410 > [hooks]
1403 > [hooks]
1411 > pre-version.testing-default=sh -c "echo '### default ###' plain: \${HGPLAIN:-'<unset>'}"
1404 > pre-version.testing-default=sh -c "echo '### default ###' plain: \${HGPLAIN:-'<unset>'}"
1412 > pre-version.testing-yes=sh -c "echo '### yes #######' plain: \${HGPLAIN:-'<unset>'}"
1405 > pre-version.testing-yes=sh -c "echo '### yes #######' plain: \${HGPLAIN:-'<unset>'}"
1413 > pre-version.testing-yes:run-with-plain=yes
1406 > pre-version.testing-yes:run-with-plain=yes
1414 > pre-version.testing-no=sh -c "echo '### no ########' plain: \${HGPLAIN:-'<unset>'}"
1407 > pre-version.testing-no=sh -c "echo '### no ########' plain: \${HGPLAIN:-'<unset>'}"
1415 > pre-version.testing-no:run-with-plain=no
1408 > pre-version.testing-no:run-with-plain=no
1416 > pre-version.testing-auto=sh -c "echo '### auto ######' plain: \${HGPLAIN:-'<unset>'}"
1409 > pre-version.testing-auto=sh -c "echo '### auto ######' plain: \${HGPLAIN:-'<unset>'}"
1417 > pre-version.testing-auto:run-with-plain=auto
1410 > pre-version.testing-auto:run-with-plain=auto
1418 > EOF
1411 > EOF
1419
1412
1420 $ (unset HGPLAIN; hg version --quiet)
1413 $ (unset HGPLAIN; hg version --quiet)
1421 ### default ### plain: 1
1414 ### default ### plain: 1
1422 ### yes ####### plain: 1
1415 ### yes ####### plain: 1
1423 ### no ######## plain: <unset>
1416 ### no ######## plain: <unset>
1424 ### auto ###### plain: <unset>
1417 ### auto ###### plain: <unset>
1425 Mercurial Distributed SCM (*) (glob)
1418 Mercurial Distributed SCM (*) (glob)
1426
1419
1427 $ HGPLAIN=1 hg version --quiet
1420 $ HGPLAIN=1 hg version --quiet
1428 ### default ### plain: 1
1421 ### default ### plain: 1
1429 ### yes ####### plain: 1
1422 ### yes ####### plain: 1
1430 ### no ######## plain: <unset>
1423 ### no ######## plain: <unset>
1431 ### auto ###### plain: 1
1424 ### auto ###### plain: 1
1432 Mercurial Distributed SCM (*) (glob)
1425 Mercurial Distributed SCM (*) (glob)
General Comments 0
You need to be logged in to leave comments. Login now