Mercurial > hg
annotate tests/test-hook @ 2208:12e36dedf668
update README.
fix issue 225.
do not use deprecated commands in examples.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Thu, 04 May 2006 21:44:09 -0700 |
parents | cbd458228a96 |
children | 05b6c13f43c6 |
rev | line source |
---|---|
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 |
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 | 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 | 11 echo a > a |
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 |
2155
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
90 cat > hooktests.py <<EOF |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
91 from mercurial import util |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
92 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
93 uncallable = 0 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
94 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
95 def printargs(args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
96 args.pop('ui', None) |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
97 args.pop('repo', None) |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
98 a = list(args.items()) |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
99 a.sort() |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
100 print 'hook args:' |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
101 for k, v in a: |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
102 print ' ', k, v |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
103 return True |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
104 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
105 def passhook(**args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
106 printargs(args) |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
107 return True |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
108 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
109 def failhook(**args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
110 printargs(args) |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
111 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
112 class LocalException(Exception): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
113 pass |
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 raisehook(**args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
116 raise LocalException('exception from hook') |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
117 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
118 def aborthook(**args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
119 raise util.Abort('raise abort from hook') |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
120 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
121 def brokenhook(**args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
122 return 1 + {} |
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 class container: |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
125 unreachable = 1 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
126 EOF |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
127 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
128 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
|
129 PYTHONPATH="`pwd`:$PYTHONPATH" |
2155
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
130 export PYTHONPATH |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
131 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
132 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
133 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
|
134 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
|
135 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
136 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
137 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
|
138 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
|
139 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
140 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
141 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
|
142 hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
143 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
144 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
145 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
|
146 hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
147 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
148 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
149 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
|
150 hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
151 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
152 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
153 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
|
154 hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
155 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
156 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
157 echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
158 hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
159 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
160 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
161 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
|
162 hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
163 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
164 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
165 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
|
166 hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
167 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
168 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
169 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
|
170 hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
171 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
172 echo '# make sure --traceback works' |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
173 echo '[hooks]' > .hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
174 echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
175 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
176 echo a >> a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
177 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
|
178 |
1736
50de0887bbcd
add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1734
diff
changeset
|
179 exit 0 |