[RFC] Pre-commit hooks and other requests

Martin Pool mbp at sourcefrog.net
Wed Jun 27 05:16:35 BST 2007


On 6/26/07, Ian Clatworthy <ian.clatworthy at internode.on.net> wrote:
> Before I go overboard restructuring commit, I'd like to have a feel for
>  any future features that are *likely* to be requested. For example,
> right now commit supports hooks for code to execute after a commit is
> successful. Is there a need for pre-commit hooks or some "mid-commit" hooks?

It would be simple to add a pre-commit hook that just runs before
anything else, and can look at the working directory and so on.

Selective commits (of just some files) make things more complicated
for such a hook -- things that do eg consistency checks across the
tree probably want to make sure that the selected tree is consistent.
That probably means they need to run once all the texts and the
inventory is committed.  You almost structure this as actually doing
the commit and  then uncommitting if it's unacceptable, except that's
a bit messy with regard to bound branches, other people observing the
revision, and other hooks.  So in a way this is a pre-commit hook.

They might not be done through hooks but you can consider how
$keyword$ expansion ought to work - probably that after the commit, it
gets to see the list of modified files.  (There might be enough in the
current postcommit hook to do this.)

midcommit hooks might want to customize how the message is read from
the user: what gets inserted into the informational section of the
file, and what gets done when it's read back in.

-- 
Martin



More information about the bazaar mailing list