using external commit hooks to kick off build

Sean schliden at gmail.com
Wed Mar 28 07:30:51 CDT 2007


Hi Christian,

Thanks for the advice..

I decided to just try and test I could get python hooks working at
all, but am getting this error on commit:

abort: commit.build hook is invalid (import of "hghooks.buildhook" failed)

I am not sure if this is a python syntax error or if hg can't find buildhook.py

I am quite sure it is in the PYTHONPATH.

Basically, all I've done is added this to your sample:

        for x in files:
            print x

Perhaps I am taking the rest of the sample too literally ?

Cheers

Sean


On 3/28/07, Christian Ebert <blacktrash at gmx.net> wrote:
> Hi Sean,
>
> * Sean on Wednesday, March 28, 2007 at 18:16:12 +1000:
> > I am trying to do a little post commit automation using commit hooks.
> >
> > I can pick up the %HG_NODE% from the environment (windows) all right,
> > but, how do I then retrieve a list of pathname\file.ext that were
> > committed so that I can do stuff ?
> >
> > The following works in my external .cmd file:
> >
> > hg log --template {files} -r %HG_NODE%
>
> Might break on filenames with spaces.
>
> > but I am sure there must be a way to pass the file directly to the
> > external script rather than have to invoke hg again like this ?
>
> I'd use a python hook, something along those lines (see
> man 5 hgrc), should be safer and faster:
>
> hgrc (adapt "hghooks", "buildhook(.py)"):
>
> #v+
> [hooks]
> commit =
> commit.build = python:hghooks.buildhook.mybuild
> #v-
>
> buildhook.py:
>
> #v+
> from mercurial.node import *
>
> def mybuild(ui=None, repo=None, hooktype='', **args):
>     if hooktype != 'commit':
>         return True
>     files = repo.changelog.read(bin(args['node']))[3]
>
>     # perhaps do a check for removed files and symlinks here
>     if files:
>         # do stuff with files
> #v-
>
>
> c
> --
> _B A U S T E L L E N_ lesen! --->> <http://www.blacktrash.org/baustellen.html>
> _______________________________________________
> Mercurial mailing list
> Mercurial at selenic.com
> http://selenic.com/mailman/listinfo/mercurial
>


More information about the Mercurial mailing list