~bzr-pqm/bzr/bzr.dev

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
Hooks
=====

Introduction
------------

A hook of type *xxx* of class *yyy* needs to be registered using::

  yyy.hooks.install_named_hook("xxx", ...)

See `Using hooks`_ in the User Guide for examples.

.. _Using hooks: ../user-guide/index.html#using-hooks

The class that contains each hook is given in parentheses immediately
after each hook type below.

Each description also indicates whether the hook runs on the client (the
machine where bzr was invoked) or the server (the machine addressed by
the branch URL).  These may be, but are not necessarily, the same machine.

Plugins (including hooks) are run on the server if any of these is true:

  * The remote branch is on the same machine as the client, and the client
    has plugins enabled.

  * The connection is via a smart server (accessed with a URL starting with
    "bzr://", "bzr+ssh://" or "bzr+http://", or accessed via a "http://"
    URL when a smart server is available via HTTP), and that server has
    plugins enabled.


open (Branch)
-------------

Called after a Branch object is opened, with the Branch object.
Runs on the client and on the server.


post_push (Branch)
------------------

Run after ``push`` has completed.
Runs on the client.

The hook signature is (push_result), containing the members

  source_branch
    Where the data is being pushed from (read locked).
    This should be the lowest latency branch.

  target_branch
    The direct location where data is being sent (write locked).

  master_branch
    Either target_branch, or if the target is a bound branch, it
    will be the master location (write locked).

  local_branch
    If the target is a bound branch, this will be the target
    branch, else it will be None.

  old_revno
    The revision number (eg 10) of the branch before the push.

  old_revid
    The revision id (eg joe@foo.com-1234234-aoeua34) before the push.

  new_revno
    The revision number (eg 12) of the branch after the push.

  new_revid
    The revision id (eg joe@foo.com-5676566-boa234a) after the push.


post_pull (Branch)
------------------

Run after ``pull`` has completed.
Runs on the client.

The hook signature is (push_result) containing the members
(source, local, master, old_revno, old_revid, new_revno, new_revid)
where local is the local target branch or None, master is the target 
master branch, and the rest should be self explanatory. The source
is read-locked and the target branches are write-locked. Source will
be the local low-latency branch.


start_commit (MutableTree)
--------------------------

Run on the working tree before ``commit`` starts processing it.
Runs on the client.

Unlike the ``pre_commit`` hook (see below), the ``start_commit`` hook
can safely change the working tree.

The hook signature is (tree) where tree is a MutableTree object.


pre_commit (Branch)
-------------------

Run before ``commit`` has completed.
Runs on the client.

The hook signature is (local, master, old_revno, old_revid, future_revno,
future_revid, tree_delta, future_tree) where old_revno is NULL_REVISION for
the first commit to a branch, tree_delta is a TreeDelta object describing
changes from the basis revision, and future_tree is an in-memory tree
obtained from CommitBuilder.revision_tree(). Hooks MUST NOT modify tree_delta
and future_tree.


post_commit (Branch)
--------------------

Run after ``commit`` has completed.
Runs on the client.

The hook signature is (local, master, old_revno, old_revid, new_revno,
new_revid) old_revid is NULL_REVISION for the first commit to a branch.


post_uncommit (Branch)
----------------------

Run after ``uncommit`` has completed.
Runs on the client.

The api signature is (local, master, old_revno, old_revid, new_revno,
new_revid) where local is the local branch or None, master is the target
branch, and an empty branch receives new_revno of 0, new_revid of None.


pre_change_branch_tip (Branch)
-------------------------------

Run before a branch tip has been changed, while the branch is write-locked.
Runs on the client and on the server.
Note that push, pull, commit and uncommit all invoke this hook.

The hook signature is (params), where params is an object containing
the members

  branch
    The branch whose tip has been changed.

  old_revno
    The revision number (eg 10) of the branch before the change.

  old_revid
    The revision id (eg joe@foo.com-1234234-aoeua34) before the change.

  new_revno
    The revision number (eg 12) of the branch after the change.

  new_revid
    The revision id (eg joe@foo.com-5676566-boa234a) after the change.

The old_revno and new_revno members are integers, as the head
revision never has a dotted revision number.


post_change_branch_tip (Branch)
-------------------------------

Run after a branch tip has been changed but while the branch is still
write-locked.
Runs on the client and on the server.
Note that push, pull, commit and uncommit all invoke this hook.

The hook signature is (params), where params is an object containing
the members

  branch
    The branch whose tip has been changed.

  old_revno
    The revision number (eg 10) of the branch before the change.

  old_revid
    The revision id (eg joe@foo.com-1234234-aoeua34) before the change.

  new_revno
    The revision number (eg 12) of the branch after the change.

  new_revid
    The revision id (eg joe@foo.com-5676566-boa234a) after the change.

The old_revno and new_revno members are integers, as the head
revision never has a dotted revision number.


set_rh (Branch)
---------------

Note: This hook is now deprecated and will be removed in the near future.
Please use the ``post_change_branch_tip`` hook instead.


transform_fallback_location (Branch)
------------------------------------

Invoked as a stacked branch activates its fallback locations.

The hook signature is (branch, url) where:

  branch
    The branch being opened.  Note that as it does not yet have its
    fallback locations activated, the branch should be treated as
    half-built.

  url
    The URL that the branch specified for its fallback location.

The hook must return a URL for the branch containing the fallback
location. If multiple hooks are registered, the order in which they 
will be called is undefined and subject to change.

(New in 1.9)


server_started (SmartTCPServer)
-------------------------------

Invoked whenever the server starts serving a directory.
Runs on the server.

The hook signature is (backing urls, public url), where:

  backing_url
    A list of (string) URLs giving the server-specific directory locations.

  public_url
    The public URL for the directory.


server_stopped (SmartTCPServer)
-------------------------------

Invoked whenever the server stops serving a directory.
Runs on the server.

The hook signature is the same as ``server_started``.


lock_acquired (LockDir)
----------------------------

Called with a LockResult object when a lock has been successfully acquired.
Runs on the client and on the server.

(New in 1.8.)

lock_released (LockDir)
----------------------------

Called with a LockResult object when a lock has been successfully released.
Runs on the client.

(New in 1.8.)

commit_message_template (msgeditor)
-----------------------------------

Invoked by commit to generate a commit message template.
Each hook can modify the commit message template.
The hook signature is (commit, start_message), where:

  commit
    A commit object, for the commit in progress

  start_message
    The original commit message, None initially.

The hook should return a new commit message template.

(New in 1.10.)