##// END OF EJS Templates
tests: remove bundle2 activation from test-hook.t...
Pierre-Yves David -
r29655:b55bfbb9 default
parent child Browse files
Show More
@@ -1,875 +1,869
1 commit hooks can see env vars
1 commit hooks can see env vars
2 (and post-transaction one are run unlocked)
2 (and post-transaction one are run unlocked)
3
3
4 $ cat << EOF >> $HGRCPATH
5 > [experimental]
6 > # drop me once bundle2 is the default,
7 > # added to get test change early.
8 > bundle2-exp = True
9 > EOF
10
4
11 $ cat > $TESTTMP/txnabort.checkargs.py <<EOF
5 $ cat > $TESTTMP/txnabort.checkargs.py <<EOF
12 > def showargs(ui, repo, hooktype, **kwargs):
6 > def showargs(ui, repo, hooktype, **kwargs):
13 > ui.write('%s python hook: %s\n' % (hooktype, ','.join(sorted(kwargs))))
7 > ui.write('%s python hook: %s\n' % (hooktype, ','.join(sorted(kwargs))))
14 > EOF
8 > EOF
15
9
16 $ hg init a
10 $ hg init a
17 $ cd a
11 $ cd a
18 $ cat > .hg/hgrc <<EOF
12 $ cat > .hg/hgrc <<EOF
19 > [hooks]
13 > [hooks]
20 > commit = sh -c "HG_LOCAL= HG_TAG= printenv.py commit"
14 > commit = sh -c "HG_LOCAL= HG_TAG= printenv.py commit"
21 > commit.b = sh -c "HG_LOCAL= HG_TAG= printenv.py commit.b"
15 > commit.b = sh -c "HG_LOCAL= HG_TAG= printenv.py commit.b"
22 > precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= printenv.py precommit"
16 > precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= printenv.py precommit"
23 > pretxncommit = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxncommit"
17 > pretxncommit = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxncommit"
24 > pretxncommit.tip = hg -q tip
18 > pretxncommit.tip = hg -q tip
25 > pre-identify = printenv.py pre-identify 1
19 > pre-identify = printenv.py pre-identify 1
26 > pre-cat = printenv.py pre-cat
20 > pre-cat = printenv.py pre-cat
27 > post-cat = printenv.py post-cat
21 > post-cat = printenv.py post-cat
28 > pretxnopen = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnopen"
22 > pretxnopen = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnopen"
29 > pretxnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnclose"
23 > pretxnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnclose"
30 > txnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py txnclose"
24 > txnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py txnclose"
31 > txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs
25 > txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs
32 > txnabort.1 = sh -c "HG_LOCAL= HG_TAG= printenv.py txnabort"
26 > txnabort.1 = sh -c "HG_LOCAL= HG_TAG= printenv.py txnabort"
33 > txnclose.checklock = sh -c "hg debuglock > /dev/null"
27 > txnclose.checklock = sh -c "hg debuglock > /dev/null"
34 > EOF
28 > EOF
35 $ echo a > a
29 $ echo a > a
36 $ hg add a
30 $ hg add a
37 $ hg commit -m a
31 $ hg commit -m a
38 precommit hook: HG_PARENT1=0000000000000000000000000000000000000000
32 precommit hook: HG_PARENT1=0000000000000000000000000000000000000000
39 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
33 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
40 pretxncommit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$TESTTMP/a
34 pretxncommit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$TESTTMP/a
41 0:cb9a9f314b8b
35 0:cb9a9f314b8b
42 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
36 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
43 txnclose hook: HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
37 txnclose hook: HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
44 commit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
38 commit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
45 commit.b hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
39 commit.b hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
46
40
47 $ hg clone . ../b
41 $ hg clone . ../b
48 updating to branch default
42 updating to branch default
49 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
43 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
50 $ cd ../b
44 $ cd ../b
51
45
52 changegroup hooks can see env vars
46 changegroup hooks can see env vars
53
47
54 $ cat > .hg/hgrc <<EOF
48 $ cat > .hg/hgrc <<EOF
55 > [hooks]
49 > [hooks]
56 > prechangegroup = printenv.py prechangegroup
50 > prechangegroup = printenv.py prechangegroup
57 > changegroup = printenv.py changegroup
51 > changegroup = printenv.py changegroup
58 > incoming = printenv.py incoming
52 > incoming = printenv.py incoming
59 > EOF
53 > EOF
60
54
61 pretxncommit and commit hooks can see both parents of merge
55 pretxncommit and commit hooks can see both parents of merge
62
56
63 $ cd ../a
57 $ cd ../a
64 $ echo b >> a
58 $ echo b >> a
65 $ hg commit -m a1 -d "1 0"
59 $ hg commit -m a1 -d "1 0"
66 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
60 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
67 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
61 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
68 pretxncommit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
62 pretxncommit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
69 1:ab228980c14d
63 1:ab228980c14d
70 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
64 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
71 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
65 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
72 commit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
66 commit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
73 commit.b hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
67 commit.b hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
74 $ hg update -C 0
68 $ hg update -C 0
75 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
69 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
76 $ echo b > b
70 $ echo b > b
77 $ hg add b
71 $ hg add b
78 $ hg commit -m b -d '1 0'
72 $ hg commit -m b -d '1 0'
79 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
73 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
80 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
74 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
81 pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
75 pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
82 2:ee9deb46ab31
76 2:ee9deb46ab31
83 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
77 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
84 created new head
78 created new head
85 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
79 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
86 commit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
80 commit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
87 commit.b hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
81 commit.b hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
88 $ hg merge 1
82 $ hg merge 1
89 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
83 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
90 (branch merge, don't forget to commit)
84 (branch merge, don't forget to commit)
91 $ hg commit -m merge -d '2 0'
85 $ hg commit -m merge -d '2 0'
92 precommit hook: HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
86 precommit hook: HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
93 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
87 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
94 pretxncommit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$TESTTMP/a
88 pretxncommit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$TESTTMP/a
95 3:07f3376c1e65
89 3:07f3376c1e65
96 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
90 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
97 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
91 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
98 commit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
92 commit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
99 commit.b hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
93 commit.b hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
100
94
101 test generic hooks
95 test generic hooks
102
96
103 $ hg id
97 $ hg id
104 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=[]
98 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=[]
105 abort: pre-identify hook exited with status 1
99 abort: pre-identify hook exited with status 1
106 [255]
100 [255]
107 $ hg cat b
101 $ hg cat b
108 pre-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b']
102 pre-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b']
109 b
103 b
110 post-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b'] HG_RESULT=0
104 post-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b'] HG_RESULT=0
111
105
112 $ cd ../b
106 $ cd ../b
113 $ hg pull ../a
107 $ hg pull ../a
114 pulling from ../a
108 pulling from ../a
115 searching for changes
109 searching for changes
116 prechangegroup hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
110 prechangegroup hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
117 adding changesets
111 adding changesets
118 adding manifests
112 adding manifests
119 adding file changes
113 adding file changes
120 added 3 changesets with 2 changes to 2 files
114 added 3 changesets with 2 changes to 2 files
121 changegroup hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_NODE_LAST=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
115 changegroup hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_NODE_LAST=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
122 incoming hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
116 incoming hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
123 incoming hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
117 incoming hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
124 incoming hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
118 incoming hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
125 (run 'hg update' to get a working copy)
119 (run 'hg update' to get a working copy)
126
120
127 tag hooks can see env vars
121 tag hooks can see env vars
128
122
129 $ cd ../a
123 $ cd ../a
130 $ cat >> .hg/hgrc <<EOF
124 $ cat >> .hg/hgrc <<EOF
131 > pretag = printenv.py pretag
125 > pretag = printenv.py pretag
132 > tag = sh -c "HG_PARENT1= HG_PARENT2= printenv.py tag"
126 > tag = sh -c "HG_PARENT1= HG_PARENT2= printenv.py tag"
133 > EOF
127 > EOF
134 $ hg tag -d '3 0' a
128 $ hg tag -d '3 0' a
135 pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
129 pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
136 precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
130 precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
137 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
131 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
138 pretxncommit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$TESTTMP/a
132 pretxncommit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$TESTTMP/a
139 4:539e4b31b6dc
133 4:539e4b31b6dc
140 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
134 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
141 tag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
135 tag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
142 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
136 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
143 commit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
137 commit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
144 commit.b hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
138 commit.b hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
145 $ hg tag -l la
139 $ hg tag -l la
146 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
140 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
147 tag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
141 tag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
148
142
149 pretag hook can forbid tagging
143 pretag hook can forbid tagging
150
144
151 $ echo "pretag.forbid = printenv.py pretag.forbid 1" >> .hg/hgrc
145 $ echo "pretag.forbid = printenv.py pretag.forbid 1" >> .hg/hgrc
152 $ hg tag -d '4 0' fa
146 $ hg tag -d '4 0' fa
153 pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
147 pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
154 pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
148 pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
155 abort: pretag.forbid hook exited with status 1
149 abort: pretag.forbid hook exited with status 1
156 [255]
150 [255]
157 $ hg tag -l fla
151 $ hg tag -l fla
158 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
152 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
159 pretag.forbid hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
153 pretag.forbid hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
160 abort: pretag.forbid hook exited with status 1
154 abort: pretag.forbid hook exited with status 1
161 [255]
155 [255]
162
156
163 pretxncommit hook can see changeset, can roll back txn, changeset no
157 pretxncommit hook can see changeset, can roll back txn, changeset no
164 more there after
158 more there after
165
159
166 $ echo "pretxncommit.forbid0 = hg tip -q" >> .hg/hgrc
160 $ echo "pretxncommit.forbid0 = hg tip -q" >> .hg/hgrc
167 $ echo "pretxncommit.forbid1 = printenv.py pretxncommit.forbid 1" >> .hg/hgrc
161 $ echo "pretxncommit.forbid1 = printenv.py pretxncommit.forbid 1" >> .hg/hgrc
168 $ echo z > z
162 $ echo z > z
169 $ hg add z
163 $ hg add z
170 $ hg -q tip
164 $ hg -q tip
171 4:539e4b31b6dc
165 4:539e4b31b6dc
172 $ hg commit -m 'fail' -d '4 0'
166 $ hg commit -m 'fail' -d '4 0'
173 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
167 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
174 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
168 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
175 pretxncommit hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
169 pretxncommit hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
176 5:6f611f8018c1
170 5:6f611f8018c1
177 5:6f611f8018c1
171 5:6f611f8018c1
178 pretxncommit.forbid hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
172 pretxncommit.forbid hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
179 transaction abort!
173 transaction abort!
180 txnabort python hook: txnid,txnname
174 txnabort python hook: txnid,txnname
181 txnabort hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
175 txnabort hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
182 rollback completed
176 rollback completed
183 abort: pretxncommit.forbid1 hook exited with status 1
177 abort: pretxncommit.forbid1 hook exited with status 1
184 [255]
178 [255]
185 $ hg -q tip
179 $ hg -q tip
186 4:539e4b31b6dc
180 4:539e4b31b6dc
187
181
188 (Check that no 'changelog.i.a' file were left behind)
182 (Check that no 'changelog.i.a' file were left behind)
189
183
190 $ ls -1 .hg/store/
184 $ ls -1 .hg/store/
191 00changelog.i
185 00changelog.i
192 00manifest.i
186 00manifest.i
193 data
187 data
194 fncache
188 fncache
195 journal.phaseroots
189 journal.phaseroots
196 phaseroots
190 phaseroots
197 undo
191 undo
198 undo.backup.fncache
192 undo.backup.fncache
199 undo.backupfiles
193 undo.backupfiles
200 undo.phaseroots
194 undo.phaseroots
201
195
202
196
203 precommit hook can prevent commit
197 precommit hook can prevent commit
204
198
205 $ echo "precommit.forbid = printenv.py precommit.forbid 1" >> .hg/hgrc
199 $ echo "precommit.forbid = printenv.py precommit.forbid 1" >> .hg/hgrc
206 $ hg commit -m 'fail' -d '4 0'
200 $ hg commit -m 'fail' -d '4 0'
207 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
201 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
208 precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
202 precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
209 abort: precommit.forbid hook exited with status 1
203 abort: precommit.forbid hook exited with status 1
210 [255]
204 [255]
211 $ hg -q tip
205 $ hg -q tip
212 4:539e4b31b6dc
206 4:539e4b31b6dc
213
207
214 preupdate hook can prevent update
208 preupdate hook can prevent update
215
209
216 $ echo "preupdate = printenv.py preupdate" >> .hg/hgrc
210 $ echo "preupdate = printenv.py preupdate" >> .hg/hgrc
217 $ hg update 1
211 $ hg update 1
218 preupdate hook: HG_PARENT1=ab228980c14d
212 preupdate hook: HG_PARENT1=ab228980c14d
219 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
213 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
220
214
221 update hook
215 update hook
222
216
223 $ echo "update = printenv.py update" >> .hg/hgrc
217 $ echo "update = printenv.py update" >> .hg/hgrc
224 $ hg update
218 $ hg update
225 preupdate hook: HG_PARENT1=539e4b31b6dc
219 preupdate hook: HG_PARENT1=539e4b31b6dc
226 update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc
220 update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc
227 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
221 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
228
222
229 pushkey hook
223 pushkey hook
230
224
231 $ echo "pushkey = printenv.py pushkey" >> .hg/hgrc
225 $ echo "pushkey = printenv.py pushkey" >> .hg/hgrc
232 $ cd ../b
226 $ cd ../b
233 $ hg bookmark -r null foo
227 $ hg bookmark -r null foo
234 $ hg push -B foo ../a
228 $ hg push -B foo ../a
235 pushing to ../a
229 pushing to ../a
236 searching for changes
230 searching for changes
237 no changes found
231 no changes found
238 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=push (glob)
232 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=push (glob)
239 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_PENDING=$TESTTMP/a HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=push (glob)
233 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_PENDING=$TESTTMP/a HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=push (glob)
240 pushkey hook: HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1
234 pushkey hook: HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1
241 txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=push (glob)
235 txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=push (glob)
242 exporting bookmark foo
236 exporting bookmark foo
243 [1]
237 [1]
244 $ cd ../a
238 $ cd ../a
245
239
246 listkeys hook
240 listkeys hook
247
241
248 $ echo "listkeys = printenv.py listkeys" >> .hg/hgrc
242 $ echo "listkeys = printenv.py listkeys" >> .hg/hgrc
249 $ hg bookmark -r null bar
243 $ hg bookmark -r null bar
250 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
244 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
251 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
245 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
252 txnclose hook: HG_BOOKMARK_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
246 txnclose hook: HG_BOOKMARK_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
253 $ cd ../b
247 $ cd ../b
254 $ hg pull -B bar ../a
248 $ hg pull -B bar ../a
255 pulling from ../a
249 pulling from ../a
256 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
250 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
257 no changes found
251 no changes found
258 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
252 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
259 adding remote bookmark bar
253 adding remote bookmark bar
260 $ cd ../a
254 $ cd ../a
261
255
262 test that prepushkey can prevent incoming keys
256 test that prepushkey can prevent incoming keys
263
257
264 $ echo "prepushkey = printenv.py prepushkey.forbid 1" >> .hg/hgrc
258 $ echo "prepushkey = printenv.py prepushkey.forbid 1" >> .hg/hgrc
265 $ cd ../b
259 $ cd ../b
266 $ hg bookmark -r null baz
260 $ hg bookmark -r null baz
267 $ hg push -B baz ../a
261 $ hg push -B baz ../a
268 pushing to ../a
262 pushing to ../a
269 searching for changes
263 searching for changes
270 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
264 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
271 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
265 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
272 no changes found
266 no changes found
273 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=push (glob)
267 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=push (glob)
274 prepushkey.forbid hook: HG_BUNDLE2=1 HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_SOURCE=push HG_TXNID=TXN:* HG_URL=push (glob)
268 prepushkey.forbid hook: HG_BUNDLE2=1 HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_SOURCE=push HG_TXNID=TXN:* HG_URL=push (glob)
275 pushkey-abort: prepushkey hook exited with status 1
269 pushkey-abort: prepushkey hook exited with status 1
276 abort: exporting bookmark baz failed!
270 abort: exporting bookmark baz failed!
277 [255]
271 [255]
278 $ cd ../a
272 $ cd ../a
279
273
280 test that prelistkeys can prevent listing keys
274 test that prelistkeys can prevent listing keys
281
275
282 $ echo "prelistkeys = printenv.py prelistkeys.forbid 1" >> .hg/hgrc
276 $ echo "prelistkeys = printenv.py prelistkeys.forbid 1" >> .hg/hgrc
283 $ hg bookmark -r null quux
277 $ hg bookmark -r null quux
284 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
278 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
285 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
279 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
286 txnclose hook: HG_BOOKMARK_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
280 txnclose hook: HG_BOOKMARK_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
287 $ cd ../b
281 $ cd ../b
288 $ hg pull -B quux ../a
282 $ hg pull -B quux ../a
289 pulling from ../a
283 pulling from ../a
290 prelistkeys.forbid hook: HG_NAMESPACE=bookmarks
284 prelistkeys.forbid hook: HG_NAMESPACE=bookmarks
291 abort: prelistkeys hook exited with status 1
285 abort: prelistkeys hook exited with status 1
292 [255]
286 [255]
293 $ cd ../a
287 $ cd ../a
294 $ rm .hg/hgrc
288 $ rm .hg/hgrc
295
289
296 prechangegroup hook can prevent incoming changes
290 prechangegroup hook can prevent incoming changes
297
291
298 $ cd ../b
292 $ cd ../b
299 $ hg -q tip
293 $ hg -q tip
300 3:07f3376c1e65
294 3:07f3376c1e65
301 $ cat > .hg/hgrc <<EOF
295 $ cat > .hg/hgrc <<EOF
302 > [hooks]
296 > [hooks]
303 > prechangegroup.forbid = printenv.py prechangegroup.forbid 1
297 > prechangegroup.forbid = printenv.py prechangegroup.forbid 1
304 > EOF
298 > EOF
305 $ hg pull ../a
299 $ hg pull ../a
306 pulling from ../a
300 pulling from ../a
307 searching for changes
301 searching for changes
308 prechangegroup.forbid hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
302 prechangegroup.forbid hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
309 abort: prechangegroup.forbid hook exited with status 1
303 abort: prechangegroup.forbid hook exited with status 1
310 [255]
304 [255]
311
305
312 pretxnchangegroup hook can see incoming changes, can roll back txn,
306 pretxnchangegroup hook can see incoming changes, can roll back txn,
313 incoming changes no longer there after
307 incoming changes no longer there after
314
308
315 $ cat > .hg/hgrc <<EOF
309 $ cat > .hg/hgrc <<EOF
316 > [hooks]
310 > [hooks]
317 > pretxnchangegroup.forbid0 = hg tip -q
311 > pretxnchangegroup.forbid0 = hg tip -q
318 > pretxnchangegroup.forbid1 = printenv.py pretxnchangegroup.forbid 1
312 > pretxnchangegroup.forbid1 = printenv.py pretxnchangegroup.forbid 1
319 > EOF
313 > EOF
320 $ hg pull ../a
314 $ hg pull ../a
321 pulling from ../a
315 pulling from ../a
322 searching for changes
316 searching for changes
323 adding changesets
317 adding changesets
324 adding manifests
318 adding manifests
325 adding file changes
319 adding file changes
326 added 1 changesets with 1 changes to 1 files
320 added 1 changesets with 1 changes to 1 files
327 4:539e4b31b6dc
321 4:539e4b31b6dc
328 pretxnchangegroup.forbid hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_NODE_LAST=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/b HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
322 pretxnchangegroup.forbid hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_NODE_LAST=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/b HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
329 transaction abort!
323 transaction abort!
330 rollback completed
324 rollback completed
331 abort: pretxnchangegroup.forbid1 hook exited with status 1
325 abort: pretxnchangegroup.forbid1 hook exited with status 1
332 [255]
326 [255]
333 $ hg -q tip
327 $ hg -q tip
334 3:07f3376c1e65
328 3:07f3376c1e65
335
329
336 outgoing hooks can see env vars
330 outgoing hooks can see env vars
337
331
338 $ rm .hg/hgrc
332 $ rm .hg/hgrc
339 $ cat > ../a/.hg/hgrc <<EOF
333 $ cat > ../a/.hg/hgrc <<EOF
340 > [hooks]
334 > [hooks]
341 > preoutgoing = printenv.py preoutgoing
335 > preoutgoing = printenv.py preoutgoing
342 > outgoing = printenv.py outgoing
336 > outgoing = printenv.py outgoing
343 > EOF
337 > EOF
344 $ hg pull ../a
338 $ hg pull ../a
345 pulling from ../a
339 pulling from ../a
346 searching for changes
340 searching for changes
347 preoutgoing hook: HG_SOURCE=pull
341 preoutgoing hook: HG_SOURCE=pull
348 outgoing hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_SOURCE=pull
342 outgoing hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_SOURCE=pull
349 adding changesets
343 adding changesets
350 adding manifests
344 adding manifests
351 adding file changes
345 adding file changes
352 added 1 changesets with 1 changes to 1 files
346 added 1 changesets with 1 changes to 1 files
353 adding remote bookmark quux
347 adding remote bookmark quux
354 (run 'hg update' to get a working copy)
348 (run 'hg update' to get a working copy)
355 $ hg rollback
349 $ hg rollback
356 repository tip rolled back to revision 3 (undo pull)
350 repository tip rolled back to revision 3 (undo pull)
357
351
358 preoutgoing hook can prevent outgoing changes
352 preoutgoing hook can prevent outgoing changes
359
353
360 $ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> ../a/.hg/hgrc
354 $ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> ../a/.hg/hgrc
361 $ hg pull ../a
355 $ hg pull ../a
362 pulling from ../a
356 pulling from ../a
363 searching for changes
357 searching for changes
364 preoutgoing hook: HG_SOURCE=pull
358 preoutgoing hook: HG_SOURCE=pull
365 preoutgoing.forbid hook: HG_SOURCE=pull
359 preoutgoing.forbid hook: HG_SOURCE=pull
366 abort: preoutgoing.forbid hook exited with status 1
360 abort: preoutgoing.forbid hook exited with status 1
367 [255]
361 [255]
368
362
369 outgoing hooks work for local clones
363 outgoing hooks work for local clones
370
364
371 $ cd ..
365 $ cd ..
372 $ cat > a/.hg/hgrc <<EOF
366 $ cat > a/.hg/hgrc <<EOF
373 > [hooks]
367 > [hooks]
374 > preoutgoing = printenv.py preoutgoing
368 > preoutgoing = printenv.py preoutgoing
375 > outgoing = printenv.py outgoing
369 > outgoing = printenv.py outgoing
376 > EOF
370 > EOF
377 $ hg clone a c
371 $ hg clone a c
378 preoutgoing hook: HG_SOURCE=clone
372 preoutgoing hook: HG_SOURCE=clone
379 outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone
373 outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone
380 updating to branch default
374 updating to branch default
381 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
375 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
382 $ rm -rf c
376 $ rm -rf c
383
377
384 preoutgoing hook can prevent outgoing changes for local clones
378 preoutgoing hook can prevent outgoing changes for local clones
385
379
386 $ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> a/.hg/hgrc
380 $ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> a/.hg/hgrc
387 $ hg clone a zzz
381 $ hg clone a zzz
388 preoutgoing hook: HG_SOURCE=clone
382 preoutgoing hook: HG_SOURCE=clone
389 preoutgoing.forbid hook: HG_SOURCE=clone
383 preoutgoing.forbid hook: HG_SOURCE=clone
390 abort: preoutgoing.forbid hook exited with status 1
384 abort: preoutgoing.forbid hook exited with status 1
391 [255]
385 [255]
392
386
393 $ cd "$TESTTMP/b"
387 $ cd "$TESTTMP/b"
394
388
395 $ cat > hooktests.py <<EOF
389 $ cat > hooktests.py <<EOF
396 > from mercurial import error
390 > from mercurial import error
397 >
391 >
398 > uncallable = 0
392 > uncallable = 0
399 >
393 >
400 > def printargs(args):
394 > def printargs(args):
401 > args.pop('ui', None)
395 > args.pop('ui', None)
402 > args.pop('repo', None)
396 > args.pop('repo', None)
403 > a = list(args.items())
397 > a = list(args.items())
404 > a.sort()
398 > a.sort()
405 > print 'hook args:'
399 > print 'hook args:'
406 > for k, v in a:
400 > for k, v in a:
407 > print ' ', k, v
401 > print ' ', k, v
408 >
402 >
409 > def passhook(**args):
403 > def passhook(**args):
410 > printargs(args)
404 > printargs(args)
411 >
405 >
412 > def failhook(**args):
406 > def failhook(**args):
413 > printargs(args)
407 > printargs(args)
414 > return True
408 > return True
415 >
409 >
416 > class LocalException(Exception):
410 > class LocalException(Exception):
417 > pass
411 > pass
418 >
412 >
419 > def raisehook(**args):
413 > def raisehook(**args):
420 > raise LocalException('exception from hook')
414 > raise LocalException('exception from hook')
421 >
415 >
422 > def aborthook(**args):
416 > def aborthook(**args):
423 > raise error.Abort('raise abort from hook')
417 > raise error.Abort('raise abort from hook')
424 >
418 >
425 > def brokenhook(**args):
419 > def brokenhook(**args):
426 > return 1 + {}
420 > return 1 + {}
427 >
421 >
428 > def verbosehook(ui, **args):
422 > def verbosehook(ui, **args):
429 > ui.note('verbose output from hook\n')
423 > ui.note('verbose output from hook\n')
430 >
424 >
431 > def printtags(ui, repo, **args):
425 > def printtags(ui, repo, **args):
432 > print sorted(repo.tags())
426 > print sorted(repo.tags())
433 >
427 >
434 > class container:
428 > class container:
435 > unreachable = 1
429 > unreachable = 1
436 > EOF
430 > EOF
437
431
438 $ cat > syntaxerror.py << EOF
432 $ cat > syntaxerror.py << EOF
439 > (foo
433 > (foo
440 > EOF
434 > EOF
441
435
442 test python hooks
436 test python hooks
443
437
444 #if windows
438 #if windows
445 $ PYTHONPATH="$TESTTMP/b;$PYTHONPATH"
439 $ PYTHONPATH="$TESTTMP/b;$PYTHONPATH"
446 #else
440 #else
447 $ PYTHONPATH="$TESTTMP/b:$PYTHONPATH"
441 $ PYTHONPATH="$TESTTMP/b:$PYTHONPATH"
448 #endif
442 #endif
449 $ export PYTHONPATH
443 $ export PYTHONPATH
450
444
451 $ echo '[hooks]' > ../a/.hg/hgrc
445 $ echo '[hooks]' > ../a/.hg/hgrc
452 $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
446 $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
453 $ hg pull ../a 2>&1 | grep 'raised an exception'
447 $ hg pull ../a 2>&1 | grep 'raised an exception'
454 error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
448 error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
455
449
456 $ echo '[hooks]' > ../a/.hg/hgrc
450 $ echo '[hooks]' > ../a/.hg/hgrc
457 $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
451 $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
458 $ hg pull ../a 2>&1 | grep 'raised an exception'
452 $ hg pull ../a 2>&1 | grep 'raised an exception'
459 error: preoutgoing.raise hook raised an exception: exception from hook
453 error: preoutgoing.raise hook raised an exception: exception from hook
460
454
461 $ echo '[hooks]' > ../a/.hg/hgrc
455 $ echo '[hooks]' > ../a/.hg/hgrc
462 $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
456 $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
463 $ hg pull ../a
457 $ hg pull ../a
464 pulling from ../a
458 pulling from ../a
465 searching for changes
459 searching for changes
466 error: preoutgoing.abort hook failed: raise abort from hook
460 error: preoutgoing.abort hook failed: raise abort from hook
467 abort: raise abort from hook
461 abort: raise abort from hook
468 [255]
462 [255]
469
463
470 $ echo '[hooks]' > ../a/.hg/hgrc
464 $ echo '[hooks]' > ../a/.hg/hgrc
471 $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
465 $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
472 $ hg pull ../a
466 $ hg pull ../a
473 pulling from ../a
467 pulling from ../a
474 searching for changes
468 searching for changes
475 hook args:
469 hook args:
476 hooktype preoutgoing
470 hooktype preoutgoing
477 source pull
471 source pull
478 abort: preoutgoing.fail hook failed
472 abort: preoutgoing.fail hook failed
479 [255]
473 [255]
480
474
481 $ echo '[hooks]' > ../a/.hg/hgrc
475 $ echo '[hooks]' > ../a/.hg/hgrc
482 $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
476 $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
483 $ hg pull ../a
477 $ hg pull ../a
484 pulling from ../a
478 pulling from ../a
485 searching for changes
479 searching for changes
486 abort: preoutgoing.uncallable hook is invalid: "hooktests.uncallable" is not callable
480 abort: preoutgoing.uncallable hook is invalid: "hooktests.uncallable" is not callable
487 [255]
481 [255]
488
482
489 $ echo '[hooks]' > ../a/.hg/hgrc
483 $ echo '[hooks]' > ../a/.hg/hgrc
490 $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
484 $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
491 $ hg pull ../a
485 $ hg pull ../a
492 pulling from ../a
486 pulling from ../a
493 searching for changes
487 searching for changes
494 abort: preoutgoing.nohook hook is invalid: "hooktests.nohook" is not defined
488 abort: preoutgoing.nohook hook is invalid: "hooktests.nohook" is not defined
495 [255]
489 [255]
496
490
497 $ echo '[hooks]' > ../a/.hg/hgrc
491 $ echo '[hooks]' > ../a/.hg/hgrc
498 $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
492 $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
499 $ hg pull ../a
493 $ hg pull ../a
500 pulling from ../a
494 pulling from ../a
501 searching for changes
495 searching for changes
502 abort: preoutgoing.nomodule hook is invalid: "nomodule" not in a module
496 abort: preoutgoing.nomodule hook is invalid: "nomodule" not in a module
503 [255]
497 [255]
504
498
505 $ echo '[hooks]' > ../a/.hg/hgrc
499 $ echo '[hooks]' > ../a/.hg/hgrc
506 $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
500 $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
507 $ hg pull ../a
501 $ hg pull ../a
508 pulling from ../a
502 pulling from ../a
509 searching for changes
503 searching for changes
510 abort: preoutgoing.badmodule hook is invalid: import of "nomodule" failed
504 abort: preoutgoing.badmodule hook is invalid: import of "nomodule" failed
511 (run with --traceback for stack trace)
505 (run with --traceback for stack trace)
512 [255]
506 [255]
513
507
514 $ echo '[hooks]' > ../a/.hg/hgrc
508 $ echo '[hooks]' > ../a/.hg/hgrc
515 $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
509 $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
516 $ hg pull ../a
510 $ hg pull ../a
517 pulling from ../a
511 pulling from ../a
518 searching for changes
512 searching for changes
519 abort: preoutgoing.unreachable hook is invalid: import of "hooktests.container" failed
513 abort: preoutgoing.unreachable hook is invalid: import of "hooktests.container" failed
520 (run with --traceback for stack trace)
514 (run with --traceback for stack trace)
521 [255]
515 [255]
522
516
523 $ echo '[hooks]' > ../a/.hg/hgrc
517 $ echo '[hooks]' > ../a/.hg/hgrc
524 $ echo 'preoutgoing.syntaxerror = python:syntaxerror.syntaxerror' >> ../a/.hg/hgrc
518 $ echo 'preoutgoing.syntaxerror = python:syntaxerror.syntaxerror' >> ../a/.hg/hgrc
525 $ hg pull ../a
519 $ hg pull ../a
526 pulling from ../a
520 pulling from ../a
527 searching for changes
521 searching for changes
528 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
522 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
529 (run with --traceback for stack trace)
523 (run with --traceback for stack trace)
530 [255]
524 [255]
531
525
532 The second egrep is to filter out lines like ' ^', which are slightly
526 The second egrep is to filter out lines like ' ^', which are slightly
533 different between Python 2.6 and Python 2.7.
527 different between Python 2.6 and Python 2.7.
534 $ hg pull ../a --traceback 2>&1 | egrep -v '^( +File| [_a-zA-Z*(])' | egrep -v '^( )+(\^)?$'
528 $ hg pull ../a --traceback 2>&1 | egrep -v '^( +File| [_a-zA-Z*(])' | egrep -v '^( )+(\^)?$'
535 pulling from ../a
529 pulling from ../a
536 searching for changes
530 searching for changes
537 exception from first failed import attempt:
531 exception from first failed import attempt:
538 Traceback (most recent call last):
532 Traceback (most recent call last):
539 SyntaxError: * (glob)
533 SyntaxError: * (glob)
540 exception from second failed import attempt:
534 exception from second failed import attempt:
541 Traceback (most recent call last):
535 Traceback (most recent call last):
542 ImportError: No module named hgext_syntaxerror
536 ImportError: No module named hgext_syntaxerror
543 Traceback (most recent call last):
537 Traceback (most recent call last):
544 HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
538 HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
545 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
539 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
546
540
547 $ echo '[hooks]' > ../a/.hg/hgrc
541 $ echo '[hooks]' > ../a/.hg/hgrc
548 $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
542 $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
549 $ hg pull ../a
543 $ hg pull ../a
550 pulling from ../a
544 pulling from ../a
551 searching for changes
545 searching for changes
552 hook args:
546 hook args:
553 hooktype preoutgoing
547 hooktype preoutgoing
554 source pull
548 source pull
555 adding changesets
549 adding changesets
556 adding manifests
550 adding manifests
557 adding file changes
551 adding file changes
558 added 1 changesets with 1 changes to 1 files
552 added 1 changesets with 1 changes to 1 files
559 adding remote bookmark quux
553 adding remote bookmark quux
560 (run 'hg update' to get a working copy)
554 (run 'hg update' to get a working copy)
561
555
562 post- python hooks that fail to *run* don't cause an abort
556 post- python hooks that fail to *run* don't cause an abort
563 $ rm ../a/.hg/hgrc
557 $ rm ../a/.hg/hgrc
564 $ echo '[hooks]' > .hg/hgrc
558 $ echo '[hooks]' > .hg/hgrc
565 $ echo 'post-pull.broken = python:hooktests.brokenhook' >> .hg/hgrc
559 $ echo 'post-pull.broken = python:hooktests.brokenhook' >> .hg/hgrc
566 $ hg pull ../a
560 $ hg pull ../a
567 pulling from ../a
561 pulling from ../a
568 searching for changes
562 searching for changes
569 no changes found
563 no changes found
570 error: post-pull.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
564 error: post-pull.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
571 (run with --traceback for stack trace)
565 (run with --traceback for stack trace)
572
566
573 but post- python hooks that fail to *load* do
567 but post- python hooks that fail to *load* do
574 $ echo '[hooks]' > .hg/hgrc
568 $ echo '[hooks]' > .hg/hgrc
575 $ echo 'post-pull.nomodule = python:nomodule' >> .hg/hgrc
569 $ echo 'post-pull.nomodule = python:nomodule' >> .hg/hgrc
576 $ hg pull ../a
570 $ hg pull ../a
577 pulling from ../a
571 pulling from ../a
578 searching for changes
572 searching for changes
579 no changes found
573 no changes found
580 abort: post-pull.nomodule hook is invalid: "nomodule" not in a module
574 abort: post-pull.nomodule hook is invalid: "nomodule" not in a module
581 [255]
575 [255]
582
576
583 $ echo '[hooks]' > .hg/hgrc
577 $ echo '[hooks]' > .hg/hgrc
584 $ echo 'post-pull.badmodule = python:nomodule.nowhere' >> .hg/hgrc
578 $ echo 'post-pull.badmodule = python:nomodule.nowhere' >> .hg/hgrc
585 $ hg pull ../a
579 $ hg pull ../a
586 pulling from ../a
580 pulling from ../a
587 searching for changes
581 searching for changes
588 no changes found
582 no changes found
589 abort: post-pull.badmodule hook is invalid: import of "nomodule" failed
583 abort: post-pull.badmodule hook is invalid: import of "nomodule" failed
590 (run with --traceback for stack trace)
584 (run with --traceback for stack trace)
591 [255]
585 [255]
592
586
593 $ echo '[hooks]' > .hg/hgrc
587 $ echo '[hooks]' > .hg/hgrc
594 $ echo 'post-pull.nohook = python:hooktests.nohook' >> .hg/hgrc
588 $ echo 'post-pull.nohook = python:hooktests.nohook' >> .hg/hgrc
595 $ hg pull ../a
589 $ hg pull ../a
596 pulling from ../a
590 pulling from ../a
597 searching for changes
591 searching for changes
598 no changes found
592 no changes found
599 abort: post-pull.nohook hook is invalid: "hooktests.nohook" is not defined
593 abort: post-pull.nohook hook is invalid: "hooktests.nohook" is not defined
600 [255]
594 [255]
601
595
602 make sure --traceback works
596 make sure --traceback works
603
597
604 $ echo '[hooks]' > .hg/hgrc
598 $ echo '[hooks]' > .hg/hgrc
605 $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
599 $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
606
600
607 $ echo aa > a
601 $ echo aa > a
608 $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback'
602 $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback'
609 Traceback (most recent call last):
603 Traceback (most recent call last):
610
604
611 $ cd ..
605 $ cd ..
612 $ hg init c
606 $ hg init c
613 $ cd c
607 $ cd c
614
608
615 $ cat > hookext.py <<EOF
609 $ cat > hookext.py <<EOF
616 > def autohook(**args):
610 > def autohook(**args):
617 > print "Automatically installed hook"
611 > print "Automatically installed hook"
618 >
612 >
619 > def reposetup(ui, repo):
613 > def reposetup(ui, repo):
620 > repo.ui.setconfig("hooks", "commit.auto", autohook)
614 > repo.ui.setconfig("hooks", "commit.auto", autohook)
621 > EOF
615 > EOF
622 $ echo '[extensions]' >> .hg/hgrc
616 $ echo '[extensions]' >> .hg/hgrc
623 $ echo 'hookext = hookext.py' >> .hg/hgrc
617 $ echo 'hookext = hookext.py' >> .hg/hgrc
624
618
625 $ touch foo
619 $ touch foo
626 $ hg add foo
620 $ hg add foo
627 $ hg ci -d '0 0' -m 'add foo'
621 $ hg ci -d '0 0' -m 'add foo'
628 Automatically installed hook
622 Automatically installed hook
629 $ echo >> foo
623 $ echo >> foo
630 $ hg ci --debug -d '0 0' -m 'change foo'
624 $ hg ci --debug -d '0 0' -m 'change foo'
631 committing files:
625 committing files:
632 foo
626 foo
633 committing manifest
627 committing manifest
634 committing changelog
628 committing changelog
635 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
629 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
636 calling hook commit.auto: hgext_hookext.autohook
630 calling hook commit.auto: hgext_hookext.autohook
637 Automatically installed hook
631 Automatically installed hook
638
632
639 $ hg showconfig hooks
633 $ hg showconfig hooks
640 hooks.commit.auto=<function autohook at *> (glob)
634 hooks.commit.auto=<function autohook at *> (glob)
641
635
642 test python hook configured with python:[file]:[hook] syntax
636 test python hook configured with python:[file]:[hook] syntax
643
637
644 $ cd ..
638 $ cd ..
645 $ mkdir d
639 $ mkdir d
646 $ cd d
640 $ cd d
647 $ hg init repo
641 $ hg init repo
648 $ mkdir hooks
642 $ mkdir hooks
649
643
650 $ cd hooks
644 $ cd hooks
651 $ cat > testhooks.py <<EOF
645 $ cat > testhooks.py <<EOF
652 > def testhook(**args):
646 > def testhook(**args):
653 > print 'hook works'
647 > print 'hook works'
654 > EOF
648 > EOF
655 $ echo '[hooks]' > ../repo/.hg/hgrc
649 $ echo '[hooks]' > ../repo/.hg/hgrc
656 $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
650 $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
657
651
658 $ cd ../repo
652 $ cd ../repo
659 $ hg commit -d '0 0'
653 $ hg commit -d '0 0'
660 hook works
654 hook works
661 nothing changed
655 nothing changed
662 [1]
656 [1]
663
657
664 $ echo '[hooks]' > .hg/hgrc
658 $ echo '[hooks]' > .hg/hgrc
665 $ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc
659 $ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc
666 $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc
660 $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc
667
661
668 $ hg up null
662 $ hg up null
669 loading update.ne hook failed:
663 loading update.ne hook failed:
670 abort: No such file or directory: $TESTTMP/d/repo/nonexistent.py
664 abort: No such file or directory: $TESTTMP/d/repo/nonexistent.py
671 [255]
665 [255]
672
666
673 $ hg id
667 $ hg id
674 loading pre-identify.npmd hook failed:
668 loading pre-identify.npmd hook failed:
675 abort: No module named repo!
669 abort: No module named repo!
676 [255]
670 [255]
677
671
678 $ cd ../../b
672 $ cd ../../b
679
673
680 make sure --traceback works on hook import failure
674 make sure --traceback works on hook import failure
681
675
682 $ cat > importfail.py <<EOF
676 $ cat > importfail.py <<EOF
683 > import somebogusmodule
677 > import somebogusmodule
684 > # dereference something in the module to force demandimport to load it
678 > # dereference something in the module to force demandimport to load it
685 > somebogusmodule.whatever
679 > somebogusmodule.whatever
686 > EOF
680 > EOF
687
681
688 $ echo '[hooks]' > .hg/hgrc
682 $ echo '[hooks]' > .hg/hgrc
689 $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
683 $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
690
684
691 $ echo a >> a
685 $ echo a >> a
692 $ hg --traceback commit -ma 2>&1 | egrep -v '^( +File| [a-zA-Z(])'
686 $ hg --traceback commit -ma 2>&1 | egrep -v '^( +File| [a-zA-Z(])'
693 exception from first failed import attempt:
687 exception from first failed import attempt:
694 Traceback (most recent call last):
688 Traceback (most recent call last):
695 ImportError: No module named somebogusmodule
689 ImportError: No module named somebogusmodule
696 exception from second failed import attempt:
690 exception from second failed import attempt:
697 Traceback (most recent call last):
691 Traceback (most recent call last):
698 ImportError: No module named hgext_importfail
692 ImportError: No module named hgext_importfail
699 Traceback (most recent call last):
693 Traceback (most recent call last):
700 HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed
694 HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed
701 abort: precommit.importfail hook is invalid: import of "importfail" failed
695 abort: precommit.importfail hook is invalid: import of "importfail" failed
702
696
703 Issue1827: Hooks Update & Commit not completely post operation
697 Issue1827: Hooks Update & Commit not completely post operation
704
698
705 commit and update hooks should run after command completion. The largefiles
699 commit and update hooks should run after command completion. The largefiles
706 use demonstrates a recursive wlock, showing the hook doesn't run until the
700 use demonstrates a recursive wlock, showing the hook doesn't run until the
707 final release (and dirstate flush).
701 final release (and dirstate flush).
708
702
709 $ echo '[hooks]' > .hg/hgrc
703 $ echo '[hooks]' > .hg/hgrc
710 $ echo 'commit = hg id' >> .hg/hgrc
704 $ echo 'commit = hg id' >> .hg/hgrc
711 $ echo 'update = hg id' >> .hg/hgrc
705 $ echo 'update = hg id' >> .hg/hgrc
712 $ echo bb > a
706 $ echo bb > a
713 $ hg ci -ma
707 $ hg ci -ma
714 223eafe2750c tip
708 223eafe2750c tip
715 $ hg up 0 --config extensions.largefiles=
709 $ hg up 0 --config extensions.largefiles=
716 cb9a9f314b8b
710 cb9a9f314b8b
717 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
711 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
718
712
719 make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui
713 make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui
720 that is passed to pre/post hooks
714 that is passed to pre/post hooks
721
715
722 $ echo '[hooks]' > .hg/hgrc
716 $ echo '[hooks]' > .hg/hgrc
723 $ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc
717 $ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc
724 $ hg id
718 $ hg id
725 cb9a9f314b8b
719 cb9a9f314b8b
726 $ hg id --verbose
720 $ hg id --verbose
727 calling hook pre-identify: hooktests.verbosehook
721 calling hook pre-identify: hooktests.verbosehook
728 verbose output from hook
722 verbose output from hook
729 cb9a9f314b8b
723 cb9a9f314b8b
730
724
731 Ensure hooks can be prioritized
725 Ensure hooks can be prioritized
732
726
733 $ echo '[hooks]' > .hg/hgrc
727 $ echo '[hooks]' > .hg/hgrc
734 $ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc
728 $ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc
735 $ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc
729 $ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc
736 $ echo 'priority.pre-identify.b = 1' >> .hg/hgrc
730 $ echo 'priority.pre-identify.b = 1' >> .hg/hgrc
737 $ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc
731 $ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc
738 $ hg id --verbose
732 $ hg id --verbose
739 calling hook pre-identify.b: hooktests.verbosehook
733 calling hook pre-identify.b: hooktests.verbosehook
740 verbose output from hook
734 verbose output from hook
741 calling hook pre-identify.a: hooktests.verbosehook
735 calling hook pre-identify.a: hooktests.verbosehook
742 verbose output from hook
736 verbose output from hook
743 calling hook pre-identify.c: hooktests.verbosehook
737 calling hook pre-identify.c: hooktests.verbosehook
744 verbose output from hook
738 verbose output from hook
745 cb9a9f314b8b
739 cb9a9f314b8b
746
740
747 new tags must be visible in pretxncommit (issue3210)
741 new tags must be visible in pretxncommit (issue3210)
748
742
749 $ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc
743 $ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc
750 $ hg tag -f foo
744 $ hg tag -f foo
751 ['a', 'foo', 'tip']
745 ['a', 'foo', 'tip']
752
746
753 post-init hooks must not crash (issue4983)
747 post-init hooks must not crash (issue4983)
754 This also creates the `to` repo for the next test block.
748 This also creates the `to` repo for the next test block.
755
749
756 $ cd ..
750 $ cd ..
757 $ cat << EOF >> hgrc-with-post-init-hook
751 $ cat << EOF >> hgrc-with-post-init-hook
758 > [hooks]
752 > [hooks]
759 > post-init = printenv.py post-init
753 > post-init = printenv.py post-init
760 > EOF
754 > EOF
761 $ HGRCPATH=hgrc-with-post-init-hook hg init to
755 $ HGRCPATH=hgrc-with-post-init-hook hg init to
762 post-init hook: HG_ARGS=init to HG_OPTS={'insecure': None, 'remotecmd': '', 'ssh': ''} HG_PATS=['to'] HG_RESULT=0
756 post-init hook: HG_ARGS=init to HG_OPTS={'insecure': None, 'remotecmd': '', 'ssh': ''} HG_PATS=['to'] HG_RESULT=0
763
757
764 new commits must be visible in pretxnchangegroup (issue3428)
758 new commits must be visible in pretxnchangegroup (issue3428)
765
759
766 $ echo '[hooks]' >> to/.hg/hgrc
760 $ echo '[hooks]' >> to/.hg/hgrc
767 $ echo 'prechangegroup = hg --traceback tip' >> to/.hg/hgrc
761 $ echo 'prechangegroup = hg --traceback tip' >> to/.hg/hgrc
768 $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc
762 $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc
769 $ echo a >> to/a
763 $ echo a >> to/a
770 $ hg --cwd to ci -Ama
764 $ hg --cwd to ci -Ama
771 adding a
765 adding a
772 $ hg clone to from
766 $ hg clone to from
773 updating to branch default
767 updating to branch default
774 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
768 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
775 $ echo aa >> from/a
769 $ echo aa >> from/a
776 $ hg --cwd from ci -mb
770 $ hg --cwd from ci -mb
777 $ hg --cwd from push
771 $ hg --cwd from push
778 pushing to $TESTTMP/to (glob)
772 pushing to $TESTTMP/to (glob)
779 searching for changes
773 searching for changes
780 changeset: 0:cb9a9f314b8b
774 changeset: 0:cb9a9f314b8b
781 tag: tip
775 tag: tip
782 user: test
776 user: test
783 date: Thu Jan 01 00:00:00 1970 +0000
777 date: Thu Jan 01 00:00:00 1970 +0000
784 summary: a
778 summary: a
785
779
786 adding changesets
780 adding changesets
787 adding manifests
781 adding manifests
788 adding file changes
782 adding file changes
789 added 1 changesets with 1 changes to 1 files
783 added 1 changesets with 1 changes to 1 files
790 changeset: 1:9836a07b9b9d
784 changeset: 1:9836a07b9b9d
791 tag: tip
785 tag: tip
792 user: test
786 user: test
793 date: Thu Jan 01 00:00:00 1970 +0000
787 date: Thu Jan 01 00:00:00 1970 +0000
794 summary: b
788 summary: b
795
789
796
790
797 pretxnclose hook failure should abort the transaction
791 pretxnclose hook failure should abort the transaction
798
792
799 $ hg init txnfailure
793 $ hg init txnfailure
800 $ cd txnfailure
794 $ cd txnfailure
801 $ touch a && hg commit -Aqm a
795 $ touch a && hg commit -Aqm a
802 $ cat >> .hg/hgrc <<EOF
796 $ cat >> .hg/hgrc <<EOF
803 > [hooks]
797 > [hooks]
804 > pretxnclose.error = exit 1
798 > pretxnclose.error = exit 1
805 > EOF
799 > EOF
806 $ hg strip -r 0 --config extensions.strip=
800 $ hg strip -r 0 --config extensions.strip=
807 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
801 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
808 saved backup bundle to * (glob)
802 saved backup bundle to * (glob)
809 transaction abort!
803 transaction abort!
810 rollback completed
804 rollback completed
811 strip failed, full bundle stored in * (glob)
805 strip failed, full bundle stored in * (glob)
812 abort: pretxnclose.error hook exited with status 1
806 abort: pretxnclose.error hook exited with status 1
813 [255]
807 [255]
814 $ hg recover
808 $ hg recover
815 no interrupted transaction available
809 no interrupted transaction available
816 [1]
810 [1]
817 $ cd ..
811 $ cd ..
818
812
819 Hook from untrusted hgrc are reported as failure
813 Hook from untrusted hgrc are reported as failure
820 ================================================
814 ================================================
821
815
822 $ cat << EOF > $TESTTMP/untrusted.py
816 $ cat << EOF > $TESTTMP/untrusted.py
823 > from mercurial import scmutil, util
817 > from mercurial import scmutil, util
824 > def uisetup(ui):
818 > def uisetup(ui):
825 > class untrustedui(ui.__class__):
819 > class untrustedui(ui.__class__):
826 > def _trusted(self, fp, f):
820 > def _trusted(self, fp, f):
827 > if util.normpath(fp.name).endswith('untrusted/.hg/hgrc'):
821 > if util.normpath(fp.name).endswith('untrusted/.hg/hgrc'):
828 > return False
822 > return False
829 > return super(untrustedui, self)._trusted(fp, f)
823 > return super(untrustedui, self)._trusted(fp, f)
830 > ui.__class__ = untrustedui
824 > ui.__class__ = untrustedui
831 > EOF
825 > EOF
832 $ cat << EOF >> $HGRCPATH
826 $ cat << EOF >> $HGRCPATH
833 > [extensions]
827 > [extensions]
834 > untrusted=$TESTTMP/untrusted.py
828 > untrusted=$TESTTMP/untrusted.py
835 > EOF
829 > EOF
836 $ hg init untrusted
830 $ hg init untrusted
837 $ cd untrusted
831 $ cd untrusted
838
832
839 Non-blocking hook
833 Non-blocking hook
840 -----------------
834 -----------------
841
835
842 $ cat << EOF >> .hg/hgrc
836 $ cat << EOF >> .hg/hgrc
843 > [hooks]
837 > [hooks]
844 > txnclose.testing=echo txnclose hook called
838 > txnclose.testing=echo txnclose hook called
845 > EOF
839 > EOF
846 $ touch a && hg commit -Aqm a
840 $ touch a && hg commit -Aqm a
847 warning: untrusted hook txnclose not executed
841 warning: untrusted hook txnclose not executed
848 $ hg log
842 $ hg log
849 changeset: 0:3903775176ed
843 changeset: 0:3903775176ed
850 tag: tip
844 tag: tip
851 user: test
845 user: test
852 date: Thu Jan 01 00:00:00 1970 +0000
846 date: Thu Jan 01 00:00:00 1970 +0000
853 summary: a
847 summary: a
854
848
855
849
856 Non-blocking hook
850 Non-blocking hook
857 -----------------
851 -----------------
858
852
859 $ cat << EOF >> .hg/hgrc
853 $ cat << EOF >> .hg/hgrc
860 > [hooks]
854 > [hooks]
861 > pretxnclose.testing=echo pre-txnclose hook called
855 > pretxnclose.testing=echo pre-txnclose hook called
862 > EOF
856 > EOF
863 $ touch b && hg commit -Aqm a
857 $ touch b && hg commit -Aqm a
864 transaction abort!
858 transaction abort!
865 rollback completed
859 rollback completed
866 abort: untrusted hook pretxnclose not executed
860 abort: untrusted hook pretxnclose not executed
867 (see 'hg help config.trusted')
861 (see 'hg help config.trusted')
868 [255]
862 [255]
869 $ hg log
863 $ hg log
870 changeset: 0:3903775176ed
864 changeset: 0:3903775176ed
871 tag: tip
865 tag: tip
872 user: test
866 user: test
873 date: Thu Jan 01 00:00:00 1970 +0000
867 date: Thu Jan 01 00:00:00 1970 +0000
874 summary: a
868 summary: a
875
869
General Comments 0
You need to be logged in to leave comments. Login now