Reload hgrc before notify hook call ?

Matt Mackall mpm at selenic.com
Tue Dec 4 21:31:50 UTC 2012


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.





More information about the Mercurial mailing list