Mercurial > public > mercurial-scm > hg
diff tests/test-import.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 | fe458d078ed7 |
line wrap: on
line diff
--- a/tests/test-import.t Sat Oct 17 01:15:34 2015 +0900 +++ b/tests/test-import.t Sat Oct 17 01:15:34 2015 +0900 @@ -533,6 +533,110 @@ $ hg --cwd b revert --no-backup a $ rm -f b/foo +== test visibility to precommit external hook + + $ cat >> b/.hg/hgrc <<EOF + > [hooks] + > precommit.visibility = sh $TESTTMP/checkvisibility.sh + > EOF + + $ (cd b && sh "$TESTTMP/checkvisibility.sh") + ==== + VISIBLE 0:80971e65b431 + ACTUAL 0:80971e65b431 + ==== + + $ hg --cwd b import ../patch1 ../patch2 ../patch3 + applying ../patch1 + ==== + VISIBLE 0:80971e65b431 + M a + ACTUAL 0:80971e65b431 + M a + ==== + applying ../patch2 + ==== + VISIBLE 1:1d4bd90af0e4 + M a + ACTUAL 0:80971e65b431 + M a + ==== + applying ../patch3 + ==== + VISIBLE 2:6d019af21222 + A foo + ACTUAL 0:80971e65b431 + M a + ==== + + $ hg --cwd b rollback -q + $ (cd b && sh "$TESTTMP/checkvisibility.sh") + ==== + VISIBLE 0:80971e65b431 + M a + ACTUAL 0:80971e65b431 + M a + ==== + $ hg --cwd b revert --no-backup a + $ rm -f b/foo + + $ cat >> b/.hg/hgrc <<EOF + > [hooks] + > precommit.visibility = + > EOF + +== test visibility to pretxncommit external hook + + $ cat >> b/.hg/hgrc <<EOF + > [hooks] + > pretxncommit.visibility = sh $TESTTMP/checkvisibility.sh + > EOF + + $ (cd b && sh "$TESTTMP/checkvisibility.sh") + ==== + VISIBLE 0:80971e65b431 + ACTUAL 0:80971e65b431 + ==== + + $ hg --cwd b import ../patch1 ../patch2 ../patch3 + applying ../patch1 + ==== + VISIBLE 0:80971e65b431 + M a + ACTUAL 0:80971e65b431 + M a + ==== + applying ../patch2 + ==== + VISIBLE 1:1d4bd90af0e4 + M a + ACTUAL 0:80971e65b431 + M a + ==== + applying ../patch3 + ==== + VISIBLE 2:6d019af21222 + A foo + ACTUAL 0:80971e65b431 + M a + ==== + + $ hg --cwd b rollback -q + $ (cd b && sh "$TESTTMP/checkvisibility.sh") + ==== + VISIBLE 0:80971e65b431 + M a + ACTUAL 0:80971e65b431 + M a + ==== + $ hg --cwd b revert --no-backup a + $ rm -f b/foo + + $ cat >> b/.hg/hgrc <<EOF + > [hooks] + > pretxncommit.visibility = + > EOF + $ rm -r b