Here’s a quick and easy recipe for serving a mercurial repository with mod_wsgi.
Create a file called hgwebdir.wsgi with these contents:
from mercurial.hgweb.request import wsgiapplication from mercurial.hgweb.hgwebdir_mod import hgwebdir def make_web_app(): return hgwebdir("/path/to/hgweb.config") application = wsgiapplication(make_web_app)Add it to the apache configuration:
WSGIScriptAlias /hg /path/to/hgwebdir.wsgi
[optional] To make sure nobody modifies your repository via the http interface, add ‘deny_push = *’ to the ‘[web]‘ group of hgweb.config.
Hopefully this page will save the next person a few minutes of searching.
Hi,
is it compatible with pushing over http (as with CGI) ?
When I use this wsgi script the syntax highlighting using your extension doesn’t work (it’s in hgweb.config though). Using “hg serve” it does though. I tried everything like providing the absolute path to the hightlight.py file. What other things can I check?
To answer these questions:
1) I’m not sure if it’s compatible with pushing over HTTP but my guess would that it is. I always use ssh if I’m going to push though.
2) This is probably a PYTHONPATH issue. Do you have multiple hg installs? You can make sure this uses the right one by putting:
import sys sys.path.insert(0, “/path/to/correct/hg/install”)
at the top of the .wsgi script.
I only have one install, nonetheless I tried to set the path in the script, but without luck. When I put the extension in hgweb.config of hgwebdir it doesn’t work, however when I put the entry in every repositories’ hgrc, everything works fine.
I haven’t tried other extensions in the general hgwebdir config, so maybe it’s a mercurial thing.