Mercurial > hg-stable
comparison tests/test-mq-qrefresh-replace-log-message.t @ 26751:520defbc0335
hook: centralize passing HG_PENDING to external hook process
This patch centralizes passing HG_PENDING to external hook process
into '_exthook()'. To make in-memory changes visible to external hook
process, this patch does:
- write (or schedule to write) in-memory dirstate changes, and
- set HG_PENDING environment variable, if:
- a transaction is running, and
- there are in-memory changes to be visible
This patch tests some commands with some hooks, because transaction
activity of a same hook differs from each other ("---": "not tested").
======== ========= ========= ============
command preupdate precommit pretxncommit
======== ========= ========= ============
unshelve o --- ---
backout x --- ---
import --- o o
qrefresh --- x o
======== ========= ========= ============
Each hooks are examined separately to prevent in-memory changes from
being visible to external process accidentally by side effect of hooks
previously invoked.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 17 Oct 2015 01:15:34 +0900 |
parents | 9f9ec4abe700 |
children | bbf544b5f2e9 |
comparison
equal
deleted
inserted
replaced
26750:9f9ec4abe700 | 26751:520defbc0335 |
---|---|
240 | 240 |
241 $ sh "$TESTTMP/checkvisibility.sh" | 241 $ sh "$TESTTMP/checkvisibility.sh" |
242 ==== | 242 ==== |
243 0:25e397dabed2 | 243 0:25e397dabed2 |
244 ==== | 244 ==== |
245 | |
246 == test visibility to precommit external hook | |
247 | |
248 $ hg update -C -q | |
249 $ rm -f file2 | |
250 $ hg qpush -q second-patch --config hooks.pretxncommit.unexpectedabort= | |
251 now at: second-patch | |
252 $ echo bbbb >> file2 | |
253 | |
254 $ cat >> .hg/hgrc <<EOF | |
255 > [hooks] | |
256 > precommit.checkvisibility = sh "$TESTTMP/checkvisibility.sh" | |
257 > EOF | |
258 | |
259 $ sh "$TESTTMP/checkvisibility.sh" | |
260 ==== | |
261 1:e30108269082 | |
262 M file2 | |
263 ==== | |
264 | |
265 $ hg qrefresh | |
266 ==== | |
267 0:25e397dabed2 | |
268 A file2 | |
269 ==== | |
270 transaction abort! | |
271 rollback completed | |
272 refresh interrupted while patch was popped! (revert --all, qpush to recover) | |
273 abort: pretxncommit.unexpectedabort hook exited with status 1 | |
274 [255] | |
275 | |
276 $ sh "$TESTTMP/checkvisibility.sh" | |
277 ==== | |
278 0:25e397dabed2 | |
279 ==== | |
280 | |
281 $ cat >> .hg/hgrc <<EOF | |
282 > [hooks] | |
283 > precommit.checkvisibility = | |
284 > EOF | |
285 | |
286 == test visibility to pretxncommit external hook | |
287 | |
288 $ hg update -C -q | |
289 $ rm -f file2 | |
290 $ hg qpush -q second-patch --config hooks.pretxncommit.unexpectedabort= | |
291 now at: second-patch | |
292 $ echo bbbb >> file2 | |
293 | |
294 $ cat >> .hg/hgrc <<EOF | |
295 > [hooks] | |
296 > pretxncommit.checkvisibility = sh "$TESTTMP/checkvisibility.sh" | |
297 > # make checkvisibility run before unexpectedabort | |
298 > priority.pretxncommit.checkvisibility = 10 | |
299 > EOF | |
300 | |
301 $ sh "$TESTTMP/checkvisibility.sh" | |
302 ==== | |
303 1:e30108269082 | |
304 M file2 | |
305 ==== | |
306 | |
307 $ hg qrefresh | |
308 ==== | |
309 0:25e397dabed2 | |
310 A file2 | |
311 ==== | |
312 transaction abort! | |
313 rollback completed | |
314 refresh interrupted while patch was popped! (revert --all, qpush to recover) | |
315 abort: pretxncommit.unexpectedabort hook exited with status 1 | |
316 [255] | |
317 | |
318 $ sh "$TESTTMP/checkvisibility.sh" | |
319 ==== | |
320 0:25e397dabed2 | |
321 ==== | |
322 | |
323 $ cat >> .hg/hgrc <<EOF | |
324 > [hooks] | |
325 > pretxncommit.checkvisibility = | |
326 > EOF |