author | Martin Geisler <mg@lazybytes.net> |
Wed, 20 May 2009 00:52:46 +0200 | |
changeset 8527 | f9a80054dd3c |
parent 4659 | 7a7d4937272b |
child 8907 | e9ef409e6399 |
permissions | -rwxr-xr-x |
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 | 2 |
|
4286
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
3 |
cp "$TESTDIR"/printenv.py . |
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
4 |
|
1734
9488d53233b5
tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1481
diff
changeset
|
5 |
# 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
|
6 |
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
|
7 |
cd a |
487 | 8 |
echo "[hooks]" > .hg/hgrc |
4368
97962a3e73cf
Work around problem where 'del os.environ["FOO"]' doesn't update environment.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4286
diff
changeset
|
9 |
echo 'commit = unset HG_LOCAL HG_TAG; python ../printenv.py commit' >> .hg/hgrc |
97962a3e73cf
Work around problem where 'del os.environ["FOO"]' doesn't update environment.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4286
diff
changeset
|
10 |
echo 'commit.b = unset HG_LOCAL HG_TAG; python ../printenv.py commit.b' >> .hg/hgrc |
97962a3e73cf
Work around problem where 'del os.environ["FOO"]' doesn't update environment.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4286
diff
changeset
|
11 |
echo 'precommit = unset HG_LOCAL HG_NODE HG_TAG; python ../printenv.py precommit' >> .hg/hgrc |
97962a3e73cf
Work around problem where 'del os.environ["FOO"]' doesn't update environment.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4286
diff
changeset
|
12 |
echo 'pretxncommit = unset HG_LOCAL HG_TAG; python ../printenv.py pretxncommit' >> .hg/hgrc |
4286
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
13 |
echo 'pretxncommit.tip = hg -q tip' >> .hg/hgrc |
4634
73bf2b586f3f
Use printenv.py for pre/post-command-hooks (fixes tests on Solaris, too)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4630
diff
changeset
|
14 |
echo 'pre-identify = python ../printenv.py pre-identify 1' >> .hg/hgrc |
73bf2b586f3f
Use printenv.py for pre/post-command-hooks (fixes tests on Solaris, too)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4630
diff
changeset
|
15 |
echo 'pre-cat = python ../printenv.py pre-cat' >> .hg/hgrc |
73bf2b586f3f
Use printenv.py for pre/post-command-hooks (fixes tests on Solaris, too)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4630
diff
changeset
|
16 |
echo 'post-cat = python ../printenv.py post-cat' >> .hg/hgrc |
487 | 17 |
echo a > a |
18 |
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
|
19 |
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
|
20 |
|
9488d53233b5
tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1481
diff
changeset
|
21 |
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
|
22 |
cd ../b |
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 |
# 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
|
25 |
echo '[hooks]' > .hg/hgrc |
4286
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
26 |
echo 'prechangegroup = python ../printenv.py prechangegroup' >> .hg/hgrc |
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
27 |
echo 'changegroup = python ../printenv.py changegroup' >> .hg/hgrc |
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
28 |
echo 'incoming = python ../printenv.py incoming' >> .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
|
29 |
|
9488d53233b5
tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1481
diff
changeset
|
30 |
# 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
|
31 |
cd ../a |
9488d53233b5
tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1481
diff
changeset
|
32 |
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
|
33 |
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
|
34 |
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
|
35 |
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
|
36 |
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
|
37 |
hg commit -m b -d '1 0' |
2283
e506c14382fd
deprecate 'update -m'. use 'merge' instead.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2266
diff
changeset
|
38 |
hg merge 1 |
1734
9488d53233b5
tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1481
diff
changeset
|
39 |
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
|
40 |
|
4630
e6d105a51ec7
dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents:
4368
diff
changeset
|
41 |
# test generic hooks |
e6d105a51ec7
dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents:
4368
diff
changeset
|
42 |
hg id |
4659
7a7d4937272b
Kill trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4634
diff
changeset
|
43 |
hg cat b |
4630
e6d105a51ec7
dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents:
4368
diff
changeset
|
44 |
|
1734
9488d53233b5
tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1481
diff
changeset
|
45 |
cd ../b |
9488d53233b5
tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1481
diff
changeset
|
46 |
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
|
47 |
|
9488d53233b5
tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1481
diff
changeset
|
48 |
# 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
|
49 |
cd ../a |
4286
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
50 |
echo 'pretag = python ../printenv.py pretag' >> .hg/hgrc |
4368
97962a3e73cf
Work around problem where 'del os.environ["FOO"]' doesn't update environment.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4286
diff
changeset
|
51 |
echo 'tag = unset HG_PARENT1 HG_PARENT2; python ../printenv.py tag' >> .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
|
52 |
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
|
53 |
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
|
54 |
|
9488d53233b5
tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1481
diff
changeset
|
55 |
# pretag hook can forbid tagging |
4286
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
56 |
echo 'pretag.forbid = python ../printenv.py pretag.forbid 1' >> .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
|
57 |
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
|
58 |
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
|
59 |
|
9488d53233b5
tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1481
diff
changeset
|
60 |
# 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
|
61 |
# no more there after |
4286
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
62 |
echo 'pretxncommit.forbid0 = hg tip -q' >> .hg/hgrc |
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
63 |
echo 'pretxncommit.forbid1 = python ../printenv.py pretxncommit.forbid 1' >> .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
|
64 |
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
|
65 |
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
|
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 |
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
|
68 |
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
|
69 |
|
9488d53233b5
tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1481
diff
changeset
|
70 |
# precommit hook can prevent commit |
4286
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
71 |
echo 'precommit.forbid = python ../printenv.py precommit.forbid 1' >> .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
|
72 |
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
|
73 |
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
|
74 |
|
2266
3f7692b0ff13
hooks: add preupdate and update hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2227
diff
changeset
|
75 |
# preupdate hook can prevent update |
4286
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
76 |
echo 'preupdate = python ../printenv.py preupdate' >> .hg/hgrc |
2266
3f7692b0ff13
hooks: add preupdate and update hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2227
diff
changeset
|
77 |
hg update 1 |
3f7692b0ff13
hooks: add preupdate and update hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2227
diff
changeset
|
78 |
|
3f7692b0ff13
hooks: add preupdate and update hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2227
diff
changeset
|
79 |
# update hook |
4286
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
80 |
echo 'update = python ../printenv.py update' >> .hg/hgrc |
2266
3f7692b0ff13
hooks: add preupdate and update hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2227
diff
changeset
|
81 |
hg update |
3f7692b0ff13
hooks: add preupdate and update hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2227
diff
changeset
|
82 |
|
1734
9488d53233b5
tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1481
diff
changeset
|
83 |
# 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
|
84 |
cd ../b |
9488d53233b5
tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1481
diff
changeset
|
85 |
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
|
86 |
echo '[hooks]' > .hg/hgrc |
4286
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
87 |
echo 'prechangegroup.forbid = python ../printenv.py prechangegroup.forbid 1' >> .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
|
88 |
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
|
89 |
|
9488d53233b5
tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1481
diff
changeset
|
90 |
# 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
|
91 |
# 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
|
92 |
echo '[hooks]' > .hg/hgrc |
4286
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
93 |
echo 'pretxnchangegroup.forbid0 = hg tip -q' >> .hg/hgrc |
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
94 |
echo 'pretxnchangegroup.forbid1 = python ../printenv.py pretxnchangegroup.forbid 1' >> .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
|
95 |
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
|
96 |
hg -q tip |
1736
50de0887bbcd
add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1734
diff
changeset
|
97 |
|
50de0887bbcd
add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1734
diff
changeset
|
98 |
# outgoing hooks can see env vars |
50de0887bbcd
add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1734
diff
changeset
|
99 |
rm .hg/hgrc |
50de0887bbcd
add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1734
diff
changeset
|
100 |
echo '[hooks]' > ../a/.hg/hgrc |
4286
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
101 |
echo 'preoutgoing = python ../printenv.py preoutgoing' >> ../a/.hg/hgrc |
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
102 |
echo 'outgoing = python ../printenv.py outgoing' >> ../a/.hg/hgrc |
1736
50de0887bbcd
add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1734
diff
changeset
|
103 |
hg pull ../a |
2227
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2221
diff
changeset
|
104 |
hg rollback |
1736
50de0887bbcd
add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1734
diff
changeset
|
105 |
|
50de0887bbcd
add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1734
diff
changeset
|
106 |
# preoutgoing hook can prevent outgoing changes |
4286
949516072388
test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4085
diff
changeset
|
107 |
echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> ../a/.hg/hgrc |
1736
50de0887bbcd
add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1734
diff
changeset
|
108 |
hg pull ../a |
50de0887bbcd
add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1734
diff
changeset
|
109 |
|
2155
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
110 |
cat > hooktests.py <<EOF |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
111 |
from mercurial import util |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
112 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
113 |
uncallable = 0 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
114 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
115 |
def printargs(args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
116 |
args.pop('ui', None) |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
117 |
args.pop('repo', None) |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
118 |
a = list(args.items()) |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
119 |
a.sort() |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
120 |
print 'hook args:' |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
121 |
for k, v in a: |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
122 |
print ' ', k, v |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
123 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
124 |
def passhook(**args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
125 |
printargs(args) |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
126 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
127 |
def failhook(**args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
128 |
printargs(args) |
2221
05b6c13f43c6
reverse sense of return value from python hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2164
diff
changeset
|
129 |
return True |
2155
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
130 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
131 |
class LocalException(Exception): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
132 |
pass |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
133 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
134 |
def raisehook(**args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
135 |
raise LocalException('exception from hook') |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
136 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
137 |
def aborthook(**args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
138 |
raise util.Abort('raise abort from hook') |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
139 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
140 |
def brokenhook(**args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
141 |
return 1 + {} |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
142 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
143 |
class container: |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
144 |
unreachable = 1 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
145 |
EOF |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
146 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
147 |
echo '# test python hooks' |
2164
cbd458228a96
Applied $PWD fix (changeset 278f9b13c39a) to tests/test-hook, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2155
diff
changeset
|
148 |
PYTHONPATH="`pwd`:$PYTHONPATH" |
2155
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
149 |
export PYTHONPATH |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
150 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
151 |
echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
152 |
echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
153 |
hg pull ../a 2>&1 | grep 'raised an exception' |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
154 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
155 |
echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
156 |
echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
157 |
hg pull ../a 2>&1 | grep 'raised an exception' |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
158 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
159 |
echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
160 |
echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
161 |
hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
162 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
163 |
echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
164 |
echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
165 |
hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
166 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
167 |
echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
168 |
echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
169 |
hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
170 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
171 |
echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
172 |
echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
173 |
hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
174 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
175 |
echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
176 |
echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
177 |
hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
178 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
179 |
echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
180 |
echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
181 |
hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
182 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
183 |
echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
184 |
echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
185 |
hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
186 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
187 |
echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
188 |
echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
189 |
hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
190 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
191 |
echo '# make sure --traceback works' |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
192 |
echo '[hooks]' > .hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
193 |
echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
194 |
|
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
195 |
echo a >> a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
196 |
hg --traceback commit -A -m a 2>&1 | grep '^Traceback' |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
197 |
|
4070
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
198 |
cd .. |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
199 |
hg init c |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
200 |
cd c |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
201 |
|
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
202 |
cat > hookext.py <<EOF |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
203 |
def autohook(**args): |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
204 |
print "Automatically installed hook" |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
205 |
|
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
206 |
def reposetup(ui, repo): |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
207 |
repo.ui.setconfig("hooks", "commit.auto", autohook) |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
208 |
EOF |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
209 |
echo '[extensions]' >> .hg/hgrc |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
210 |
echo 'hookext = hookext.py' >> .hg/hgrc |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
211 |
|
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
212 |
touch foo |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
213 |
hg add foo |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
214 |
hg ci -m 'add foo' |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
215 |
echo >> foo |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
216 |
hg ci --debug -m 'change foo' | sed -e 's/ at .*>/>/' |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
217 |
|
4085
719488a98ebe
Fix hg showconfig traceback with values that aren't strings
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4070
diff
changeset
|
218 |
hg showconfig hooks | sed -e 's/ at .*>/>/' |
719488a98ebe
Fix hg showconfig traceback with values that aren't strings
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4070
diff
changeset
|
219 |
|
1736
50de0887bbcd
add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1734
diff
changeset
|
220 |
exit 0 |