Reload hgrc before notify hook call ?

Yannick CHARLES yannick.charles at gmail.com
Wed Dec 5 14:55:54 UTC 2012


Thanks for your answers. :)

I've tried to look into notify.py source code, and to find information on
Mercurial API. I found ui.readconfig() that might do the job.
Regarding the API, I found the page
http://mercurial.selenic.com/wiki/MercurialApi - is there a more complete
documentation somewhere ?

Regarding notify source code, I tried to modify the file located at
/usr/share/pyshared/hgext/notify.py and it doesn't seem to reflect the
changes I make.
Is there something particular I need to do, or do I miss some point (I'm a
python newbie, sorry).

Yannick

2012/12/4 Matt Mackall <mpm at selenic.com>

> On Tue, 2012-12-04 at 13:47 +0100, Yannick CHARLES wrote:
> > Hello to everybody,
> >
> > I have the following hgrc in a versionned patch queue, on a remote
> > server where I can push over http:
> > ------
> > #
> > # [web] section goes here
> > #
> >
> > [hooks]
> > changegroup.00updatefiles = hg update
> > changegroup.01autobuild_patch = bash ../patch_chgrouphook.sh Yann
> >
> > # Include notify parameters
> > %include /var/hg/repos/test-syst/.hg/notifypatches.rc
> >
> > [hooks]
> > # Here for testing purposes
> > changegroup.02upcf = hg showconfig
> >
> > # Include notify hook
> > %include /var/hg/repos/test-syst/.hg/notifyphook.rc
> > ------
> >
> > /var/hg/repos/test-syst/.hg/notifyphook.rc normally contains the
> > following lines:
> > ------
> > [hooks]
> > changegroup.03notify = python:hgext.notify.hook
> > ------
> >
> > Hook 01 rebuilds the project's output files, but also modify notify's
> > template. This modification is reflected by hook 02 where I see the new
> > template.
> > However, in hook 03, notify still uses the old template.
> >
> > I guess this is because though hooks are run in order, hgrc is only
> > parsed once when I push on the repo (and parsed again to run
> > showconfig), so notify is passed the values present in hgrc at the
> > beginning of the changegroup event.
> > Is my interpretation correct?
> >
> > My second problem is that in some cases, I wouldn't like notify to send
> > e-mails (e.g. the patch queue is empty). To achieve this I tried in the
> > same way to have the bash script called by the 01 hook to modify
> > notifyphook.rc into an empty file, but I have the same problem (i.e. the
> > file used is the previous one).
> >
> >
> > So starting from this, I have three questions:
> > -Is there a way to somehow reload hgrc before calling the notify hook,
> > or to call it with the updated parameters (if so, it could fix the 2nd
> > pb as well, as I would set notify.test to true)?
>
> No.
>
> > -Would it be possible to call the python notify hook directly from the
> > bash script from hook 01?
>
> No.
>
> > -Is it possible to run a hook only under certain conditions?
>
> No.
>
> > Or maybe I'm looking at the wrong direction, and it would be better to
> > rewrite a mail-sending procedure from scratch in the form of a bash
> > script for example?
>
> You could do that. Or you could make (fairly minor) changes to a private
> copy of notify.py.
>
> --
> Mathematics is the supreme nostalgia of our time.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20121205/289b38c7/attachment-0002.html>


More information about the Mercurial mailing list