Post-processing a commit message

James Westby jw+debian at jameswestby.net
Tue Jun 9 15:29:38 BST 2009


On Thu, 2009-05-21 at 11:13 +0000, Eric wrote:
> Hi,

Hi,

Sorry for the delay in responding.

> I need to post-process all commit messages, after they have been entered but 
> before the commit actually happens. I have written a pre_commit hook which 
> gets hold of the entered message and carries out the post-processing. I now 
> want to replace the original message with the modified one.
> 
> I tried:
> 
> branch.repository.get_revision(future_revid).message = formatted_comment
> 
> where formatted_comment is my new message, but this doesn't modify the message.

Once the revision is in the repository it can't be modified, so the 
above won't change things as you wish. You need to modify the message 
before the revision object is stored instead.

> Is it possible to do what I want ?

In theory, yes.

>  I have seen that there are warnings not to 
> modify the tree_delta and future_tree in the pre_commit hook. Does this 
> include the message ?
> 
> Is there another way to achieve what I want ?

It doesn't seem to be possible to do this currently. It would be
possible to either add a new hook for this, or perhaps re-jig things
so that an existing hook could be used.

Thanks,

James




More information about the bazaar mailing list