tests/test-hook
author Thomas Arendsen Hein <thomas@intevation.de>
Tue, 21 Mar 2006 12:54:32 +0100
changeset 1984 df7436f439a0
parent 1933 7544700fd931
child 2155 ff255b41b4aa
permissions -rwxr-xr-x
Improved ui.edit(): - Use descriptive name for temporary file: hg-editor-*.txt - Don't import tempfile in the method, but use demandload() - Remove tempfile file even if editor aborts.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
800
ec85f9e6f3b1 Don't use 'set -x', fix exports, sed and hexdump usage for Solaris.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 749
diff changeset
     1
#!/bin/sh
487
2ad41189bee5 Add initial hook support
mpm@selenic.com
parents:
diff changeset
     2
1734
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
     3
# commit hooks can see env vars
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
     4
hg init a
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
     5
cd a
487
2ad41189bee5 Add initial hook support
mpm@selenic.com
parents:
diff changeset
     6
echo "[hooks]" > .hg/hgrc
1734
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
     7
echo 'commit = echo commit hook: n=$HG_NODE p1=$HG_PARENT1 p2=$HG_PARENT2' >> .hg/hgrc
1481
acd1832ebf31 Change test-hook to test multiple hooks
Matt Mackall <mpm@selenic.com>
parents: 814
diff changeset
     8
echo 'commit.b = echo commit hook b' >> .hg/hgrc
1734
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
     9
echo 'precommit = echo precommit hook: p1=$HG_PARENT1 p2=$HG_PARENT2' >> .hg/hgrc
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    10
echo 'pretxncommit = echo pretxncommit hook: n=$HG_NODE p1=$HG_PARENT1 p2=$HG_PARENT2; hg -q tip' >> .hg/hgrc
487
2ad41189bee5 Add initial hook support
mpm@selenic.com
parents:
diff changeset
    11
echo a > a
2ad41189bee5 Add initial hook support
mpm@selenic.com
parents:
diff changeset
    12
hg add a
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1736
diff changeset
    13
hg commit -m a -d "1000000 0"
1734
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    14
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    15
hg clone . ../b
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    16
cd ../b
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    17
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    18
# changegroup hooks can see env vars
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    19
echo '[hooks]' > .hg/hgrc
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    20
echo 'prechangegroup = echo prechangegroup hook' >> .hg/hgrc
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    21
echo 'changegroup = echo changegroup hook: n=$HG_NODE' >> .hg/hgrc
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    22
echo 'incoming = echo incoming hook: n=$HG_NODE' >> .hg/hgrc
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    23
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    24
# pretxncommit and commit hooks can see both parents of merge
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    25
cd ../a
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    26
echo b >> a
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    27
hg commit -m a1 -d "1 0"
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    28
hg update -C 0
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    29
echo b > b
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    30
hg add b
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    31
hg commit -m b -d '1 0'
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    32
hg update -m 1
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    33
hg commit -m merge -d '2 0'
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    34
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    35
cd ../b
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    36
hg pull ../a
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    37
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    38
# tag hooks can see env vars
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    39
cd ../a
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    40
echo 'pretag = echo pretag hook: t=$HG_TAG n=$HG_NODE l=$HG_LOCAL' >> .hg/hgrc
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    41
echo 'tag = echo tag hook: t=$HG_TAG n=$HG_NODE l=$HG_LOCAL' >> .hg/hgrc
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    42
hg tag -d '3 0' a
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    43
hg tag -l la
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    44
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    45
# pretag hook can forbid tagging
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    46
echo 'pretag.forbid = echo pretag.forbid hook; exit 1' >> .hg/hgrc
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    47
hg tag -d '4 0' fa
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    48
hg tag -l fla
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    49
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    50
# pretxncommit hook can see changeset, can roll back txn, changeset
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    51
# no more there after
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    52
echo 'pretxncommit.forbid = echo pretxncommit.forbid hook: tip=`hg -q tip`; exit 1' >> .hg/hgrc
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    53
echo z > z
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    54
hg add z
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    55
hg -q tip
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    56
hg commit -m 'fail' -d '4 0'
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    57
hg -q tip
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    58
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    59
# precommit hook can prevent commit
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    60
echo 'precommit.forbid = echo precommit.forbid hook; exit 1' >> .hg/hgrc
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    61
hg commit -m 'fail' -d '4 0'
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    62
hg -q tip
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    63
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    64
# prechangegroup hook can prevent incoming changes
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    65
cd ../b
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    66
hg -q tip
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    67
echo '[hooks]' > .hg/hgrc
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    68
echo 'prechangegroup.forbid = echo prechangegroup.forbid hook; exit 1' >> .hg/hgrc
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    69
hg pull ../a
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    70
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    71
# pretxnchangegroup hook can see incoming changes, can roll back txn,
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    72
# incoming changes no longer there after
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    73
echo '[hooks]' > .hg/hgrc
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    74
echo 'pretxnchangegroup.forbid = echo pretxnchangegroup.forbid hook: tip=`hg -q tip`; exit 1' >> .hg/hgrc
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    75
hg pull ../a
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    76
hg -q tip
1736
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
    77
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
    78
# outgoing hooks can see env vars
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
    79
rm .hg/hgrc
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
    80
echo '[hooks]' > ../a/.hg/hgrc
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
    81
echo 'preoutgoing = echo preoutgoing hook: s=$HG_SOURCE' >> ../a/.hg/hgrc
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
    82
echo 'outgoing = echo outgoing hook: n=$HG_NODE s=$HG_SOURCE' >> ../a/.hg/hgrc
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
    83
hg pull ../a
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
    84
hg undo
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
    85
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
    86
# preoutgoing hook can prevent outgoing changes
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
    87
echo 'preoutgoing.forbid = echo preoutgoing.forbid hook; exit 1' >> ../a/.hg/hgrc
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
    88
hg pull ../a
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
    89
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
    90
exit 0