-
Pierre-Yves David authored
We are adding generic hooking for all transactions. We do not really have any useful information to include when opening the transaction but this is a useful time to allow a hook anyway. We better let people abort transaction before they happen than after multiple seconds/minutes of processing.
Pierre-Yves David authoredWe are adding generic hooking for all transactions. We do not really have any useful information to include when opening the transaction but this is a useful time to allow a hook anyway. We better let people abort transaction before they happen than after multiple seconds/minutes of processing.
test-hook.t 22.34 KiB
commit hooks can see env vars
$ hg init a
$ cd a
$ cat > .hg/hgrc <<EOF
> [hooks]
> commit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit"
> commit.b = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit.b"
> precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= python \"$TESTDIR/printenv.py\" precommit"
> pretxncommit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxncommit"
> pretxncommit.tip = hg -q tip
> pre-identify = python "$TESTDIR/printenv.py" pre-identify 1
> pre-cat = python "$TESTDIR/printenv.py" pre-cat
> post-cat = python "$TESTDIR/printenv.py" post-cat
> pretxnopen = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxnopen"
> EOF
$ echo a > a
$ hg add a
$ hg commit -m a
precommit hook: HG_PARENT1=0000000000000000000000000000000000000000
pretxnopen hook: HG_TXNNAME=commit
pretxncommit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$TESTTMP/a
0:cb9a9f314b8b
commit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
commit.b hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
$ hg clone . ../b
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd ../b
changegroup hooks can see env vars
$ cat > .hg/hgrc <<EOF
> [hooks]
> prechangegroup = python "$TESTDIR/printenv.py" prechangegroup
> changegroup = python "$TESTDIR/printenv.py" changegroup
> incoming = python "$TESTDIR/printenv.py" incoming
> EOF
pretxncommit and commit hooks can see both parents of merge
$ cd ../a
$ echo b >> a
$ hg commit -m a1 -d "1 0"
precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
pretxnopen hook: HG_TXNNAME=commit
pretxncommit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
1:ab228980c14d
commit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
commit.b hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
$ hg update -C 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo b > b
$ hg add b
$ hg commit -m b -d '1 0'
precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
pretxnopen hook: HG_TXNNAME=commit
pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
2:ee9deb46ab31
commit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
commit.b hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
created new head
$ hg merge 1
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg commit -m merge -d '2 0'
precommit hook: HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
pretxnopen hook: HG_TXNNAME=commit
pretxncommit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$TESTTMP/a