How to load global mercurial configuration from wsgi scripts?

Giannini, Matthew mgiannini at tridium.com
Fri Jul 20 17:58:46 UTC 2012


We have an extension running on our mercurial server that programmatically registers some hooks via the extsetup(ui) callback. These hooks are pretxnchangegroup hooks.  We enabled the extension via the /etc/mercurial/hgrc global configuration file.  The extension runs fine and has no problem when we use the hgweb.cgi script.

However, we recently switched to hgweb.wsgi  because it is *so* much better (especially for largefile repos).

Anyway, we noticed that our extension was no longer running, and therefore our hooks were not running when we switched to the wsgi version of hgweb.  While investigating this problem, I came across this link:

http://mercurial.selenic.com/wiki/WebUserDirExtension

I basically followed the instructions there and modified the hgweb.wsgi script to be:

from mercurial import demandimport; demandimport.enable()
from mercurial import extensions, hgweb, ui as uimod
ui = uimod.ui()
ui.readconfig('hgwebdir.config', trust=True)
extensions.loadall(ui)
application = hgweb.hgwebdir('hgwebdir.config', baseui=ui)

Except, I changed it to ui.readconfig('/etc/mercurial/hgrc', trust=True) to read the global hgrc file.

And now everything works great.  But I want to make sure this is the "best" way to enable the configuration from our global hgrc file?

Thanks and Regards,
matthew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20120720/fc4dfa05/attachment-0002.html>


More information about the Mercurial mailing list