Show More
@@ -1,875 +1,869 | |||
|
1 | 1 | commit hooks can see env vars |
|
2 | 2 | (and post-transaction one are run unlocked) |
|
3 | 3 | |
|
4 | $ cat << EOF >> $HGRCPATH | |
|
5 | > [experimental] | |
|
6 | > # drop me once bundle2 is the default, | |
|
7 | > # added to get test change early. | |
|
8 | > bundle2-exp = True | |
|
9 | > EOF | |
|
10 | 4 | |
|
11 | 5 | $ cat > $TESTTMP/txnabort.checkargs.py <<EOF |
|
12 | 6 | > def showargs(ui, repo, hooktype, **kwargs): |
|
13 | 7 | > ui.write('%s python hook: %s\n' % (hooktype, ','.join(sorted(kwargs)))) |
|
14 | 8 | > EOF |
|
15 | 9 | |
|
16 | 10 | $ hg init a |
|
17 | 11 | $ cd a |
|
18 | 12 | $ cat > .hg/hgrc <<EOF |
|
19 | 13 | > [hooks] |
|
20 | 14 | > commit = sh -c "HG_LOCAL= HG_TAG= printenv.py commit" |
|
21 | 15 | > commit.b = sh -c "HG_LOCAL= HG_TAG= printenv.py commit.b" |
|
22 | 16 | > precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= printenv.py precommit" |
|
23 | 17 | > pretxncommit = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxncommit" |
|
24 | 18 | > pretxncommit.tip = hg -q tip |
|
25 | 19 | > pre-identify = printenv.py pre-identify 1 |
|
26 | 20 | > pre-cat = printenv.py pre-cat |
|
27 | 21 | > post-cat = printenv.py post-cat |
|
28 | 22 | > pretxnopen = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnopen" |
|
29 | 23 | > pretxnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnclose" |
|
30 | 24 | > txnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py txnclose" |
|
31 | 25 | > txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs |
|
32 | 26 | > txnabort.1 = sh -c "HG_LOCAL= HG_TAG= printenv.py txnabort" |
|
33 | 27 | > txnclose.checklock = sh -c "hg debuglock > /dev/null" |
|
34 | 28 | > EOF |
|
35 | 29 | $ echo a > a |
|
36 | 30 | $ hg add a |
|
37 | 31 | $ hg commit -m a |
|
38 | 32 | precommit hook: HG_PARENT1=0000000000000000000000000000000000000000 |
|
39 | 33 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
40 | 34 | pretxncommit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$TESTTMP/a |
|
41 | 35 | 0:cb9a9f314b8b |
|
42 | 36 | pretxnclose hook: HG_PENDING=$TESTTMP/a HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
43 | 37 | txnclose hook: HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
44 | 38 | commit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 |
|
45 | 39 | commit.b hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 |
|
46 | 40 | |
|
47 | 41 | $ hg clone . ../b |
|
48 | 42 | updating to branch default |
|
49 | 43 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
50 | 44 | $ cd ../b |
|
51 | 45 | |
|
52 | 46 | changegroup hooks can see env vars |
|
53 | 47 | |
|
54 | 48 | $ cat > .hg/hgrc <<EOF |
|
55 | 49 | > [hooks] |
|
56 | 50 | > prechangegroup = printenv.py prechangegroup |
|
57 | 51 | > changegroup = printenv.py changegroup |
|
58 | 52 | > incoming = printenv.py incoming |
|
59 | 53 | > EOF |
|
60 | 54 | |
|
61 | 55 | pretxncommit and commit hooks can see both parents of merge |
|
62 | 56 | |
|
63 | 57 | $ cd ../a |
|
64 | 58 | $ echo b >> a |
|
65 | 59 | $ hg commit -m a1 -d "1 0" |
|
66 | 60 | precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b |
|
67 | 61 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
68 | 62 | pretxncommit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a |
|
69 | 63 | 1:ab228980c14d |
|
70 | 64 | pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
71 | 65 | txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
72 | 66 | commit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b |
|
73 | 67 | commit.b hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b |
|
74 | 68 | $ hg update -C 0 |
|
75 | 69 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
76 | 70 | $ echo b > b |
|
77 | 71 | $ hg add b |
|
78 | 72 | $ hg commit -m b -d '1 0' |
|
79 | 73 | precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b |
|
80 | 74 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
81 | 75 | pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a |
|
82 | 76 | 2:ee9deb46ab31 |
|
83 | 77 | pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
84 | 78 | created new head |
|
85 | 79 | txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
86 | 80 | commit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b |
|
87 | 81 | commit.b hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b |
|
88 | 82 | $ hg merge 1 |
|
89 | 83 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
90 | 84 | (branch merge, don't forget to commit) |
|
91 | 85 | $ hg commit -m merge -d '2 0' |
|
92 | 86 | precommit hook: HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd |
|
93 | 87 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
94 | 88 | pretxncommit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$TESTTMP/a |
|
95 | 89 | 3:07f3376c1e65 |
|
96 | 90 | pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
97 | 91 | txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
98 | 92 | commit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd |
|
99 | 93 | commit.b hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd |
|
100 | 94 | |
|
101 | 95 | test generic hooks |
|
102 | 96 | |
|
103 | 97 | $ hg id |
|
104 | 98 | pre-identify hook: HG_ARGS=id HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'insecure': None, 'num': None, 'remotecmd': '', 'rev': '', 'ssh': '', 'tags': None} HG_PATS=[] |
|
105 | 99 | abort: pre-identify hook exited with status 1 |
|
106 | 100 | [255] |
|
107 | 101 | $ hg cat b |
|
108 | 102 | pre-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b'] |
|
109 | 103 | b |
|
110 | 104 | post-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b'] HG_RESULT=0 |
|
111 | 105 | |
|
112 | 106 | $ cd ../b |
|
113 | 107 | $ hg pull ../a |
|
114 | 108 | pulling from ../a |
|
115 | 109 | searching for changes |
|
116 | 110 | prechangegroup hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob) |
|
117 | 111 | adding changesets |
|
118 | 112 | adding manifests |
|
119 | 113 | adding file changes |
|
120 | 114 | added 3 changesets with 2 changes to 2 files |
|
121 | 115 | changegroup hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_NODE_LAST=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob) |
|
122 | 116 | incoming hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob) |
|
123 | 117 | incoming hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob) |
|
124 | 118 | incoming hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob) |
|
125 | 119 | (run 'hg update' to get a working copy) |
|
126 | 120 | |
|
127 | 121 | tag hooks can see env vars |
|
128 | 122 | |
|
129 | 123 | $ cd ../a |
|
130 | 124 | $ cat >> .hg/hgrc <<EOF |
|
131 | 125 | > pretag = printenv.py pretag |
|
132 | 126 | > tag = sh -c "HG_PARENT1= HG_PARENT2= printenv.py tag" |
|
133 | 127 | > EOF |
|
134 | 128 | $ hg tag -d '3 0' a |
|
135 | 129 | pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a |
|
136 | 130 | precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 |
|
137 | 131 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
138 | 132 | pretxncommit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$TESTTMP/a |
|
139 | 133 | 4:539e4b31b6dc |
|
140 | 134 | pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
141 | 135 | tag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a |
|
142 | 136 | txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
143 | 137 | commit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 |
|
144 | 138 | commit.b hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 |
|
145 | 139 | $ hg tag -l la |
|
146 | 140 | pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la |
|
147 | 141 | tag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la |
|
148 | 142 | |
|
149 | 143 | pretag hook can forbid tagging |
|
150 | 144 | |
|
151 | 145 | $ echo "pretag.forbid = printenv.py pretag.forbid 1" >> .hg/hgrc |
|
152 | 146 | $ hg tag -d '4 0' fa |
|
153 | 147 | pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa |
|
154 | 148 | pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa |
|
155 | 149 | abort: pretag.forbid hook exited with status 1 |
|
156 | 150 | [255] |
|
157 | 151 | $ hg tag -l fla |
|
158 | 152 | pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla |
|
159 | 153 | pretag.forbid hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla |
|
160 | 154 | abort: pretag.forbid hook exited with status 1 |
|
161 | 155 | [255] |
|
162 | 156 | |
|
163 | 157 | pretxncommit hook can see changeset, can roll back txn, changeset no |
|
164 | 158 | more there after |
|
165 | 159 | |
|
166 | 160 | $ echo "pretxncommit.forbid0 = hg tip -q" >> .hg/hgrc |
|
167 | 161 | $ echo "pretxncommit.forbid1 = printenv.py pretxncommit.forbid 1" >> .hg/hgrc |
|
168 | 162 | $ echo z > z |
|
169 | 163 | $ hg add z |
|
170 | 164 | $ hg -q tip |
|
171 | 165 | 4:539e4b31b6dc |
|
172 | 166 | $ hg commit -m 'fail' -d '4 0' |
|
173 | 167 | precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 |
|
174 | 168 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
175 | 169 | pretxncommit hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a |
|
176 | 170 | 5:6f611f8018c1 |
|
177 | 171 | 5:6f611f8018c1 |
|
178 | 172 | pretxncommit.forbid hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a |
|
179 | 173 | transaction abort! |
|
180 | 174 | txnabort python hook: txnid,txnname |
|
181 | 175 | txnabort hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) |
|
182 | 176 | rollback completed |
|
183 | 177 | abort: pretxncommit.forbid1 hook exited with status 1 |
|
184 | 178 | [255] |
|
185 | 179 | $ hg -q tip |
|
186 | 180 | 4:539e4b31b6dc |
|
187 | 181 | |
|
188 | 182 | (Check that no 'changelog.i.a' file were left behind) |
|
189 | 183 | |
|
190 | 184 | $ ls -1 .hg/store/ |
|
191 | 185 | 00changelog.i |
|
192 | 186 | 00manifest.i |
|
193 | 187 | data |
|
194 | 188 | fncache |
|
195 | 189 | journal.phaseroots |
|
196 | 190 | phaseroots |
|
197 | 191 | undo |
|
198 | 192 | undo.backup.fncache |
|
199 | 193 | undo.backupfiles |
|
200 | 194 | undo.phaseroots |
|
201 | 195 | |
|
202 | 196 | |
|
203 | 197 | precommit hook can prevent commit |
|
204 | 198 | |
|
205 | 199 | $ echo "precommit.forbid = printenv.py precommit.forbid 1" >> .hg/hgrc |
|
206 | 200 | $ hg commit -m 'fail' -d '4 0' |
|
207 | 201 | precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 |
|
208 | 202 | precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 |
|
209 | 203 | abort: precommit.forbid hook exited with status 1 |
|
210 | 204 | [255] |
|
211 | 205 | $ hg -q tip |
|
212 | 206 | 4:539e4b31b6dc |
|
213 | 207 | |
|
214 | 208 | preupdate hook can prevent update |
|
215 | 209 | |
|
216 | 210 | $ echo "preupdate = printenv.py preupdate" >> .hg/hgrc |
|
217 | 211 | $ hg update 1 |
|
218 | 212 | preupdate hook: HG_PARENT1=ab228980c14d |
|
219 | 213 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
220 | 214 | |
|
221 | 215 | update hook |
|
222 | 216 | |
|
223 | 217 | $ echo "update = printenv.py update" >> .hg/hgrc |
|
224 | 218 | $ hg update |
|
225 | 219 | preupdate hook: HG_PARENT1=539e4b31b6dc |
|
226 | 220 | update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc |
|
227 | 221 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
228 | 222 | |
|
229 | 223 | pushkey hook |
|
230 | 224 | |
|
231 | 225 | $ echo "pushkey = printenv.py pushkey" >> .hg/hgrc |
|
232 | 226 | $ cd ../b |
|
233 | 227 | $ hg bookmark -r null foo |
|
234 | 228 | $ hg push -B foo ../a |
|
235 | 229 | pushing to ../a |
|
236 | 230 | searching for changes |
|
237 | 231 | no changes found |
|
238 | 232 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=push (glob) |
|
239 | 233 | pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_PENDING=$TESTTMP/a HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=push (glob) |
|
240 | 234 | pushkey hook: HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1 |
|
241 | 235 | txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=push (glob) |
|
242 | 236 | exporting bookmark foo |
|
243 | 237 | [1] |
|
244 | 238 | $ cd ../a |
|
245 | 239 | |
|
246 | 240 | listkeys hook |
|
247 | 241 | |
|
248 | 242 | $ echo "listkeys = printenv.py listkeys" >> .hg/hgrc |
|
249 | 243 | $ hg bookmark -r null bar |
|
250 | 244 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob) |
|
251 | 245 | pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob) |
|
252 | 246 | txnclose hook: HG_BOOKMARK_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob) |
|
253 | 247 | $ cd ../b |
|
254 | 248 | $ hg pull -B bar ../a |
|
255 | 249 | pulling from ../a |
|
256 | 250 | listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'} |
|
257 | 251 | no changes found |
|
258 | 252 | listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'} |
|
259 | 253 | adding remote bookmark bar |
|
260 | 254 | $ cd ../a |
|
261 | 255 | |
|
262 | 256 | test that prepushkey can prevent incoming keys |
|
263 | 257 | |
|
264 | 258 | $ echo "prepushkey = printenv.py prepushkey.forbid 1" >> .hg/hgrc |
|
265 | 259 | $ cd ../b |
|
266 | 260 | $ hg bookmark -r null baz |
|
267 | 261 | $ hg push -B baz ../a |
|
268 | 262 | pushing to ../a |
|
269 | 263 | searching for changes |
|
270 | 264 | listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'} |
|
271 | 265 | listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'} |
|
272 | 266 | no changes found |
|
273 | 267 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=push (glob) |
|
274 | 268 | prepushkey.forbid hook: HG_BUNDLE2=1 HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_SOURCE=push HG_TXNID=TXN:* HG_URL=push (glob) |
|
275 | 269 | pushkey-abort: prepushkey hook exited with status 1 |
|
276 | 270 | abort: exporting bookmark baz failed! |
|
277 | 271 | [255] |
|
278 | 272 | $ cd ../a |
|
279 | 273 | |
|
280 | 274 | test that prelistkeys can prevent listing keys |
|
281 | 275 | |
|
282 | 276 | $ echo "prelistkeys = printenv.py prelistkeys.forbid 1" >> .hg/hgrc |
|
283 | 277 | $ hg bookmark -r null quux |
|
284 | 278 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob) |
|
285 | 279 | pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob) |
|
286 | 280 | txnclose hook: HG_BOOKMARK_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob) |
|
287 | 281 | $ cd ../b |
|
288 | 282 | $ hg pull -B quux ../a |
|
289 | 283 | pulling from ../a |
|
290 | 284 | prelistkeys.forbid hook: HG_NAMESPACE=bookmarks |
|
291 | 285 | abort: prelistkeys hook exited with status 1 |
|
292 | 286 | [255] |
|
293 | 287 | $ cd ../a |
|
294 | 288 | $ rm .hg/hgrc |
|
295 | 289 | |
|
296 | 290 | prechangegroup hook can prevent incoming changes |
|
297 | 291 | |
|
298 | 292 | $ cd ../b |
|
299 | 293 | $ hg -q tip |
|
300 | 294 | 3:07f3376c1e65 |
|
301 | 295 | $ cat > .hg/hgrc <<EOF |
|
302 | 296 | > [hooks] |
|
303 | 297 | > prechangegroup.forbid = printenv.py prechangegroup.forbid 1 |
|
304 | 298 | > EOF |
|
305 | 299 | $ hg pull ../a |
|
306 | 300 | pulling from ../a |
|
307 | 301 | searching for changes |
|
308 | 302 | prechangegroup.forbid hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob) |
|
309 | 303 | abort: prechangegroup.forbid hook exited with status 1 |
|
310 | 304 | [255] |
|
311 | 305 | |
|
312 | 306 | pretxnchangegroup hook can see incoming changes, can roll back txn, |
|
313 | 307 | incoming changes no longer there after |
|
314 | 308 | |
|
315 | 309 | $ cat > .hg/hgrc <<EOF |
|
316 | 310 | > [hooks] |
|
317 | 311 | > pretxnchangegroup.forbid0 = hg tip -q |
|
318 | 312 | > pretxnchangegroup.forbid1 = printenv.py pretxnchangegroup.forbid 1 |
|
319 | 313 | > EOF |
|
320 | 314 | $ hg pull ../a |
|
321 | 315 | pulling from ../a |
|
322 | 316 | searching for changes |
|
323 | 317 | adding changesets |
|
324 | 318 | adding manifests |
|
325 | 319 | adding file changes |
|
326 | 320 | added 1 changesets with 1 changes to 1 files |
|
327 | 321 | 4:539e4b31b6dc |
|
328 | 322 | pretxnchangegroup.forbid hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_NODE_LAST=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/b HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob) |
|
329 | 323 | transaction abort! |
|
330 | 324 | rollback completed |
|
331 | 325 | abort: pretxnchangegroup.forbid1 hook exited with status 1 |
|
332 | 326 | [255] |
|
333 | 327 | $ hg -q tip |
|
334 | 328 | 3:07f3376c1e65 |
|
335 | 329 | |
|
336 | 330 | outgoing hooks can see env vars |
|
337 | 331 | |
|
338 | 332 | $ rm .hg/hgrc |
|
339 | 333 | $ cat > ../a/.hg/hgrc <<EOF |
|
340 | 334 | > [hooks] |
|
341 | 335 | > preoutgoing = printenv.py preoutgoing |
|
342 | 336 | > outgoing = printenv.py outgoing |
|
343 | 337 | > EOF |
|
344 | 338 | $ hg pull ../a |
|
345 | 339 | pulling from ../a |
|
346 | 340 | searching for changes |
|
347 | 341 | preoutgoing hook: HG_SOURCE=pull |
|
348 | 342 | outgoing hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_SOURCE=pull |
|
349 | 343 | adding changesets |
|
350 | 344 | adding manifests |
|
351 | 345 | adding file changes |
|
352 | 346 | added 1 changesets with 1 changes to 1 files |
|
353 | 347 | adding remote bookmark quux |
|
354 | 348 | (run 'hg update' to get a working copy) |
|
355 | 349 | $ hg rollback |
|
356 | 350 | repository tip rolled back to revision 3 (undo pull) |
|
357 | 351 | |
|
358 | 352 | preoutgoing hook can prevent outgoing changes |
|
359 | 353 | |
|
360 | 354 | $ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> ../a/.hg/hgrc |
|
361 | 355 | $ hg pull ../a |
|
362 | 356 | pulling from ../a |
|
363 | 357 | searching for changes |
|
364 | 358 | preoutgoing hook: HG_SOURCE=pull |
|
365 | 359 | preoutgoing.forbid hook: HG_SOURCE=pull |
|
366 | 360 | abort: preoutgoing.forbid hook exited with status 1 |
|
367 | 361 | [255] |
|
368 | 362 | |
|
369 | 363 | outgoing hooks work for local clones |
|
370 | 364 | |
|
371 | 365 | $ cd .. |
|
372 | 366 | $ cat > a/.hg/hgrc <<EOF |
|
373 | 367 | > [hooks] |
|
374 | 368 | > preoutgoing = printenv.py preoutgoing |
|
375 | 369 | > outgoing = printenv.py outgoing |
|
376 | 370 | > EOF |
|
377 | 371 | $ hg clone a c |
|
378 | 372 | preoutgoing hook: HG_SOURCE=clone |
|
379 | 373 | outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone |
|
380 | 374 | updating to branch default |
|
381 | 375 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
382 | 376 | $ rm -rf c |
|
383 | 377 | |
|
384 | 378 | preoutgoing hook can prevent outgoing changes for local clones |
|
385 | 379 | |
|
386 | 380 | $ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> a/.hg/hgrc |
|
387 | 381 | $ hg clone a zzz |
|
388 | 382 | preoutgoing hook: HG_SOURCE=clone |
|
389 | 383 | preoutgoing.forbid hook: HG_SOURCE=clone |
|
390 | 384 | abort: preoutgoing.forbid hook exited with status 1 |
|
391 | 385 | [255] |
|
392 | 386 | |
|
393 | 387 | $ cd "$TESTTMP/b" |
|
394 | 388 | |
|
395 | 389 | $ cat > hooktests.py <<EOF |
|
396 | 390 | > from mercurial import error |
|
397 | 391 | > |
|
398 | 392 | > uncallable = 0 |
|
399 | 393 | > |
|
400 | 394 | > def printargs(args): |
|
401 | 395 | > args.pop('ui', None) |
|
402 | 396 | > args.pop('repo', None) |
|
403 | 397 | > a = list(args.items()) |
|
404 | 398 | > a.sort() |
|
405 | 399 | > print 'hook args:' |
|
406 | 400 | > for k, v in a: |
|
407 | 401 | > print ' ', k, v |
|
408 | 402 | > |
|
409 | 403 | > def passhook(**args): |
|
410 | 404 | > printargs(args) |
|
411 | 405 | > |
|
412 | 406 | > def failhook(**args): |
|
413 | 407 | > printargs(args) |
|
414 | 408 | > return True |
|
415 | 409 | > |
|
416 | 410 | > class LocalException(Exception): |
|
417 | 411 | > pass |
|
418 | 412 | > |
|
419 | 413 | > def raisehook(**args): |
|
420 | 414 | > raise LocalException('exception from hook') |
|
421 | 415 | > |
|
422 | 416 | > def aborthook(**args): |
|
423 | 417 | > raise error.Abort('raise abort from hook') |
|
424 | 418 | > |
|
425 | 419 | > def brokenhook(**args): |
|
426 | 420 | > return 1 + {} |
|
427 | 421 | > |
|
428 | 422 | > def verbosehook(ui, **args): |
|
429 | 423 | > ui.note('verbose output from hook\n') |
|
430 | 424 | > |
|
431 | 425 | > def printtags(ui, repo, **args): |
|
432 | 426 | > print sorted(repo.tags()) |
|
433 | 427 | > |
|
434 | 428 | > class container: |
|
435 | 429 | > unreachable = 1 |
|
436 | 430 | > EOF |
|
437 | 431 | |
|
438 | 432 | $ cat > syntaxerror.py << EOF |
|
439 | 433 | > (foo |
|
440 | 434 | > EOF |
|
441 | 435 | |
|
442 | 436 | test python hooks |
|
443 | 437 | |
|
444 | 438 | #if windows |
|
445 | 439 | $ PYTHONPATH="$TESTTMP/b;$PYTHONPATH" |
|
446 | 440 | #else |
|
447 | 441 | $ PYTHONPATH="$TESTTMP/b:$PYTHONPATH" |
|
448 | 442 | #endif |
|
449 | 443 | $ export PYTHONPATH |
|
450 | 444 | |
|
451 | 445 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
452 | 446 | $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc |
|
453 | 447 | $ hg pull ../a 2>&1 | grep 'raised an exception' |
|
454 | 448 | error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict' |
|
455 | 449 | |
|
456 | 450 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
457 | 451 | $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc |
|
458 | 452 | $ hg pull ../a 2>&1 | grep 'raised an exception' |
|
459 | 453 | error: preoutgoing.raise hook raised an exception: exception from hook |
|
460 | 454 | |
|
461 | 455 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
462 | 456 | $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc |
|
463 | 457 | $ hg pull ../a |
|
464 | 458 | pulling from ../a |
|
465 | 459 | searching for changes |
|
466 | 460 | error: preoutgoing.abort hook failed: raise abort from hook |
|
467 | 461 | abort: raise abort from hook |
|
468 | 462 | [255] |
|
469 | 463 | |
|
470 | 464 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
471 | 465 | $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc |
|
472 | 466 | $ hg pull ../a |
|
473 | 467 | pulling from ../a |
|
474 | 468 | searching for changes |
|
475 | 469 | hook args: |
|
476 | 470 | hooktype preoutgoing |
|
477 | 471 | source pull |
|
478 | 472 | abort: preoutgoing.fail hook failed |
|
479 | 473 | [255] |
|
480 | 474 | |
|
481 | 475 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
482 | 476 | $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc |
|
483 | 477 | $ hg pull ../a |
|
484 | 478 | pulling from ../a |
|
485 | 479 | searching for changes |
|
486 | 480 | abort: preoutgoing.uncallable hook is invalid: "hooktests.uncallable" is not callable |
|
487 | 481 | [255] |
|
488 | 482 | |
|
489 | 483 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
490 | 484 | $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc |
|
491 | 485 | $ hg pull ../a |
|
492 | 486 | pulling from ../a |
|
493 | 487 | searching for changes |
|
494 | 488 | abort: preoutgoing.nohook hook is invalid: "hooktests.nohook" is not defined |
|
495 | 489 | [255] |
|
496 | 490 | |
|
497 | 491 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
498 | 492 | $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc |
|
499 | 493 | $ hg pull ../a |
|
500 | 494 | pulling from ../a |
|
501 | 495 | searching for changes |
|
502 | 496 | abort: preoutgoing.nomodule hook is invalid: "nomodule" not in a module |
|
503 | 497 | [255] |
|
504 | 498 | |
|
505 | 499 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
506 | 500 | $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc |
|
507 | 501 | $ hg pull ../a |
|
508 | 502 | pulling from ../a |
|
509 | 503 | searching for changes |
|
510 | 504 | abort: preoutgoing.badmodule hook is invalid: import of "nomodule" failed |
|
511 | 505 | (run with --traceback for stack trace) |
|
512 | 506 | [255] |
|
513 | 507 | |
|
514 | 508 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
515 | 509 | $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc |
|
516 | 510 | $ hg pull ../a |
|
517 | 511 | pulling from ../a |
|
518 | 512 | searching for changes |
|
519 | 513 | abort: preoutgoing.unreachable hook is invalid: import of "hooktests.container" failed |
|
520 | 514 | (run with --traceback for stack trace) |
|
521 | 515 | [255] |
|
522 | 516 | |
|
523 | 517 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
524 | 518 | $ echo 'preoutgoing.syntaxerror = python:syntaxerror.syntaxerror' >> ../a/.hg/hgrc |
|
525 | 519 | $ hg pull ../a |
|
526 | 520 | pulling from ../a |
|
527 | 521 | searching for changes |
|
528 | 522 | abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed |
|
529 | 523 | (run with --traceback for stack trace) |
|
530 | 524 | [255] |
|
531 | 525 | |
|
532 | 526 | The second egrep is to filter out lines like ' ^', which are slightly |
|
533 | 527 | different between Python 2.6 and Python 2.7. |
|
534 | 528 | $ hg pull ../a --traceback 2>&1 | egrep -v '^( +File| [_a-zA-Z*(])' | egrep -v '^( )+(\^)?$' |
|
535 | 529 | pulling from ../a |
|
536 | 530 | searching for changes |
|
537 | 531 | exception from first failed import attempt: |
|
538 | 532 | Traceback (most recent call last): |
|
539 | 533 | SyntaxError: * (glob) |
|
540 | 534 | exception from second failed import attempt: |
|
541 | 535 | Traceback (most recent call last): |
|
542 | 536 | ImportError: No module named hgext_syntaxerror |
|
543 | 537 | Traceback (most recent call last): |
|
544 | 538 | HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed |
|
545 | 539 | abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed |
|
546 | 540 | |
|
547 | 541 | $ echo '[hooks]' > ../a/.hg/hgrc |
|
548 | 542 | $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc |
|
549 | 543 | $ hg pull ../a |
|
550 | 544 | pulling from ../a |
|
551 | 545 | searching for changes |
|
552 | 546 | hook args: |
|
553 | 547 | hooktype preoutgoing |
|
554 | 548 | source pull |
|
555 | 549 | adding changesets |
|
556 | 550 | adding manifests |
|
557 | 551 | adding file changes |
|
558 | 552 | added 1 changesets with 1 changes to 1 files |
|
559 | 553 | adding remote bookmark quux |
|
560 | 554 | (run 'hg update' to get a working copy) |
|
561 | 555 | |
|
562 | 556 | post- python hooks that fail to *run* don't cause an abort |
|
563 | 557 | $ rm ../a/.hg/hgrc |
|
564 | 558 | $ echo '[hooks]' > .hg/hgrc |
|
565 | 559 | $ echo 'post-pull.broken = python:hooktests.brokenhook' >> .hg/hgrc |
|
566 | 560 | $ hg pull ../a |
|
567 | 561 | pulling from ../a |
|
568 | 562 | searching for changes |
|
569 | 563 | no changes found |
|
570 | 564 | error: post-pull.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict' |
|
571 | 565 | (run with --traceback for stack trace) |
|
572 | 566 | |
|
573 | 567 | but post- python hooks that fail to *load* do |
|
574 | 568 | $ echo '[hooks]' > .hg/hgrc |
|
575 | 569 | $ echo 'post-pull.nomodule = python:nomodule' >> .hg/hgrc |
|
576 | 570 | $ hg pull ../a |
|
577 | 571 | pulling from ../a |
|
578 | 572 | searching for changes |
|
579 | 573 | no changes found |
|
580 | 574 | abort: post-pull.nomodule hook is invalid: "nomodule" not in a module |
|
581 | 575 | [255] |
|
582 | 576 | |
|
583 | 577 | $ echo '[hooks]' > .hg/hgrc |
|
584 | 578 | $ echo 'post-pull.badmodule = python:nomodule.nowhere' >> .hg/hgrc |
|
585 | 579 | $ hg pull ../a |
|
586 | 580 | pulling from ../a |
|
587 | 581 | searching for changes |
|
588 | 582 | no changes found |
|
589 | 583 | abort: post-pull.badmodule hook is invalid: import of "nomodule" failed |
|
590 | 584 | (run with --traceback for stack trace) |
|
591 | 585 | [255] |
|
592 | 586 | |
|
593 | 587 | $ echo '[hooks]' > .hg/hgrc |
|
594 | 588 | $ echo 'post-pull.nohook = python:hooktests.nohook' >> .hg/hgrc |
|
595 | 589 | $ hg pull ../a |
|
596 | 590 | pulling from ../a |
|
597 | 591 | searching for changes |
|
598 | 592 | no changes found |
|
599 | 593 | abort: post-pull.nohook hook is invalid: "hooktests.nohook" is not defined |
|
600 | 594 | [255] |
|
601 | 595 | |
|
602 | 596 | make sure --traceback works |
|
603 | 597 | |
|
604 | 598 | $ echo '[hooks]' > .hg/hgrc |
|
605 | 599 | $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc |
|
606 | 600 | |
|
607 | 601 | $ echo aa > a |
|
608 | 602 | $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback' |
|
609 | 603 | Traceback (most recent call last): |
|
610 | 604 | |
|
611 | 605 | $ cd .. |
|
612 | 606 | $ hg init c |
|
613 | 607 | $ cd c |
|
614 | 608 | |
|
615 | 609 | $ cat > hookext.py <<EOF |
|
616 | 610 | > def autohook(**args): |
|
617 | 611 | > print "Automatically installed hook" |
|
618 | 612 | > |
|
619 | 613 | > def reposetup(ui, repo): |
|
620 | 614 | > repo.ui.setconfig("hooks", "commit.auto", autohook) |
|
621 | 615 | > EOF |
|
622 | 616 | $ echo '[extensions]' >> .hg/hgrc |
|
623 | 617 | $ echo 'hookext = hookext.py' >> .hg/hgrc |
|
624 | 618 | |
|
625 | 619 | $ touch foo |
|
626 | 620 | $ hg add foo |
|
627 | 621 | $ hg ci -d '0 0' -m 'add foo' |
|
628 | 622 | Automatically installed hook |
|
629 | 623 | $ echo >> foo |
|
630 | 624 | $ hg ci --debug -d '0 0' -m 'change foo' |
|
631 | 625 | committing files: |
|
632 | 626 | foo |
|
633 | 627 | committing manifest |
|
634 | 628 | committing changelog |
|
635 | 629 | committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708 |
|
636 | 630 | calling hook commit.auto: hgext_hookext.autohook |
|
637 | 631 | Automatically installed hook |
|
638 | 632 | |
|
639 | 633 | $ hg showconfig hooks |
|
640 | 634 | hooks.commit.auto=<function autohook at *> (glob) |
|
641 | 635 | |
|
642 | 636 | test python hook configured with python:[file]:[hook] syntax |
|
643 | 637 | |
|
644 | 638 | $ cd .. |
|
645 | 639 | $ mkdir d |
|
646 | 640 | $ cd d |
|
647 | 641 | $ hg init repo |
|
648 | 642 | $ mkdir hooks |
|
649 | 643 | |
|
650 | 644 | $ cd hooks |
|
651 | 645 | $ cat > testhooks.py <<EOF |
|
652 | 646 | > def testhook(**args): |
|
653 | 647 | > print 'hook works' |
|
654 | 648 | > EOF |
|
655 | 649 | $ echo '[hooks]' > ../repo/.hg/hgrc |
|
656 | 650 | $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc |
|
657 | 651 | |
|
658 | 652 | $ cd ../repo |
|
659 | 653 | $ hg commit -d '0 0' |
|
660 | 654 | hook works |
|
661 | 655 | nothing changed |
|
662 | 656 | [1] |
|
663 | 657 | |
|
664 | 658 | $ echo '[hooks]' > .hg/hgrc |
|
665 | 659 | $ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc |
|
666 | 660 | $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc |
|
667 | 661 | |
|
668 | 662 | $ hg up null |
|
669 | 663 | loading update.ne hook failed: |
|
670 | 664 | abort: No such file or directory: $TESTTMP/d/repo/nonexistent.py |
|
671 | 665 | [255] |
|
672 | 666 | |
|
673 | 667 | $ hg id |
|
674 | 668 | loading pre-identify.npmd hook failed: |
|
675 | 669 | abort: No module named repo! |
|
676 | 670 | [255] |
|
677 | 671 | |
|
678 | 672 | $ cd ../../b |
|
679 | 673 | |
|
680 | 674 | make sure --traceback works on hook import failure |
|
681 | 675 | |
|
682 | 676 | $ cat > importfail.py <<EOF |
|
683 | 677 | > import somebogusmodule |
|
684 | 678 | > # dereference something in the module to force demandimport to load it |
|
685 | 679 | > somebogusmodule.whatever |
|
686 | 680 | > EOF |
|
687 | 681 | |
|
688 | 682 | $ echo '[hooks]' > .hg/hgrc |
|
689 | 683 | $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc |
|
690 | 684 | |
|
691 | 685 | $ echo a >> a |
|
692 | 686 | $ hg --traceback commit -ma 2>&1 | egrep -v '^( +File| [a-zA-Z(])' |
|
693 | 687 | exception from first failed import attempt: |
|
694 | 688 | Traceback (most recent call last): |
|
695 | 689 | ImportError: No module named somebogusmodule |
|
696 | 690 | exception from second failed import attempt: |
|
697 | 691 | Traceback (most recent call last): |
|
698 | 692 | ImportError: No module named hgext_importfail |
|
699 | 693 | Traceback (most recent call last): |
|
700 | 694 | HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed |
|
701 | 695 | abort: precommit.importfail hook is invalid: import of "importfail" failed |
|
702 | 696 | |
|
703 | 697 | Issue1827: Hooks Update & Commit not completely post operation |
|
704 | 698 | |
|
705 | 699 | commit and update hooks should run after command completion. The largefiles |
|
706 | 700 | use demonstrates a recursive wlock, showing the hook doesn't run until the |
|
707 | 701 | final release (and dirstate flush). |
|
708 | 702 | |
|
709 | 703 | $ echo '[hooks]' > .hg/hgrc |
|
710 | 704 | $ echo 'commit = hg id' >> .hg/hgrc |
|
711 | 705 | $ echo 'update = hg id' >> .hg/hgrc |
|
712 | 706 | $ echo bb > a |
|
713 | 707 | $ hg ci -ma |
|
714 | 708 | 223eafe2750c tip |
|
715 | 709 | $ hg up 0 --config extensions.largefiles= |
|
716 | 710 | cb9a9f314b8b |
|
717 | 711 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
718 | 712 | |
|
719 | 713 | make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui |
|
720 | 714 | that is passed to pre/post hooks |
|
721 | 715 | |
|
722 | 716 | $ echo '[hooks]' > .hg/hgrc |
|
723 | 717 | $ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc |
|
724 | 718 | $ hg id |
|
725 | 719 | cb9a9f314b8b |
|
726 | 720 | $ hg id --verbose |
|
727 | 721 | calling hook pre-identify: hooktests.verbosehook |
|
728 | 722 | verbose output from hook |
|
729 | 723 | cb9a9f314b8b |
|
730 | 724 | |
|
731 | 725 | Ensure hooks can be prioritized |
|
732 | 726 | |
|
733 | 727 | $ echo '[hooks]' > .hg/hgrc |
|
734 | 728 | $ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc |
|
735 | 729 | $ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc |
|
736 | 730 | $ echo 'priority.pre-identify.b = 1' >> .hg/hgrc |
|
737 | 731 | $ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc |
|
738 | 732 | $ hg id --verbose |
|
739 | 733 | calling hook pre-identify.b: hooktests.verbosehook |
|
740 | 734 | verbose output from hook |
|
741 | 735 | calling hook pre-identify.a: hooktests.verbosehook |
|
742 | 736 | verbose output from hook |
|
743 | 737 | calling hook pre-identify.c: hooktests.verbosehook |
|
744 | 738 | verbose output from hook |
|
745 | 739 | cb9a9f314b8b |
|
746 | 740 | |
|
747 | 741 | new tags must be visible in pretxncommit (issue3210) |
|
748 | 742 | |
|
749 | 743 | $ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc |
|
750 | 744 | $ hg tag -f foo |
|
751 | 745 | ['a', 'foo', 'tip'] |
|
752 | 746 | |
|
753 | 747 | post-init hooks must not crash (issue4983) |
|
754 | 748 | This also creates the `to` repo for the next test block. |
|
755 | 749 | |
|
756 | 750 | $ cd .. |
|
757 | 751 | $ cat << EOF >> hgrc-with-post-init-hook |
|
758 | 752 | > [hooks] |
|
759 | 753 | > post-init = printenv.py post-init |
|
760 | 754 | > EOF |
|
761 | 755 | $ HGRCPATH=hgrc-with-post-init-hook hg init to |
|
762 | 756 | post-init hook: HG_ARGS=init to HG_OPTS={'insecure': None, 'remotecmd': '', 'ssh': ''} HG_PATS=['to'] HG_RESULT=0 |
|
763 | 757 | |
|
764 | 758 | new commits must be visible in pretxnchangegroup (issue3428) |
|
765 | 759 | |
|
766 | 760 | $ echo '[hooks]' >> to/.hg/hgrc |
|
767 | 761 | $ echo 'prechangegroup = hg --traceback tip' >> to/.hg/hgrc |
|
768 | 762 | $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc |
|
769 | 763 | $ echo a >> to/a |
|
770 | 764 | $ hg --cwd to ci -Ama |
|
771 | 765 | adding a |
|
772 | 766 | $ hg clone to from |
|
773 | 767 | updating to branch default |
|
774 | 768 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
775 | 769 | $ echo aa >> from/a |
|
776 | 770 | $ hg --cwd from ci -mb |
|
777 | 771 | $ hg --cwd from push |
|
778 | 772 | pushing to $TESTTMP/to (glob) |
|
779 | 773 | searching for changes |
|
780 | 774 | changeset: 0:cb9a9f314b8b |
|
781 | 775 | tag: tip |
|
782 | 776 | user: test |
|
783 | 777 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
784 | 778 | summary: a |
|
785 | 779 | |
|
786 | 780 | adding changesets |
|
787 | 781 | adding manifests |
|
788 | 782 | adding file changes |
|
789 | 783 | added 1 changesets with 1 changes to 1 files |
|
790 | 784 | changeset: 1:9836a07b9b9d |
|
791 | 785 | tag: tip |
|
792 | 786 | user: test |
|
793 | 787 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
794 | 788 | summary: b |
|
795 | 789 | |
|
796 | 790 | |
|
797 | 791 | pretxnclose hook failure should abort the transaction |
|
798 | 792 | |
|
799 | 793 | $ hg init txnfailure |
|
800 | 794 | $ cd txnfailure |
|
801 | 795 | $ touch a && hg commit -Aqm a |
|
802 | 796 | $ cat >> .hg/hgrc <<EOF |
|
803 | 797 | > [hooks] |
|
804 | 798 | > pretxnclose.error = exit 1 |
|
805 | 799 | > EOF |
|
806 | 800 | $ hg strip -r 0 --config extensions.strip= |
|
807 | 801 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
808 | 802 | saved backup bundle to * (glob) |
|
809 | 803 | transaction abort! |
|
810 | 804 | rollback completed |
|
811 | 805 | strip failed, full bundle stored in * (glob) |
|
812 | 806 | abort: pretxnclose.error hook exited with status 1 |
|
813 | 807 | [255] |
|
814 | 808 | $ hg recover |
|
815 | 809 | no interrupted transaction available |
|
816 | 810 | [1] |
|
817 | 811 | $ cd .. |
|
818 | 812 | |
|
819 | 813 | Hook from untrusted hgrc are reported as failure |
|
820 | 814 | ================================================ |
|
821 | 815 | |
|
822 | 816 | $ cat << EOF > $TESTTMP/untrusted.py |
|
823 | 817 | > from mercurial import scmutil, util |
|
824 | 818 | > def uisetup(ui): |
|
825 | 819 | > class untrustedui(ui.__class__): |
|
826 | 820 | > def _trusted(self, fp, f): |
|
827 | 821 | > if util.normpath(fp.name).endswith('untrusted/.hg/hgrc'): |
|
828 | 822 | > return False |
|
829 | 823 | > return super(untrustedui, self)._trusted(fp, f) |
|
830 | 824 | > ui.__class__ = untrustedui |
|
831 | 825 | > EOF |
|
832 | 826 | $ cat << EOF >> $HGRCPATH |
|
833 | 827 | > [extensions] |
|
834 | 828 | > untrusted=$TESTTMP/untrusted.py |
|
835 | 829 | > EOF |
|
836 | 830 | $ hg init untrusted |
|
837 | 831 | $ cd untrusted |
|
838 | 832 | |
|
839 | 833 | Non-blocking hook |
|
840 | 834 | ----------------- |
|
841 | 835 | |
|
842 | 836 | $ cat << EOF >> .hg/hgrc |
|
843 | 837 | > [hooks] |
|
844 | 838 | > txnclose.testing=echo txnclose hook called |
|
845 | 839 | > EOF |
|
846 | 840 | $ touch a && hg commit -Aqm a |
|
847 | 841 | warning: untrusted hook txnclose not executed |
|
848 | 842 | $ hg log |
|
849 | 843 | changeset: 0:3903775176ed |
|
850 | 844 | tag: tip |
|
851 | 845 | user: test |
|
852 | 846 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
853 | 847 | summary: a |
|
854 | 848 | |
|
855 | 849 | |
|
856 | 850 | Non-blocking hook |
|
857 | 851 | ----------------- |
|
858 | 852 | |
|
859 | 853 | $ cat << EOF >> .hg/hgrc |
|
860 | 854 | > [hooks] |
|
861 | 855 | > pretxnclose.testing=echo pre-txnclose hook called |
|
862 | 856 | > EOF |
|
863 | 857 | $ touch b && hg commit -Aqm a |
|
864 | 858 | transaction abort! |
|
865 | 859 | rollback completed |
|
866 | 860 | abort: untrusted hook pretxnclose not executed |
|
867 | 861 | (see 'hg help config.trusted') |
|
868 | 862 | [255] |
|
869 | 863 | $ hg log |
|
870 | 864 | changeset: 0:3903775176ed |
|
871 | 865 | tag: tip |
|
872 | 866 | user: test |
|
873 | 867 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
874 | 868 | summary: a |
|
875 | 869 |
General Comments 0
You need to be logged in to leave comments.
Login now