#!/usr/bin/env python # $Id$ # send python tracebacks to the browser if an error occurs: import cgitb cgitb.enable() from string import split # If you'd like to serve pages with UTF-8 instead of your default # locale charset, you can do so by uncommenting the following lines. # Note that this will cause your .hgrc files to be interpreted in # UTF-8 and all your repo files to be displayed using UTF-8. # import os os.environ["HGENCODING"] = "UTF-8" from mercurial.hgweb.hgweb_mod import hgweb from mercurial.hgweb.request import wsgiapplication import mercurial.hgweb.wsgicgi as wsgicgi class Server: def __init__(self, path): self.path = path def run(self): def make_web_app(): return hgweb(self.path, "repository name") wsgicgi.launch(wsgiapplication(make_web_app)) url = os.environ['REQUEST_URI'].split('?')[0] tool_name = split(url, '/')[1] rep_path = os.path.join(os.environ['BASE_HG_PATH'], tool_name) if len(tool_name) > 0 and os.path.exists(rep_path): Server(os.path.join(rep_path, 'repository')).run() else: send_error() def send_error(): pass