Client-side vs. server-side hooks

Andrew Bennetts andrew.bennetts at
Mon Oct 20 00:08:04 BST 2008

Michael Ernst wrote:
> The Bazaar documentation is not always clear whether each hook runs on the
> client, the server, or both.  Below is my best guess, though I would
> appreciate confirmation/clarification.

Broadly speaking, the general rule is they are run whenever the corresponding
bzrlib method is run.

Technically, they can all be run on either side — it's just that there are some
that will never get triggered by default bzr installations.  You could install a
plugin that would do operations that would trigger hooks that wouldn't normally
be triggered.

As an example, it's possible to write a post_change_branch_tip plugin to
automatically push the changed branch somewhere (to automatically keep a mirror
up-to-date).  If installed on the server, this would cause the post_push hook to
run on the server.  In a sense the server here is also acting as a client, so
this arguably doesn't contradict your classification :)

I don't think complex examples like that one happen in practice very often
(yet?).  So probably it's not worth confusing the documentation to try and
account for them.

It would be good to more clearly (but still precisely) describe when these hooks
are run, so your proposed documentation is a step in the right direction.

> On a related topic, under what circumstances is a server-side hook run?
> Only when using the smart server?  Also when using the ssh server?  Under
> any other circumstances?

The server-side hooks can be run by a smart server, that is a server accessed
via bzr://, bzr+ssh:// and bzr+http:// (keeping in mind that bzr will
auto-detect a bzr+http:// server when given a http:// URL).

> lock_acquired (LockDir)
> Runs on the client.
> lock_released (LockDir)
> Runs on the client.

I'd expect actually that these get run on the server too, and in fact that in
some situations they will be run only on the server and not the client.  As the
smart protocol covers more and more operations, more and more the client, when
using the smart protocol, will not be maninpulating remote LockDirs directly
(even though it happens reguarly at the moment).

Your other classifications sound correct to me, although I haven't checked


More information about the bazaar mailing list