3089.3.1
by Ian Clatworthy
move reference material out of User Guide into User Reference |
1 |
Hooks |
2 |
===== |
|
2767.2.2
by Aaron Bentley
Split hooks doc into guide and reference |
3 |
|
3408.5.3
by Ian Clatworthy
add classes to the Hooks User Reference doc |
4 |
Introduction |
5 |
------------ |
|
6 |
||
7 |
A hook of type *xxx* of class *yyy* needs to be registered using:: |
|
8 |
||
9 |
yyy.hooks.install_named_hook("xxx", ...) |
|
10 |
||
11 |
See `Using hooks`_ in the User Guide for examples. |
|
12 |
||
13 |
.. _Using hooks: ../user-guide/index.html#using-hooks |
|
14 |
||
3805.1.1
by Martin Pool
Merge and tweak hook documentation |
15 |
The class that contains each hook is given in parentheses immediately |
16 |
after each hook type below. |
|
3786.1.1
by mernst at mit
This patch improves the User Guide's documentation of hooks. |
17 |
|
18 |
Each description also indicates whether the hook runs on the client (the |
|
3805.1.1
by Martin Pool
Merge and tweak hook documentation |
19 |
machine where bzr was invoked) or the server (the machine addressed by |
20 |
the branch URL). These may be, but are not necessarily, the same machine. |
|
3786.1.1
by mernst at mit
This patch improves the User Guide's documentation of hooks. |
21 |
|
22 |
Plugins (including hooks) are run on the server if any of these is true: |
|
23 |
||
3786.1.2
by mernst at mit
Improvements suggested by Andrew Bennetts. |
24 |
* The remote branch is on the same machine as the client, and the client |
25 |
has plugins enabled. |
|
26 |
||
27 |
* The connection is via a smart server (accessed with a URL starting with |
|
28 |
"bzr://", "bzr+ssh://" or "bzr+http://", or accessed via a "http://" |
|
29 |
URL when a smart server is available via HTTP), and that server has |
|
30 |
plugins enabled. |
|
3408.5.3
by Ian Clatworthy
add classes to the Hooks User Reference doc |
31 |
|
3414.1.1
by Ian Clatworthy
Better hooks doc (Ian Clatworthy) |
32 |
|
3681.1.1
by Robert Collins
Create a new hook Branch.open. (Robert Collins) |
33 |
open (Branch) |
34 |
------------- |
|
35 |
||
36 |
Called after a Branch object is opened, with the Branch object. |
|
3786.1.1
by mernst at mit
This patch improves the User Guide's documentation of hooks. |
37 |
Runs on the client and on the server. |
3681.1.1
by Robert Collins
Create a new hook Branch.open. (Robert Collins) |
38 |
|
39 |
||
3408.5.3
by Ian Clatworthy
add classes to the Hooks User Reference doc |
40 |
post_push (Branch) |
41 |
------------------ |
|
2767.2.2
by Aaron Bentley
Split hooks doc into guide and reference |
42 |
|
43 |
Run after ``push`` has completed. |
|
3786.1.1
by mernst at mit
This patch improves the User Guide's documentation of hooks. |
44 |
Runs on the client. |
2767.2.2
by Aaron Bentley
Split hooks doc into guide and reference |
45 |
|
46 |
The hook signature is (push_result), containing the members |
|
3026.2.1
by John Arbash Meinel
Updated post-push hook to have the correct info |
47 |
|
48 |
source_branch |
|
49 |
Where the data is being pushed from (read locked). |
|
50 |
This should be the lowest latency branch. |
|
51 |
||
52 |
target_branch |
|
53 |
The direct location where data is being sent (write locked). |
|
54 |
||
55 |
master_branch |
|
56 |
Either target_branch, or if the target is a bound branch, it |
|
57 |
will be the master location (write locked). |
|
58 |
||
59 |
local_branch |
|
60 |
If the target is a bound branch, this will be the target |
|
61 |
branch, else it will be None. |
|
62 |
||
63 |
old_revno |
|
64 |
The revision number (eg 10) of the branch before the push. |
|
65 |
||
66 |
old_revid |
|
67 |
The revision id (eg joe@foo.com-1234234-aoeua34) before the push. |
|
68 |
||
69 |
new_revno |
|
70 |
The revision number (eg 12) of the branch after the push. |
|
71 |
||
72 |
new_revid |
|
73 |
The revision id (eg joe@foo.com-5676566-boa234a) after the push. |
|
2767.2.2
by Aaron Bentley
Split hooks doc into guide and reference |
74 |
|
3414.1.1
by Ian Clatworthy
Better hooks doc (Ian Clatworthy) |
75 |
|
3408.5.3
by Ian Clatworthy
add classes to the Hooks User Reference doc |
76 |
post_pull (Branch) |
77 |
------------------ |
|
3089.3.1
by Ian Clatworthy
move reference material out of User Guide into User Reference |
78 |
|
2767.2.2
by Aaron Bentley
Split hooks doc into guide and reference |
79 |
Run after ``pull`` has completed. |
3786.1.1
by mernst at mit
This patch improves the User Guide's documentation of hooks. |
80 |
Runs on the client. |
2767.2.2
by Aaron Bentley
Split hooks doc into guide and reference |
81 |
|
82 |
The hook signature is (push_result) containing the members |
|
83 |
(source, local, master, old_revno, old_revid, new_revno, new_revid) |
|
84 |
where local is the local target branch or None, master is the target |
|
85 |
master branch, and the rest should be self explanatory. The source |
|
86 |
is read-locked and the target branches are write-locked. Source will |
|
87 |
be the local low-latency branch. |
|
88 |
||
3414.1.1
by Ian Clatworthy
Better hooks doc (Ian Clatworthy) |
89 |
|
3408.5.3
by Ian Clatworthy
add classes to the Hooks User Reference doc |
90 |
start_commit (MutableTree) |
91 |
-------------------------- |
|
3408.5.2
by Ian Clatworthy
add start_commit doc |
92 |
|
93 |
Run on the working tree before ``commit`` starts processing it. |
|
3786.1.1
by mernst at mit
This patch improves the User Guide's documentation of hooks. |
94 |
Runs on the client. |
95 |
||
3408.5.2
by Ian Clatworthy
add start_commit doc |
96 |
Unlike the ``pre_commit`` hook (see below), the ``start_commit`` hook |
97 |
can safely change the working tree. |
|
98 |
||
99 |
The hook signature is (tree) where tree is a MutableTree object. |
|
100 |
||
3414.1.1
by Ian Clatworthy
Better hooks doc (Ian Clatworthy) |
101 |
|
3408.5.3
by Ian Clatworthy
add classes to the Hooks User Reference doc |
102 |
pre_commit (Branch) |
103 |
------------------- |
|
3089.3.1
by Ian Clatworthy
move reference material out of User Guide into User Reference |
104 |
|
3408.5.2
by Ian Clatworthy
add start_commit doc |
105 |
Run before ``commit`` has completed. |
3786.1.1
by mernst at mit
This patch improves the User Guide's documentation of hooks. |
106 |
Runs on the client. |
2659.3.10
by Nam Nguyen
merge with bzr.dev and update hooks.txt to list pre_commit hook. |
107 |
|
108 |
The hook signature is (local, master, old_revno, old_revid, future_revno, |
|
109 |
future_revid, tree_delta, future_tree) where old_revno is NULL_REVISION for |
|
110 |
the first commit to a branch, tree_delta is a TreeDelta object describing |
|
111 |
changes from the basis revision, and future_tree is an in-memory tree |
|
112 |
obtained from CommitBuilder.revision_tree(). Hooks MUST NOT modify tree_delta |
|
113 |
and future_tree. |
|
114 |
||
3414.1.1
by Ian Clatworthy
Better hooks doc (Ian Clatworthy) |
115 |
|
3408.5.3
by Ian Clatworthy
add classes to the Hooks User Reference doc |
116 |
post_commit (Branch) |
117 |
-------------------- |
|
3089.3.1
by Ian Clatworthy
move reference material out of User Guide into User Reference |
118 |
|
2767.2.2
by Aaron Bentley
Split hooks doc into guide and reference |
119 |
Run after ``commit`` has completed. |
3786.1.1
by mernst at mit
This patch improves the User Guide's documentation of hooks. |
120 |
Runs on the client. |
2767.2.2
by Aaron Bentley
Split hooks doc into guide and reference |
121 |
|
122 |
The hook signature is (local, master, old_revno, old_revid, new_revno, |
|
123 |
new_revid) old_revid is NULL_REVISION for the first commit to a branch. |
|
124 |
||
3414.1.1
by Ian Clatworthy
Better hooks doc (Ian Clatworthy) |
125 |
|
3408.5.3
by Ian Clatworthy
add classes to the Hooks User Reference doc |
126 |
post_uncommit (Branch) |
127 |
---------------------- |
|
3089.3.1
by Ian Clatworthy
move reference material out of User Guide into User Reference |
128 |
|
2767.2.2
by Aaron Bentley
Split hooks doc into guide and reference |
129 |
Run after ``uncommit`` has completed. |
3786.1.1
by mernst at mit
This patch improves the User Guide's documentation of hooks. |
130 |
Runs on the client. |
2767.2.2
by Aaron Bentley
Split hooks doc into guide and reference |
131 |
|
132 |
The api signature is (local, master, old_revno, old_revid, new_revno, |
|
133 |
new_revid) where local is the local branch or None, master is the target |
|
2769.1.1
by Kent Gibson
Tweak Hook documentation |
134 |
branch, and an empty branch receives new_revno of 0, new_revid of None. |
2767.2.2
by Aaron Bentley
Split hooks doc into guide and reference |
135 |
|
3414.1.1
by Ian Clatworthy
Better hooks doc (Ian Clatworthy) |
136 |
|
3517.2.6
by Andrew Bennetts
Add NEWS entry, and document in the 'hooks' help topic. |
137 |
pre_change_branch_tip (Branch) |
138 |
------------------------------- |
|
139 |
||
140 |
Run before a branch tip has been changed, while the branch is write-locked. |
|
3786.1.2
by mernst at mit
Improvements suggested by Andrew Bennetts. |
141 |
Runs on the client and on the server. |
3517.2.6
by Andrew Bennetts
Add NEWS entry, and document in the 'hooks' help topic. |
142 |
Note that push, pull, commit and uncommit all invoke this hook. |
143 |
||
144 |
The hook signature is (params), where params is an object containing |
|
145 |
the members |
|
146 |
||
147 |
branch |
|
148 |
The branch whose tip has been changed. |
|
149 |
||
150 |
old_revno |
|
151 |
The revision number (eg 10) of the branch before the change. |
|
152 |
||
153 |
old_revid |
|
154 |
The revision id (eg joe@foo.com-1234234-aoeua34) before the change. |
|
155 |
||
156 |
new_revno |
|
157 |
The revision number (eg 12) of the branch after the change. |
|
158 |
||
159 |
new_revid |
|
160 |
The revision id (eg joe@foo.com-5676566-boa234a) after the change. |
|
161 |
||
162 |
The old_revno and new_revno members are integers, as the head |
|
163 |
revision never has a dotted revision number. |
|
164 |
||
165 |
||
3408.5.3
by Ian Clatworthy
add classes to the Hooks User Reference doc |
166 |
post_change_branch_tip (Branch) |
167 |
------------------------------- |
|
3323.2.1
by Ian Clatworthy
first cut at post_change_branch_tip hook |
168 |
|
169 |
Run after a branch tip has been changed but while the branch is still |
|
3786.1.1
by mernst at mit
This patch improves the User Guide's documentation of hooks. |
170 |
write-locked. |
3786.1.2
by mernst at mit
Improvements suggested by Andrew Bennetts. |
171 |
Runs on the client and on the server. |
3786.1.1
by mernst at mit
This patch improves the User Guide's documentation of hooks. |
172 |
Note that push, pull, commit and uncommit all invoke this hook. |
3323.2.1
by Ian Clatworthy
first cut at post_change_branch_tip hook |
173 |
|
174 |
The hook signature is (params), where params is an object containing |
|
175 |
the members |
|
176 |
||
3331.1.8
by James Henstridge
Update help text to match change to params. |
177 |
branch |
178 |
The branch whose tip has been changed. |
|
179 |
||
3323.2.1
by Ian Clatworthy
first cut at post_change_branch_tip hook |
180 |
old_revno |
3331.1.8
by James Henstridge
Update help text to match change to params. |
181 |
The revision number (eg 10) of the branch before the change. |
3323.2.1
by Ian Clatworthy
first cut at post_change_branch_tip hook |
182 |
|
183 |
old_revid |
|
3331.1.8
by James Henstridge
Update help text to match change to params. |
184 |
The revision id (eg joe@foo.com-1234234-aoeua34) before the change. |
3323.2.1
by Ian Clatworthy
first cut at post_change_branch_tip hook |
185 |
|
186 |
new_revno |
|
3331.1.8
by James Henstridge
Update help text to match change to params. |
187 |
The revision number (eg 12) of the branch after the change. |
3323.2.1
by Ian Clatworthy
first cut at post_change_branch_tip hook |
188 |
|
189 |
new_revid |
|
3331.1.8
by James Henstridge
Update help text to match change to params. |
190 |
The revision id (eg joe@foo.com-5676566-boa234a) after the change. |
3323.2.1
by Ian Clatworthy
first cut at post_change_branch_tip hook |
191 |
|
3331.1.11
by James Henstridge
Note that the revision numbers are integers in the docs. |
192 |
The old_revno and new_revno members are integers, as the head |
3517.2.6
by Andrew Bennetts
Add NEWS entry, and document in the 'hooks' help topic. |
193 |
revision never has a dotted revision number. |
3331.1.11
by James Henstridge
Note that the revision numbers are integers in the docs. |
194 |
|
3414.1.1
by Ian Clatworthy
Better hooks doc (Ian Clatworthy) |
195 |
|
3408.5.3
by Ian Clatworthy
add classes to the Hooks User Reference doc |
196 |
set_rh (Branch) |
197 |
--------------- |
|
3089.3.1
by Ian Clatworthy
move reference material out of User Guide into User Reference |
198 |
|
3323.2.1
by Ian Clatworthy
first cut at post_change_branch_tip hook |
199 |
Note: This hook is now deprecated and will be removed in the near future. |
200 |
Please use the ``post_change_branch_tip`` hook instead. |
|
3408.5.5
by Ian Clatworthy
added smart server hooks doc |
201 |
|
3414.1.1
by Ian Clatworthy
Better hooks doc (Ian Clatworthy) |
202 |
|
3770.2.1
by Michael Hudson
test and feature |
203 |
transform_fallback_location (Branch) |
204 |
------------------------------------ |
|
205 |
||
3770.2.2
by Michael Hudson
docs |
206 |
Invoked as a stacked branch activates its fallback locations. |
207 |
||
208 |
The hook signature is (branch, url) where: |
|
209 |
||
210 |
branch |
|
211 |
The branch being opened. Note that as it does not yet have its |
|
212 |
fallback locations activated, the branch should be treated as |
|
213 |
half-built. |
|
214 |
||
215 |
url |
|
216 |
The URL that the branch specified for its fallback location. |
|
217 |
||
218 |
The hook must return a URL for the branch containing the fallback |
|
3770.2.4
by John Arbash Meinel
Document that the hook call ordering is undefined. |
219 |
location. If multiple hooks are registered, the order in which they |
220 |
will be called is undefined and subject to change. |
|
3770.2.2
by Michael Hudson
docs |
221 |
|
222 |
(New in 1.9) |
|
3770.2.1
by Michael Hudson
test and feature |
223 |
|
224 |
||
3408.5.5
by Ian Clatworthy
added smart server hooks doc |
225 |
server_started (SmartTCPServer) |
226 |
------------------------------- |
|
227 |
||
228 |
Invoked whenever the server starts serving a directory. |
|
3786.1.1
by mernst at mit
This patch improves the User Guide's documentation of hooks. |
229 |
Runs on the server. |
230 |
||
3408.5.5
by Ian Clatworthy
added smart server hooks doc |
231 |
The hook signature is (backing urls, public url), where: |
232 |
||
233 |
backing_url |
|
234 |
A list of (string) URLs giving the server-specific directory locations. |
|
235 |
||
236 |
public_url |
|
237 |
The public URL for the directory. |
|
238 |
||
3414.1.1
by Ian Clatworthy
Better hooks doc (Ian Clatworthy) |
239 |
|
3408.5.5
by Ian Clatworthy
added smart server hooks doc |
240 |
server_stopped (SmartTCPServer) |
241 |
------------------------------- |
|
242 |
||
243 |
Invoked whenever the server stops serving a directory. |
|
3786.1.1
by mernst at mit
This patch improves the User Guide's documentation of hooks. |
244 |
Runs on the server. |
245 |
||
3408.5.5
by Ian Clatworthy
added smart server hooks doc |
246 |
The hook signature is the same as ``server_started``. |
3642.2.4
by Jelmer Vernooij
review feedback from John. |
247 |
|
248 |
||
3331.3.11
by Martin Pool
Move LockDir hooks onto LockDir |
249 |
lock_acquired (LockDir) |
3331.3.6
by Martin Pool
merge trunk |
250 |
---------------------------- |
3331.3.1
by Robert Collins
* ``LockDir`` lock acquisition and release now trigger hooks allowing |
251 |
|
252 |
Called with a LockResult object when a lock has been successfully acquired. |
|
3786.1.1
by mernst at mit
This patch improves the User Guide's documentation of hooks. |
253 |
Runs on the client and on the server. |
254 |
||
3724.1.1
by Martin Pool
Move Lock hooks onto a base Lock class and make them more consistent with other lock classes |
255 |
(New in 1.8.) |
3331.3.11
by Martin Pool
Move LockDir hooks onto LockDir |
256 |
|
257 |
lock_released (LockDir) |
|
3331.3.6
by Martin Pool
merge trunk |
258 |
---------------------------- |
3331.3.1
by Robert Collins
* ``LockDir`` lock acquisition and release now trigger hooks allowing |
259 |
|
260 |
Called with a LockResult object when a lock has been successfully released. |
|
3786.1.1
by mernst at mit
This patch improves the User Guide's documentation of hooks. |
261 |
Runs on the client. |
262 |
||
3724.1.1
by Martin Pool
Move Lock hooks onto a base Lock class and make them more consistent with other lock classes |
263 |
(New in 1.8.) |
3825.2.1
by Jelmer Vernooij
Merge commit hook template patch. |
264 |
|
3642.2.4
by Jelmer Vernooij
review feedback from John. |
265 |
commit_message_template (msgeditor) |
266 |
----------------------------------- |
|
267 |
||
268 |
Invoked by commit to generate a commit message template. |
|
269 |
Each hook can modify the commit message template. |
|
270 |
The hook signature is (commit, start_message), where: |
|
271 |
||
272 |
commit |
|
273 |
A commit object, for the commit in progress |
|
274 |
||
275 |
start_message |
|
276 |
The original commit message, None initially. |
|
277 |
||
278 |
The hook should return a new commit message template. |
|
3825.2.3
by Jelmer Vernooij
Move NEWS entry to latest version, update versions to 1.10. |
279 |
|
280 |
(New in 1.10.) |