Mercurial > hg
annotate tests/test-hook @ 9851:9e7b2c49d25d
Make it possible to debug failed hook imports via use of --traceback
Prior to this change, if a Python hook module failed to load (e.g. due
to an import error or path problem), it was impossible to figure out
why the error occurred, because the ImportErrors that got raised were
caught but never displayed.
If run with --traceback or ui.traceback=True, hg now prints tracebacks
of both of the ImportError instances that get raised before it bails.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Thu, 12 Nov 2009 14:05:52 -0800 |
parents | 87c05a78e588 |
children | 7f5a71946aaa |
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 |
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 |
8907
e9ef409e6399
Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents:
4659
diff
changeset
|
110 # outgoing hooks work for local clones |
e9ef409e6399
Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents:
4659
diff
changeset
|
111 cd .. |
e9ef409e6399
Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents:
4659
diff
changeset
|
112 echo '[hooks]' > a/.hg/hgrc |
e9ef409e6399
Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents:
4659
diff
changeset
|
113 echo 'preoutgoing = python ../printenv.py preoutgoing' >> a/.hg/hgrc |
e9ef409e6399
Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents:
4659
diff
changeset
|
114 echo 'outgoing = python ../printenv.py outgoing' >> a/.hg/hgrc |
e9ef409e6399
Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents:
4659
diff
changeset
|
115 hg clone a c |
e9ef409e6399
Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents:
4659
diff
changeset
|
116 rm -rf c |
e9ef409e6399
Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents:
4659
diff
changeset
|
117 |
e9ef409e6399
Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents:
4659
diff
changeset
|
118 # preoutgoing hook can prevent outgoing changes for local clones |
e9ef409e6399
Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents:
4659
diff
changeset
|
119 echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> a/.hg/hgrc |
e9ef409e6399
Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents:
4659
diff
changeset
|
120 hg clone a zzz |
e9ef409e6399
Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents:
4659
diff
changeset
|
121 cd b |
e9ef409e6399
Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents:
4659
diff
changeset
|
122 |
2155
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
123 cat > hooktests.py <<EOF |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
124 from mercurial import util |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
125 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
126 uncallable = 0 |
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 def printargs(args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
129 args.pop('ui', None) |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
130 args.pop('repo', None) |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
131 a = list(args.items()) |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
132 a.sort() |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
133 print 'hook args:' |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
134 for k, v in a: |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
135 print ' ', k, v |
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 passhook(**args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
138 printargs(args) |
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 failhook(**args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
141 printargs(args) |
2221
05b6c13f43c6
reverse sense of return value from python hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2164
diff
changeset
|
142 return True |
2155
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 class LocalException(Exception): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
145 pass |
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 def raisehook(**args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
148 raise LocalException('exception from hook') |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
149 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
150 def aborthook(**args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
151 raise util.Abort('raise abort from hook') |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
152 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
153 def brokenhook(**args): |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
154 return 1 + {} |
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 class container: |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
157 unreachable = 1 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
158 EOF |
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 '# 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
|
161 PYTHONPATH="`pwd`:$PYTHONPATH" |
2155
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
162 export PYTHONPATH |
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.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
166 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
|
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.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
170 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
|
171 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
172 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
173 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
|
174 hg pull ../a |
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 '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
177 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
|
178 hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
179 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
180 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
181 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
|
182 hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
183 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
184 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
185 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
|
186 hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
187 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
188 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
189 echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
190 hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
191 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
192 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
193 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
|
194 hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
195 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
196 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
197 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
|
198 hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
199 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
200 echo '[hooks]' > ../a/.hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
201 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
|
202 hg pull ../a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
203 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
204 echo '# make sure --traceback works' |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
205 echo '[hooks]' > .hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
206 echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
207 |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
208 echo a >> a |
ff255b41b4aa
support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
209 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
|
210 |
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
|
211 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
|
212 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
|
213 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
|
214 |
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 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
|
216 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
|
217 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
|
218 |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
219 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
|
220 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
|
221 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
|
222 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
|
223 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
|
224 |
961ccb615cf7
Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2673
diff
changeset
|
225 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
|
226 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
|
227 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
|
228 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
|
229 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
|
230 |
4085
719488a98ebe
Fix hg showconfig traceback with values that aren't strings
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4070
diff
changeset
|
231 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
|
232 |
9014
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
233 echo '# test python hook configured with python:[file]:[hook] syntax' |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
234 cd .. |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
235 mkdir d |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
236 cd d |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
237 hg init repo |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
238 mkdir hooks |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
239 |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
240 cd hooks |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
241 cat > testhooks.py <<EOF |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
242 def testhook(**args): |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
243 print 'hook works' |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
244 EOF |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
245 echo '[hooks]' > ../repo/.hg/hgrc |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
246 echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
247 |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
248 cd ../repo |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
249 hg commit |
87c05a78e588
test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents:
8907
diff
changeset
|
250 |
9851
9e7b2c49d25d
Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents:
9014
diff
changeset
|
251 cd ../../b |
9e7b2c49d25d
Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents:
9014
diff
changeset
|
252 echo '# make sure --traceback works on hook import failure' |
9e7b2c49d25d
Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents:
9014
diff
changeset
|
253 cat > importfail.py <<EOF |
9e7b2c49d25d
Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents:
9014
diff
changeset
|
254 import somebogusmodule |
9e7b2c49d25d
Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents:
9014
diff
changeset
|
255 # dereference something in the module to force demandimport to load it |
9e7b2c49d25d
Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents:
9014
diff
changeset
|
256 somebogusmodule.whatever |
9e7b2c49d25d
Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents:
9014
diff
changeset
|
257 EOF |
9e7b2c49d25d
Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents:
9014
diff
changeset
|
258 |
9e7b2c49d25d
Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents:
9014
diff
changeset
|
259 echo '[hooks]' > .hg/hgrc |
9e7b2c49d25d
Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents:
9014
diff
changeset
|
260 echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc |
9e7b2c49d25d
Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents:
9014
diff
changeset
|
261 |
9e7b2c49d25d
Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents:
9014
diff
changeset
|
262 echo a >> a |
9e7b2c49d25d
Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents:
9014
diff
changeset
|
263 hg --traceback commit -Ama 2>&1 | grep '^\(exception\|Traceback\|ImportError\)' |
9e7b2c49d25d
Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents:
9014
diff
changeset
|
264 |
1736
50de0887bbcd
add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1734
diff
changeset
|
265 exit 0 |