##// END OF EJS Templates
spelling: propagated
timeless@mozdev.org -
r17508:57fb8c95 default
parent child Browse files
Show More
@@ -1,644 +1,644 b''
1 commit hooks can see env vars
1 commit hooks can see env vars
2
2
3 $ hg init a
3 $ hg init a
4 $ cd a
4 $ cd a
5 $ cat > .hg/hgrc <<EOF
5 $ cat > .hg/hgrc <<EOF
6 > [hooks]
6 > [hooks]
7 > commit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit"
7 > commit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit"
8 > commit.b = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit.b"
8 > commit.b = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit.b"
9 > precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= python \"$TESTDIR/printenv.py\" precommit"
9 > precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= python \"$TESTDIR/printenv.py\" precommit"
10 > pretxncommit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxncommit"
10 > pretxncommit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxncommit"
11 > pretxncommit.tip = hg -q tip
11 > pretxncommit.tip = hg -q tip
12 > pre-identify = python "$TESTDIR/printenv.py" pre-identify 1
12 > pre-identify = python "$TESTDIR/printenv.py" pre-identify 1
13 > pre-cat = python "$TESTDIR/printenv.py" pre-cat
13 > pre-cat = python "$TESTDIR/printenv.py" pre-cat
14 > post-cat = python "$TESTDIR/printenv.py" post-cat
14 > post-cat = python "$TESTDIR/printenv.py" post-cat
15 > EOF
15 > EOF
16 $ echo a > a
16 $ echo a > a
17 $ hg add a
17 $ hg add a
18 $ hg commit -m a
18 $ hg commit -m a
19 precommit hook: HG_PARENT1=0000000000000000000000000000000000000000
19 precommit hook: HG_PARENT1=0000000000000000000000000000000000000000
20 pretxncommit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$TESTTMP/a
20 pretxncommit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$TESTTMP/a
21 0:cb9a9f314b8b
21 0:cb9a9f314b8b
22 commit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
22 commit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
23 commit.b hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
23 commit.b hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
24
24
25 $ hg clone . ../b
25 $ hg clone . ../b
26 updating to branch default
26 updating to branch default
27 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
27 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
28 $ cd ../b
28 $ cd ../b
29
29
30 changegroup hooks can see env vars
30 changegroup hooks can see env vars
31
31
32 $ cat > .hg/hgrc <<EOF
32 $ cat > .hg/hgrc <<EOF
33 > [hooks]
33 > [hooks]
34 > prechangegroup = python "$TESTDIR/printenv.py" prechangegroup
34 > prechangegroup = python "$TESTDIR/printenv.py" prechangegroup
35 > changegroup = python "$TESTDIR/printenv.py" changegroup
35 > changegroup = python "$TESTDIR/printenv.py" changegroup
36 > incoming = python "$TESTDIR/printenv.py" incoming
36 > incoming = python "$TESTDIR/printenv.py" incoming
37 > EOF
37 > EOF
38
38
39 pretxncommit and commit hooks can see both parents of merge
39 pretxncommit and commit hooks can see both parents of merge
40
40
41 $ cd ../a
41 $ cd ../a
42 $ echo b >> a
42 $ echo b >> a
43 $ hg commit -m a1 -d "1 0"
43 $ hg commit -m a1 -d "1 0"
44 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
44 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
45 pretxncommit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
45 pretxncommit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
46 1:ab228980c14d
46 1:ab228980c14d
47 commit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
47 commit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
48 commit.b hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
48 commit.b hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
49 $ hg update -C 0
49 $ hg update -C 0
50 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
50 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
51 $ echo b > b
51 $ echo b > b
52 $ hg add b
52 $ hg add b
53 $ hg commit -m b -d '1 0'
53 $ hg commit -m b -d '1 0'
54 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
54 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
55 pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
55 pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
56 2:ee9deb46ab31
56 2:ee9deb46ab31
57 commit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
57 commit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
58 commit.b hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
58 commit.b hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
59 created new head
59 created new head
60 $ hg merge 1
60 $ hg merge 1
61 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
61 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
62 (branch merge, don't forget to commit)
62 (branch merge, don't forget to commit)
63 $ hg commit -m merge -d '2 0'
63 $ hg commit -m merge -d '2 0'
64 precommit hook: HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
64 precommit hook: HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
65 pretxncommit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$TESTTMP/a
65 pretxncommit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$TESTTMP/a
66 3:07f3376c1e65
66 3:07f3376c1e65
67 commit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
67 commit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
68 commit.b hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
68 commit.b hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
69
69
70 test generic hooks
70 test generic hooks
71
71
72 $ hg id
72 $ hg id
73 pre-identify hook: HG_ARGS=id HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'insecure': None, 'num': None, 'remotecmd': '', 'rev': '', 'ssh': '', 'tags': None} HG_PATS=[]
73 pre-identify hook: HG_ARGS=id HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'insecure': None, 'num': None, 'remotecmd': '', 'rev': '', 'ssh': '', 'tags': None} HG_PATS=[]
74 warning: pre-identify hook exited with status 1
74 warning: pre-identify hook exited with status 1
75 [1]
75 [1]
76 $ hg cat b
76 $ hg cat b
77 pre-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b']
77 pre-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b']
78 b
78 b
79 post-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b'] HG_RESULT=0
79 post-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b'] HG_RESULT=0
80
80
81 $ cd ../b
81 $ cd ../b
82 $ hg pull ../a
82 $ hg pull ../a
83 pulling from ../a
83 pulling from ../a
84 searching for changes
84 searching for changes
85 prechangegroup hook: HG_SOURCE=pull HG_URL=file:$TESTTMP/a
85 prechangegroup hook: HG_SOURCE=pull HG_URL=file:$TESTTMP/a
86 adding changesets
86 adding changesets
87 adding manifests
87 adding manifests
88 adding file changes
88 adding file changes
89 added 3 changesets with 2 changes to 2 files
89 added 3 changesets with 2 changes to 2 files
90 changegroup hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_URL=file:$TESTTMP/a
90 changegroup hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_URL=file:$TESTTMP/a
91 incoming hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_URL=file:$TESTTMP/a
91 incoming hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_URL=file:$TESTTMP/a
92 incoming hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_URL=file:$TESTTMP/a
92 incoming hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_URL=file:$TESTTMP/a
93 incoming hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_URL=file:$TESTTMP/a
93 incoming hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_URL=file:$TESTTMP/a
94 (run 'hg update' to get a working copy)
94 (run 'hg update' to get a working copy)
95
95
96 tag hooks can see env vars
96 tag hooks can see env vars
97
97
98 $ cd ../a
98 $ cd ../a
99 $ cat >> .hg/hgrc <<EOF
99 $ cat >> .hg/hgrc <<EOF
100 > pretag = python "$TESTDIR/printenv.py" pretag
100 > pretag = python "$TESTDIR/printenv.py" pretag
101 > tag = sh -c "HG_PARENT1= HG_PARENT2= python \"$TESTDIR/printenv.py\" tag"
101 > tag = sh -c "HG_PARENT1= HG_PARENT2= python \"$TESTDIR/printenv.py\" tag"
102 > EOF
102 > EOF
103 $ hg tag -d '3 0' a
103 $ hg tag -d '3 0' a
104 pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
104 pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
105 precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
105 precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
106 pretxncommit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$TESTTMP/a
106 pretxncommit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$TESTTMP/a
107 4:539e4b31b6dc
107 4:539e4b31b6dc
108 tag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
108 tag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
109 commit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
109 commit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
110 commit.b hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
110 commit.b hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
111 $ hg tag -l la
111 $ hg tag -l la
112 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
112 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
113 tag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
113 tag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
114
114
115 pretag hook can forbid tagging
115 pretag hook can forbid tagging
116
116
117 $ echo "pretag.forbid = python \"$TESTDIR/printenv.py\" pretag.forbid 1" >> .hg/hgrc
117 $ echo "pretag.forbid = python \"$TESTDIR/printenv.py\" pretag.forbid 1" >> .hg/hgrc
118 $ hg tag -d '4 0' fa
118 $ hg tag -d '4 0' fa
119 pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
119 pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
120 pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
120 pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
121 abort: pretag.forbid hook exited with status 1
121 abort: pretag.forbid hook exited with status 1
122 [255]
122 [255]
123 $ hg tag -l fla
123 $ hg tag -l fla
124 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
124 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
125 pretag.forbid hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
125 pretag.forbid hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
126 abort: pretag.forbid hook exited with status 1
126 abort: pretag.forbid hook exited with status 1
127 [255]
127 [255]
128
128
129 pretxncommit hook can see changeset, can roll back txn, changeset no
129 pretxncommit hook can see changeset, can roll back txn, changeset no
130 more there after
130 more there after
131
131
132 $ echo "pretxncommit.forbid0 = hg tip -q" >> .hg/hgrc
132 $ echo "pretxncommit.forbid0 = hg tip -q" >> .hg/hgrc
133 $ echo "pretxncommit.forbid1 = python \"$TESTDIR/printenv.py\" pretxncommit.forbid 1" >> .hg/hgrc
133 $ echo "pretxncommit.forbid1 = python \"$TESTDIR/printenv.py\" pretxncommit.forbid 1" >> .hg/hgrc
134 $ echo z > z
134 $ echo z > z
135 $ hg add z
135 $ hg add z
136 $ hg -q tip
136 $ hg -q tip
137 4:539e4b31b6dc
137 4:539e4b31b6dc
138 $ hg commit -m 'fail' -d '4 0'
138 $ hg commit -m 'fail' -d '4 0'
139 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
139 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
140 pretxncommit hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
140 pretxncommit hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
141 5:6f611f8018c1
141 5:6f611f8018c1
142 5:6f611f8018c1
142 5:6f611f8018c1
143 pretxncommit.forbid hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
143 pretxncommit.forbid hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
144 transaction abort!
144 transaction abort!
145 rollback completed
145 rollback completed
146 abort: pretxncommit.forbid1 hook exited with status 1
146 abort: pretxncommit.forbid1 hook exited with status 1
147 [255]
147 [255]
148 $ hg -q tip
148 $ hg -q tip
149 4:539e4b31b6dc
149 4:539e4b31b6dc
150
150
151 precommit hook can prevent commit
151 precommit hook can prevent commit
152
152
153 $ echo "precommit.forbid = python \"$TESTDIR/printenv.py\" precommit.forbid 1" >> .hg/hgrc
153 $ echo "precommit.forbid = python \"$TESTDIR/printenv.py\" precommit.forbid 1" >> .hg/hgrc
154 $ hg commit -m 'fail' -d '4 0'
154 $ hg commit -m 'fail' -d '4 0'
155 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
155 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
156 precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
156 precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
157 abort: precommit.forbid hook exited with status 1
157 abort: precommit.forbid hook exited with status 1
158 [255]
158 [255]
159 $ hg -q tip
159 $ hg -q tip
160 4:539e4b31b6dc
160 4:539e4b31b6dc
161
161
162 preupdate hook can prevent update
162 preupdate hook can prevent update
163
163
164 $ echo "preupdate = python \"$TESTDIR/printenv.py\" preupdate" >> .hg/hgrc
164 $ echo "preupdate = python \"$TESTDIR/printenv.py\" preupdate" >> .hg/hgrc
165 $ hg update 1
165 $ hg update 1
166 preupdate hook: HG_PARENT1=ab228980c14d
166 preupdate hook: HG_PARENT1=ab228980c14d
167 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
167 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
168
168
169 update hook
169 update hook
170
170
171 $ echo "update = python \"$TESTDIR/printenv.py\" update" >> .hg/hgrc
171 $ echo "update = python \"$TESTDIR/printenv.py\" update" >> .hg/hgrc
172 $ hg update
172 $ hg update
173 preupdate hook: HG_PARENT1=539e4b31b6dc
173 preupdate hook: HG_PARENT1=539e4b31b6dc
174 update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc
174 update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc
175 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
175 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
176
176
177 pushkey hook
177 pushkey hook
178
178
179 $ echo "pushkey = python \"$TESTDIR/printenv.py\" pushkey" >> .hg/hgrc
179 $ echo "pushkey = python \"$TESTDIR/printenv.py\" pushkey" >> .hg/hgrc
180 $ cd ../b
180 $ cd ../b
181 $ hg bookmark -r null foo
181 $ hg bookmark -r null foo
182 $ hg push -B foo ../a
182 $ hg push -B foo ../a
183 pushing to ../a
183 pushing to ../a
184 searching for changes
184 searching for changes
185 no changes found
185 no changes found
186 exporting bookmark foo
186 exporting bookmark foo
187 pushkey hook: HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1
187 pushkey hook: HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1
188 [1]
188 [1]
189 $ cd ../a
189 $ cd ../a
190
190
191 listkeys hook
191 listkeys hook
192
192
193 $ echo "listkeys = python \"$TESTDIR/printenv.py\" listkeys" >> .hg/hgrc
193 $ echo "listkeys = python \"$TESTDIR/printenv.py\" listkeys" >> .hg/hgrc
194 $ hg bookmark -r null bar
194 $ hg bookmark -r null bar
195 $ cd ../b
195 $ cd ../b
196 $ hg pull -B bar ../a
196 $ hg pull -B bar ../a
197 pulling from ../a
197 pulling from ../a
198 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
198 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
199 no changes found
199 no changes found
200 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
200 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
201 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
201 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
202 adding remote bookmark bar
202 adding remote bookmark bar
203 importing bookmark bar
203 importing bookmark bar
204 $ cd ../a
204 $ cd ../a
205
205
206 test that prepushkey can prevent incoming keys
206 test that prepushkey can prevent incoming keys
207
207
208 $ echo "prepushkey = python \"$TESTDIR/printenv.py\" prepushkey.forbid 1" >> .hg/hgrc
208 $ echo "prepushkey = python \"$TESTDIR/printenv.py\" prepushkey.forbid 1" >> .hg/hgrc
209 $ cd ../b
209 $ cd ../b
210 $ hg bookmark -r null baz
210 $ hg bookmark -r null baz
211 $ hg push -B baz ../a
211 $ hg push -B baz ../a
212 pushing to ../a
212 pushing to ../a
213 searching for changes
213 searching for changes
214 no changes found
214 no changes found
215 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
215 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
216 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
216 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
217 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
217 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
218 exporting bookmark baz
218 exporting bookmark baz
219 prepushkey.forbid hook: HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000
219 prepushkey.forbid hook: HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000
220 abort: prepushkey hook exited with status 1
220 abort: prepushkey hook exited with status 1
221 [255]
221 [255]
222 $ cd ../a
222 $ cd ../a
223
223
224 test that prelistkeys can prevent listing keys
224 test that prelistkeys can prevent listing keys
225
225
226 $ echo "prelistkeys = python \"$TESTDIR/printenv.py\" prelistkeys.forbid 1" >> .hg/hgrc
226 $ echo "prelistkeys = python \"$TESTDIR/printenv.py\" prelistkeys.forbid 1" >> .hg/hgrc
227 $ hg bookmark -r null quux
227 $ hg bookmark -r null quux
228 $ cd ../b
228 $ cd ../b
229 $ hg pull -B quux ../a
229 $ hg pull -B quux ../a
230 pulling from ../a
230 pulling from ../a
231 prelistkeys.forbid hook: HG_NAMESPACE=bookmarks
231 prelistkeys.forbid hook: HG_NAMESPACE=bookmarks
232 abort: prelistkeys hook exited with status 1
232 abort: prelistkeys hook exited with status 1
233 [255]
233 [255]
234 $ cd ../a
234 $ cd ../a
235
235
236 prechangegroup hook can prevent incoming changes
236 prechangegroup hook can prevent incoming changes
237
237
238 $ cd ../b
238 $ cd ../b
239 $ hg -q tip
239 $ hg -q tip
240 3:07f3376c1e65
240 3:07f3376c1e65
241 $ cat > .hg/hgrc <<EOF
241 $ cat > .hg/hgrc <<EOF
242 > [hooks]
242 > [hooks]
243 > prechangegroup.forbid = python "$TESTDIR/printenv.py" prechangegroup.forbid 1
243 > prechangegroup.forbid = python "$TESTDIR/printenv.py" prechangegroup.forbid 1
244 > EOF
244 > EOF
245 $ hg pull ../a
245 $ hg pull ../a
246 pulling from ../a
246 pulling from ../a
247 searching for changes
247 searching for changes
248 prechangegroup.forbid hook: HG_SOURCE=pull HG_URL=file:$TESTTMP/a
248 prechangegroup.forbid hook: HG_SOURCE=pull HG_URL=file:$TESTTMP/a
249 abort: prechangegroup.forbid hook exited with status 1
249 abort: prechangegroup.forbid hook exited with status 1
250 [255]
250 [255]
251
251
252 pretxnchangegroup hook can see incoming changes, can roll back txn,
252 pretxnchangegroup hook can see incoming changes, can roll back txn,
253 incoming changes no longer there after
253 incoming changes no longer there after
254
254
255 $ cat > .hg/hgrc <<EOF
255 $ cat > .hg/hgrc <<EOF
256 > [hooks]
256 > [hooks]
257 > pretxnchangegroup.forbid0 = hg tip -q
257 > pretxnchangegroup.forbid0 = hg tip -q
258 > pretxnchangegroup.forbid1 = python "$TESTDIR/printenv.py" pretxnchangegroup.forbid 1
258 > pretxnchangegroup.forbid1 = python "$TESTDIR/printenv.py" pretxnchangegroup.forbid 1
259 > EOF
259 > EOF
260 $ hg pull ../a
260 $ hg pull ../a
261 pulling from ../a
261 pulling from ../a
262 searching for changes
262 searching for changes
263 adding changesets
263 adding changesets
264 adding manifests
264 adding manifests
265 adding file changes
265 adding file changes
266 added 1 changesets with 1 changes to 1 files
266 added 1 changesets with 1 changes to 1 files
267 4:539e4b31b6dc
267 4:539e4b31b6dc
268 pretxnchangegroup.forbid hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/b HG_SOURCE=pull HG_URL=file:$TESTTMP/a
268 pretxnchangegroup.forbid hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/b HG_SOURCE=pull HG_URL=file:$TESTTMP/a
269 transaction abort!
269 transaction abort!
270 rollback completed
270 rollback completed
271 abort: pretxnchangegroup.forbid1 hook exited with status 1
271 abort: pretxnchangegroup.forbid1 hook exited with status 1
272 [255]
272 [255]
273 $ hg -q tip
273 $ hg -q tip
274 3:07f3376c1e65
274 3:07f3376c1e65
275
275
276 outgoing hooks can see env vars
276 outgoing hooks can see env vars
277
277
278 $ rm .hg/hgrc
278 $ rm .hg/hgrc
279 $ cat > ../a/.hg/hgrc <<EOF
279 $ cat > ../a/.hg/hgrc <<EOF
280 > [hooks]
280 > [hooks]
281 > preoutgoing = python "$TESTDIR/printenv.py" preoutgoing
281 > preoutgoing = python "$TESTDIR/printenv.py" preoutgoing
282 > outgoing = python "$TESTDIR/printenv.py" outgoing
282 > outgoing = python "$TESTDIR/printenv.py" outgoing
283 > EOF
283 > EOF
284 $ hg pull ../a
284 $ hg pull ../a
285 pulling from ../a
285 pulling from ../a
286 searching for changes
286 searching for changes
287 preoutgoing hook: HG_SOURCE=pull
287 preoutgoing hook: HG_SOURCE=pull
288 adding changesets
288 adding changesets
289 outgoing hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_SOURCE=pull
289 outgoing hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_SOURCE=pull
290 adding manifests
290 adding manifests
291 adding file changes
291 adding file changes
292 added 1 changesets with 1 changes to 1 files
292 added 1 changesets with 1 changes to 1 files
293 adding remote bookmark quux
293 adding remote bookmark quux
294 (run 'hg update' to get a working copy)
294 (run 'hg update' to get a working copy)
295 $ hg rollback
295 $ hg rollback
296 repository tip rolled back to revision 3 (undo pull)
296 repository tip rolled back to revision 3 (undo pull)
297
297
298 preoutgoing hook can prevent outgoing changes
298 preoutgoing hook can prevent outgoing changes
299
299
300 $ echo "preoutgoing.forbid = python \"$TESTDIR/printenv.py\" preoutgoing.forbid 1" >> ../a/.hg/hgrc
300 $ echo "preoutgoing.forbid = python \"$TESTDIR/printenv.py\" preoutgoing.forbid 1" >> ../a/.hg/hgrc
301 $ hg pull ../a
301 $ hg pull ../a
302 pulling from ../a
302 pulling from ../a
303 searching for changes
303 searching for changes
304 preoutgoing hook: HG_SOURCE=pull
304 preoutgoing hook: HG_SOURCE=pull
305 preoutgoing.forbid hook: HG_SOURCE=pull
305 preoutgoing.forbid hook: HG_SOURCE=pull
306 abort: preoutgoing.forbid hook exited with status 1
306 abort: preoutgoing.forbid hook exited with status 1
307 [255]
307 [255]
308
308
309 outgoing hooks work for local clones
309 outgoing hooks work for local clones
310
310
311 $ cd ..
311 $ cd ..
312 $ cat > a/.hg/hgrc <<EOF
312 $ cat > a/.hg/hgrc <<EOF
313 > [hooks]
313 > [hooks]
314 > preoutgoing = python "$TESTDIR/printenv.py" preoutgoing
314 > preoutgoing = python "$TESTDIR/printenv.py" preoutgoing
315 > outgoing = python "$TESTDIR/printenv.py" outgoing
315 > outgoing = python "$TESTDIR/printenv.py" outgoing
316 > EOF
316 > EOF
317 $ hg clone a c
317 $ hg clone a c
318 preoutgoing hook: HG_SOURCE=clone
318 preoutgoing hook: HG_SOURCE=clone
319 outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone
319 outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone
320 updating to branch default
320 updating to branch default
321 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
321 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
322 $ rm -rf c
322 $ rm -rf c
323
323
324 preoutgoing hook can prevent outgoing changes for local clones
324 preoutgoing hook can prevent outgoing changes for local clones
325
325
326 $ echo "preoutgoing.forbid = python \"$TESTDIR/printenv.py\" preoutgoing.forbid 1" >> a/.hg/hgrc
326 $ echo "preoutgoing.forbid = python \"$TESTDIR/printenv.py\" preoutgoing.forbid 1" >> a/.hg/hgrc
327 $ hg clone a zzz
327 $ hg clone a zzz
328 preoutgoing hook: HG_SOURCE=clone
328 preoutgoing hook: HG_SOURCE=clone
329 preoutgoing.forbid hook: HG_SOURCE=clone
329 preoutgoing.forbid hook: HG_SOURCE=clone
330 abort: preoutgoing.forbid hook exited with status 1
330 abort: preoutgoing.forbid hook exited with status 1
331 [255]
331 [255]
332
332
333 $ cd "$TESTTMP/b"
333 $ cd "$TESTTMP/b"
334
334
335 $ cat > hooktests.py <<EOF
335 $ cat > hooktests.py <<EOF
336 > from mercurial import util
336 > from mercurial import util
337 >
337 >
338 > uncallable = 0
338 > uncallable = 0
339 >
339 >
340 > def printargs(args):
340 > def printargs(args):
341 > args.pop('ui', None)
341 > args.pop('ui', None)
342 > args.pop('repo', None)
342 > args.pop('repo', None)
343 > a = list(args.items())
343 > a = list(args.items())
344 > a.sort()
344 > a.sort()
345 > print 'hook args:'
345 > print 'hook args:'
346 > for k, v in a:
346 > for k, v in a:
347 > print ' ', k, v
347 > print ' ', k, v
348 >
348 >
349 > def passhook(**args):
349 > def passhook(**args):
350 > printargs(args)
350 > printargs(args)
351 >
351 >
352 > def failhook(**args):
352 > def failhook(**args):
353 > printargs(args)
353 > printargs(args)
354 > return True
354 > return True
355 >
355 >
356 > class LocalException(Exception):
356 > class LocalException(Exception):
357 > pass
357 > pass
358 >
358 >
359 > def raisehook(**args):
359 > def raisehook(**args):
360 > raise LocalException('exception from hook')
360 > raise LocalException('exception from hook')
361 >
361 >
362 > def aborthook(**args):
362 > def aborthook(**args):
363 > raise util.Abort('raise abort from hook')
363 > raise util.Abort('raise abort from hook')
364 >
364 >
365 > def brokenhook(**args):
365 > def brokenhook(**args):
366 > return 1 + {}
366 > return 1 + {}
367 >
367 >
368 > def verbosehook(ui, **args):
368 > def verbosehook(ui, **args):
369 > ui.note('verbose output from hook\n')
369 > ui.note('verbose output from hook\n')
370 >
370 >
371 > def printtags(ui, repo, **args):
371 > def printtags(ui, repo, **args):
372 > print repo.tags().keys()
372 > print repo.tags().keys()
373 >
373 >
374 > class container:
374 > class container:
375 > unreachable = 1
375 > unreachable = 1
376 > EOF
376 > EOF
377
377
378 test python hooks
378 test python hooks
379
379
380 #if windows
380 #if windows
381 $ PYTHONPATH="$TESTTMP/b;$PYTHONPATH"
381 $ PYTHONPATH="$TESTTMP/b;$PYTHONPATH"
382 #else
382 #else
383 $ PYTHONPATH="$TESTTMP/b:$PYTHONPATH"
383 $ PYTHONPATH="$TESTTMP/b:$PYTHONPATH"
384 #endif
384 #endif
385 $ export PYTHONPATH
385 $ export PYTHONPATH
386
386
387 $ echo '[hooks]' > ../a/.hg/hgrc
387 $ echo '[hooks]' > ../a/.hg/hgrc
388 $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
388 $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
389 $ hg pull ../a 2>&1 | grep 'raised an exception'
389 $ hg pull ../a 2>&1 | grep 'raised an exception'
390 error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
390 error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
391
391
392 $ echo '[hooks]' > ../a/.hg/hgrc
392 $ echo '[hooks]' > ../a/.hg/hgrc
393 $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
393 $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
394 $ hg pull ../a 2>&1 | grep 'raised an exception'
394 $ hg pull ../a 2>&1 | grep 'raised an exception'
395 error: preoutgoing.raise hook raised an exception: exception from hook
395 error: preoutgoing.raise hook raised an exception: exception from hook
396
396
397 $ echo '[hooks]' > ../a/.hg/hgrc
397 $ echo '[hooks]' > ../a/.hg/hgrc
398 $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
398 $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
399 $ hg pull ../a
399 $ hg pull ../a
400 pulling from ../a
400 pulling from ../a
401 searching for changes
401 searching for changes
402 error: preoutgoing.abort hook failed: raise abort from hook
402 error: preoutgoing.abort hook failed: raise abort from hook
403 abort: raise abort from hook
403 abort: raise abort from hook
404 [255]
404 [255]
405
405
406 $ echo '[hooks]' > ../a/.hg/hgrc
406 $ echo '[hooks]' > ../a/.hg/hgrc
407 $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
407 $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
408 $ hg pull ../a
408 $ hg pull ../a
409 pulling from ../a
409 pulling from ../a
410 searching for changes
410 searching for changes
411 hook args:
411 hook args:
412 hooktype preoutgoing
412 hooktype preoutgoing
413 source pull
413 source pull
414 abort: preoutgoing.fail hook failed
414 abort: preoutgoing.fail hook failed
415 [255]
415 [255]
416
416
417 $ echo '[hooks]' > ../a/.hg/hgrc
417 $ echo '[hooks]' > ../a/.hg/hgrc
418 $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
418 $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
419 $ hg pull ../a
419 $ hg pull ../a
420 pulling from ../a
420 pulling from ../a
421 searching for changes
421 searching for changes
422 abort: preoutgoing.uncallable hook is invalid ("hooktests.uncallable" is not callable)
422 abort: preoutgoing.uncallable hook is invalid ("hooktests.uncallable" is not callable)
423 [255]
423 [255]
424
424
425 $ echo '[hooks]' > ../a/.hg/hgrc
425 $ echo '[hooks]' > ../a/.hg/hgrc
426 $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
426 $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
427 $ hg pull ../a
427 $ hg pull ../a
428 pulling from ../a
428 pulling from ../a
429 searching for changes
429 searching for changes
430 abort: preoutgoing.nohook hook is invalid ("hooktests.nohook" is not defined)
430 abort: preoutgoing.nohook hook is invalid ("hooktests.nohook" is not defined)
431 [255]
431 [255]
432
432
433 $ echo '[hooks]' > ../a/.hg/hgrc
433 $ echo '[hooks]' > ../a/.hg/hgrc
434 $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
434 $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
435 $ hg pull ../a
435 $ hg pull ../a
436 pulling from ../a
436 pulling from ../a
437 searching for changes
437 searching for changes
438 abort: preoutgoing.nomodule hook is invalid ("nomodule" not in a module)
438 abort: preoutgoing.nomodule hook is invalid ("nomodule" not in a module)
439 [255]
439 [255]
440
440
441 $ echo '[hooks]' > ../a/.hg/hgrc
441 $ echo '[hooks]' > ../a/.hg/hgrc
442 $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
442 $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
443 $ hg pull ../a
443 $ hg pull ../a
444 pulling from ../a
444 pulling from ../a
445 searching for changes
445 searching for changes
446 abort: preoutgoing.badmodule hook is invalid (import of "nomodule" failed)
446 abort: preoutgoing.badmodule hook is invalid (import of "nomodule" failed)
447 [255]
447 [255]
448
448
449 $ echo '[hooks]' > ../a/.hg/hgrc
449 $ echo '[hooks]' > ../a/.hg/hgrc
450 $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
450 $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
451 $ hg pull ../a
451 $ hg pull ../a
452 pulling from ../a
452 pulling from ../a
453 searching for changes
453 searching for changes
454 abort: preoutgoing.unreachable hook is invalid (import of "hooktests.container" failed)
454 abort: preoutgoing.unreachable hook is invalid (import of "hooktests.container" failed)
455 [255]
455 [255]
456
456
457 $ echo '[hooks]' > ../a/.hg/hgrc
457 $ echo '[hooks]' > ../a/.hg/hgrc
458 $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
458 $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
459 $ hg pull ../a
459 $ hg pull ../a
460 pulling from ../a
460 pulling from ../a
461 searching for changes
461 searching for changes
462 hook args:
462 hook args:
463 hooktype preoutgoing
463 hooktype preoutgoing
464 source pull
464 source pull
465 adding changesets
465 adding changesets
466 adding manifests
466 adding manifests
467 adding file changes
467 adding file changes
468 added 1 changesets with 1 changes to 1 files
468 added 1 changesets with 1 changes to 1 files
469 adding remote bookmark quux
469 adding remote bookmark quux
470 (run 'hg update' to get a working copy)
470 (run 'hg update' to get a working copy)
471
471
472 make sure --traceback works
472 make sure --traceback works
473
473
474 $ echo '[hooks]' > .hg/hgrc
474 $ echo '[hooks]' > .hg/hgrc
475 $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
475 $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
476
476
477 $ echo aa > a
477 $ echo aa > a
478 $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback'
478 $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback'
479 Traceback (most recent call last):
479 Traceback (most recent call last):
480
480
481 $ cd ..
481 $ cd ..
482 $ hg init c
482 $ hg init c
483 $ cd c
483 $ cd c
484
484
485 $ cat > hookext.py <<EOF
485 $ cat > hookext.py <<EOF
486 > def autohook(**args):
486 > def autohook(**args):
487 > print "Automatically installed hook"
487 > print "Automatically installed hook"
488 >
488 >
489 > def reposetup(ui, repo):
489 > def reposetup(ui, repo):
490 > repo.ui.setconfig("hooks", "commit.auto", autohook)
490 > repo.ui.setconfig("hooks", "commit.auto", autohook)
491 > EOF
491 > EOF
492 $ echo '[extensions]' >> .hg/hgrc
492 $ echo '[extensions]' >> .hg/hgrc
493 $ echo 'hookext = hookext.py' >> .hg/hgrc
493 $ echo 'hookext = hookext.py' >> .hg/hgrc
494
494
495 $ touch foo
495 $ touch foo
496 $ hg add foo
496 $ hg add foo
497 $ hg ci -d '0 0' -m 'add foo'
497 $ hg ci -d '0 0' -m 'add foo'
498 Automatically installed hook
498 Automatically installed hook
499 $ echo >> foo
499 $ echo >> foo
500 $ hg ci --debug -d '0 0' -m 'change foo'
500 $ hg ci --debug -d '0 0' -m 'change foo'
501 foo
501 foo
502 calling hook commit.auto: <function autohook at *> (glob)
502 calling hook commit.auto: <function autohook at *> (glob)
503 Automatically installed hook
503 Automatically installed hook
504 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
504 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
505
505
506 $ hg showconfig hooks
506 $ hg showconfig hooks
507 hooks.commit.auto=<function autohook at *> (glob)
507 hooks.commit.auto=<function autohook at *> (glob)
508
508
509 test python hook configured with python:[file]:[hook] syntax
509 test python hook configured with python:[file]:[hook] syntax
510
510
511 $ cd ..
511 $ cd ..
512 $ mkdir d
512 $ mkdir d
513 $ cd d
513 $ cd d
514 $ hg init repo
514 $ hg init repo
515 $ mkdir hooks
515 $ mkdir hooks
516
516
517 $ cd hooks
517 $ cd hooks
518 $ cat > testhooks.py <<EOF
518 $ cat > testhooks.py <<EOF
519 > def testhook(**args):
519 > def testhook(**args):
520 > print 'hook works'
520 > print 'hook works'
521 > EOF
521 > EOF
522 $ echo '[hooks]' > ../repo/.hg/hgrc
522 $ echo '[hooks]' > ../repo/.hg/hgrc
523 $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
523 $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
524
524
525 $ cd ../repo
525 $ cd ../repo
526 $ hg commit -d '0 0'
526 $ hg commit -d '0 0'
527 hook works
527 hook works
528 nothing changed
528 nothing changed
529 [1]
529 [1]
530
530
531 $ echo '[hooks]' > .hg/hgrc
531 $ echo '[hooks]' > .hg/hgrc
532 $ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc
532 $ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc
533 $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc
533 $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc
534
534
535 $ hg up null
535 $ hg up null
536 loading update.ne hook failed:
536 loading update.ne hook failed:
537 abort: No such file or directory: $TESTTMP/d/repo/nonexistent.py
537 abort: No such file or directory: $TESTTMP/d/repo/nonexistent.py
538 [255]
538 [255]
539
539
540 $ hg id
540 $ hg id
541 loading pre-identify.npmd hook failed:
541 loading pre-identify.npmd hook failed:
542 abort: No module named repo!
542 abort: No module named repo!
543 [255]
543 [255]
544
544
545 $ cd ../../b
545 $ cd ../../b
546
546
547 make sure --traceback works on hook import failure
547 make sure --traceback works on hook import failure
548
548
549 $ cat > importfail.py <<EOF
549 $ cat > importfail.py <<EOF
550 > import somebogusmodule
550 > import somebogusmodule
551 > # dereference something in the module to force demandimport to load it
551 > # dereference something in the module to force demandimport to load it
552 > somebogusmodule.whatever
552 > somebogusmodule.whatever
553 > EOF
553 > EOF
554
554
555 $ echo '[hooks]' > .hg/hgrc
555 $ echo '[hooks]' > .hg/hgrc
556 $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
556 $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
557
557
558 $ echo a >> a
558 $ echo a >> a
559 $ hg --traceback commit -ma 2>&1 | egrep -v '^( +File| [a-zA-Z(])'
559 $ hg --traceback commit -ma 2>&1 | egrep -v '^( +File| [a-zA-Z(])'
560 exception from first failed import attempt:
560 exception from first failed import attempt:
561 Traceback (most recent call last):
561 Traceback (most recent call last):
562 ImportError: No module named somebogusmodule
562 ImportError: No module named somebogusmodule
563 exception from second failed import attempt:
563 exception from second failed import attempt:
564 Traceback (most recent call last):
564 Traceback (most recent call last):
565 ImportError: No module named hgext_importfail
565 ImportError: No module named hgext_importfail
566 Traceback (most recent call last):
566 Traceback (most recent call last):
567 Abort: precommit.importfail hook is invalid (import of "importfail" failed)
567 Abort: precommit.importfail hook is invalid (import of "importfail" failed)
568 abort: precommit.importfail hook is invalid (import of "importfail" failed)
568 abort: precommit.importfail hook is invalid (import of "importfail" failed)
569
569
570 Issue1827: Hooks Update & Commit not completely post operation
570 Issue1827: Hooks Update & Commit not completely post operation
571
571
572 commit and update hooks should run after command completion
572 commit and update hooks should run after command completion
573
573
574 $ echo '[hooks]' > .hg/hgrc
574 $ echo '[hooks]' > .hg/hgrc
575 $ echo 'commit = hg id' >> .hg/hgrc
575 $ echo 'commit = hg id' >> .hg/hgrc
576 $ echo 'update = hg id' >> .hg/hgrc
576 $ echo 'update = hg id' >> .hg/hgrc
577 $ echo bb > a
577 $ echo bb > a
578 $ hg ci -ma
578 $ hg ci -ma
579 223eafe2750c tip
579 223eafe2750c tip
580 $ hg up 0
580 $ hg up 0
581 cb9a9f314b8b
581 cb9a9f314b8b
582 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
582 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
583
583
584 make sure --verbose (and --quiet/--debug etc.) are propogated to the local ui
584 make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui
585 that is passed to pre/post hooks
585 that is passed to pre/post hooks
586
586
587 $ echo '[hooks]' > .hg/hgrc
587 $ echo '[hooks]' > .hg/hgrc
588 $ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc
588 $ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc
589 $ hg id
589 $ hg id
590 cb9a9f314b8b
590 cb9a9f314b8b
591 $ hg id --verbose
591 $ hg id --verbose
592 calling hook pre-identify: hooktests.verbosehook
592 calling hook pre-identify: hooktests.verbosehook
593 verbose output from hook
593 verbose output from hook
594 cb9a9f314b8b
594 cb9a9f314b8b
595
595
596 Ensure hooks can be prioritized
596 Ensure hooks can be prioritized
597
597
598 $ echo '[hooks]' > .hg/hgrc
598 $ echo '[hooks]' > .hg/hgrc
599 $ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc
599 $ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc
600 $ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc
600 $ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc
601 $ echo 'priority.pre-identify.b = 1' >> .hg/hgrc
601 $ echo 'priority.pre-identify.b = 1' >> .hg/hgrc
602 $ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc
602 $ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc
603 $ hg id --verbose
603 $ hg id --verbose
604 calling hook pre-identify.b: hooktests.verbosehook
604 calling hook pre-identify.b: hooktests.verbosehook
605 verbose output from hook
605 verbose output from hook
606 calling hook pre-identify.a: hooktests.verbosehook
606 calling hook pre-identify.a: hooktests.verbosehook
607 verbose output from hook
607 verbose output from hook
608 calling hook pre-identify.c: hooktests.verbosehook
608 calling hook pre-identify.c: hooktests.verbosehook
609 verbose output from hook
609 verbose output from hook
610 cb9a9f314b8b
610 cb9a9f314b8b
611
611
612 new tags must be visible in pretxncommit (issue3210)
612 new tags must be visible in pretxncommit (issue3210)
613
613
614 $ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc
614 $ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc
615 $ hg tag -f foo
615 $ hg tag -f foo
616 ['a', 'foo', 'tip']
616 ['a', 'foo', 'tip']
617
617
618 new commits must be visible in pretxnchangegroup (issue3428)
618 new commits must be visible in pretxnchangegroup (issue3428)
619
619
620 $ cd ..
620 $ cd ..
621 $ hg init to
621 $ hg init to
622 $ echo '[hooks]' >> to/.hg/hgrc
622 $ echo '[hooks]' >> to/.hg/hgrc
623 $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc
623 $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc
624 $ echo a >> to/a
624 $ echo a >> to/a
625 $ hg --cwd to ci -Ama
625 $ hg --cwd to ci -Ama
626 adding a
626 adding a
627 $ hg clone to from
627 $ hg clone to from
628 updating to branch default
628 updating to branch default
629 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
629 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
630 $ echo aa >> from/a
630 $ echo aa >> from/a
631 $ hg --cwd from ci -mb
631 $ hg --cwd from ci -mb
632 $ hg --cwd from push
632 $ hg --cwd from push
633 pushing to $TESTTMP/to (glob)
633 pushing to $TESTTMP/to (glob)
634 searching for changes
634 searching for changes
635 adding changesets
635 adding changesets
636 adding manifests
636 adding manifests
637 adding file changes
637 adding file changes
638 added 1 changesets with 1 changes to 1 files
638 added 1 changesets with 1 changes to 1 files
639 changeset: 1:9836a07b9b9d
639 changeset: 1:9836a07b9b9d
640 tag: tip
640 tag: tip
641 user: test
641 user: test
642 date: Thu Jan 01 00:00:00 1970 +0000
642 date: Thu Jan 01 00:00:00 1970 +0000
643 summary: b
643 summary: b
644
644
General Comments 0
You need to be logged in to leave comments. Login now