Adam Hupp


Serving mercurial with mod_wsgi

Here’s a quick and easy recipe for serving a mercurial repository with mod_wsgi.

  1. 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)
  2. Add it to the apache configuration:

    WSGIScriptAlias /hg /path/to/hgwebdir.wsgi
  3. [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.