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