Show More
@@ -178,7 +178,7 b' hooks::' | |||||
178 | but before the transaction has been committed. Changegroup is |
|
178 | but before the transaction has been committed. Changegroup is | |
179 | visible to hook program. This lets you validate incoming changes |
|
179 | visible to hook program. This lets you validate incoming changes | |
180 | before accepting them. Passed the ID of the first new changeset |
|
180 | before accepting them. Passed the ID of the first new changeset | |
181 | in $NODE. Exit status 0 allows the transaction to commit. |
|
181 | in $HG_NODE. Exit status 0 allows the transaction to commit. | |
182 | Non-zero status will cause the transaction to be rolled back and |
|
182 | Non-zero status will cause the transaction to be rolled back and | |
183 | the push, pull or unbundle will fail. |
|
183 | the push, pull or unbundle will fail. | |
184 | pretxncommit;; |
|
184 | pretxncommit;; |
@@ -2117,7 +2117,7 b' def tag(ui, repo, name, rev_=None, **opt' | |||||
2117 | raise util.Abort(_("%s cannot be used in a tag name") % repr(c)) |
|
2117 | raise util.Abort(_("%s cannot be used in a tag name") % repr(c)) | |
2118 |
|
2118 | |||
2119 | repo.hook('pretag', throw=True, node=r, tag=name, |
|
2119 | repo.hook('pretag', throw=True, node=r, tag=name, | |
2120 | local=not not opts['local']) |
|
2120 | local=int(not not opts['local'])) | |
2121 |
|
2121 | |||
2122 | if opts['local']: |
|
2122 | if opts['local']: | |
2123 | repo.opener("localtags", "a").write("%s %s\n" % (r, name)) |
|
2123 | repo.opener("localtags", "a").write("%s %s\n" % (r, name)) |
@@ -1,10 +1,76 b'' | |||||
1 | #!/bin/sh |
|
1 | #!/bin/sh | |
2 |
|
2 | |||
3 | hg init |
|
3 | # commit hooks can see env vars | |
|
4 | hg init a | |||
|
5 | cd a | |||
4 | echo "[hooks]" > .hg/hgrc |
|
6 | echo "[hooks]" > .hg/hgrc | |
5 |
echo ' |
|
7 | echo 'commit = echo commit hook: n=$HG_NODE p1=$HG_PARENT1 p2=$HG_PARENT2' >> .hg/hgrc | |
6 | echo 'commit = echo commit hook: $NODE' >> .hg/hgrc |
|
|||
7 | echo 'commit.b = echo commit hook b' >> .hg/hgrc |
|
8 | echo 'commit.b = echo commit hook b' >> .hg/hgrc | |
|
9 | echo 'precommit = echo precommit hook: p1=$HG_PARENT1 p2=$HG_PARENT2' >> .hg/hgrc | |||
|
10 | echo 'pretxncommit = echo pretxncommit hook: n=$HG_NODE p1=$HG_PARENT1 p2=$HG_PARENT2; hg -q tip' >> .hg/hgrc | |||
8 | echo a > a |
|
11 | echo a > a | |
9 | hg add a |
|
12 | hg add a | |
10 |
hg commit -m |
|
13 | hg commit -m a -d "0 0" | |
|
14 | ||||
|
15 | hg clone . ../b | |||
|
16 | cd ../b | |||
|
17 | ||||
|
18 | # changegroup hooks can see env vars | |||
|
19 | echo '[hooks]' > .hg/hgrc | |||
|
20 | echo 'prechangegroup = echo prechangegroup hook' >> .hg/hgrc | |||
|
21 | echo 'changegroup = echo changegroup hook: n=$HG_NODE' >> .hg/hgrc | |||
|
22 | echo 'incoming = echo incoming hook: n=$HG_NODE' >> .hg/hgrc | |||
|
23 | ||||
|
24 | # pretxncommit and commit hooks can see both parents of merge | |||
|
25 | cd ../a | |||
|
26 | echo b >> a | |||
|
27 | hg commit -m a1 -d "1 0" | |||
|
28 | hg update -C 0 | |||
|
29 | echo b > b | |||
|
30 | hg add b | |||
|
31 | hg commit -m b -d '1 0' | |||
|
32 | hg update -m 1 | |||
|
33 | hg commit -m merge -d '2 0' | |||
|
34 | ||||
|
35 | cd ../b | |||
|
36 | hg pull ../a | |||
|
37 | ||||
|
38 | # tag hooks can see env vars | |||
|
39 | cd ../a | |||
|
40 | echo 'pretag = echo pretag hook: t=$HG_TAG n=$HG_NODE l=$HG_LOCAL' >> .hg/hgrc | |||
|
41 | echo 'tag = echo tag hook: t=$HG_TAG n=$HG_NODE l=$HG_LOCAL' >> .hg/hgrc | |||
|
42 | hg tag -d '3 0' a | |||
|
43 | hg tag -l la | |||
|
44 | ||||
|
45 | # pretag hook can forbid tagging | |||
|
46 | echo 'pretag.forbid = echo pretag.forbid hook; exit 1' >> .hg/hgrc | |||
|
47 | hg tag -d '4 0' fa | |||
|
48 | hg tag -l fla | |||
|
49 | ||||
|
50 | # pretxncommit hook can see changeset, can roll back txn, changeset | |||
|
51 | # no more there after | |||
|
52 | echo 'pretxncommit.forbid = echo pretxncommit.forbid hook: tip=`hg -q tip`; exit 1' >> .hg/hgrc | |||
|
53 | echo z > z | |||
|
54 | hg add z | |||
|
55 | hg -q tip | |||
|
56 | hg commit -m 'fail' -d '4 0' | |||
|
57 | hg -q tip | |||
|
58 | ||||
|
59 | # precommit hook can prevent commit | |||
|
60 | echo 'precommit.forbid = echo precommit.forbid hook; exit 1' >> .hg/hgrc | |||
|
61 | hg commit -m 'fail' -d '4 0' | |||
|
62 | hg -q tip | |||
|
63 | ||||
|
64 | # prechangegroup hook can prevent incoming changes | |||
|
65 | cd ../b | |||
|
66 | hg -q tip | |||
|
67 | echo '[hooks]' > .hg/hgrc | |||
|
68 | echo 'prechangegroup.forbid = echo prechangegroup.forbid hook; exit 1' >> .hg/hgrc | |||
|
69 | hg pull ../a | |||
|
70 | ||||
|
71 | # pretxnchangegroup hook can see incoming changes, can roll back txn, | |||
|
72 | # incoming changes no longer there after | |||
|
73 | echo '[hooks]' > .hg/hgrc | |||
|
74 | echo 'pretxnchangegroup.forbid = echo pretxnchangegroup.forbid hook: tip=`hg -q tip`; exit 1' >> .hg/hgrc | |||
|
75 | hg pull ../a | |||
|
76 | hg -q tip |
General Comments 0
You need to be logged in to leave comments.
Login now