[MERGE] Add pre_change_branch_tip hook

Andrew Bennetts andrew at canonical.com
Thu Jul 3 09:15:52 BST 2008


This branch adds a pre_change_branch_tip hook, which is an obvious variation of
post_change_branch_tip.  Now that server-side hooks work (if both client and
server are running bzr.dev, anyway), this could be useful to enforce rules that
are typically enforced by post-commit hooks in centralised systems like SVN.
For instance, you could forbid changing a branch's tip to a revision with no
commit message, or to a revision with malformed .xml files.

Some thought still needs to be given to how to report hook errors to a smart
client.  The generic smart server error you'd probably get at the moment isn't
ideal for communicating “This push was rejected because revision X's foo.xml is
malformed.”  Perhaps a good solution here is an explicit BranchTipChangeRejected
exception that hooks can raise?

I took the liberty of improving the TestPostChangeBranchTip tests while I was
there.  There were some fairly ugly assertEquals caused by reusing a single
general purpose fixture.  There's a bit more duplication between
TestPostChangeBranchTip and TestPreChangeBranchTip than I'd like, but I'm
reluctant to get too clever about fixing that, at least until we get easier
test parameterisation than plain subclassing.

-Andrew.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pre-branch-tip-changed-hook-3521.patch
Type: text/x-diff
Size: 20846 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080703/164c0a4b/attachment.bin 


More information about the bazaar mailing list