view hgweb.cgi @ 20208:61a47fd64f30 stable

fileset, revset: do not use global parser object for thread safety parse() cannot be called at the same time because a parser object keeps its states. This is no problem for command-line hg client, but it would cause strange errors in multi-threaded hgweb. Creating parser object is not too expensive. original: % python -m timeit -s 'from mercurial import revset' 'revset.parse("0::tip")' 100000 loops, best of 3: 11.3 usec per loop thread-safe: % python -m timeit -s 'from mercurial import revset' 'revset.parse("0::tip")' 100000 loops, best of 3: 13.1 usec per loop
author Yuya Nishihara <yuya@tcha.org>
date Sat, 21 Dec 2013 12:44:19 +0900
parents 85cba926cb59
children 4b0fc75f9403
line wrap: on
line source

#!/usr/bin/env python
#
# An example hgweb CGI script, edit as necessary
# See also http://mercurial.selenic.com/wiki/PublishingRepositories

# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "/path/to/repo/or/config"

# Uncomment and adjust if Mercurial is not installed system-wide
# (consult "installed modules" path from 'hg debuginstall'):
#import sys; sys.path.insert(0, "/path/to/python/lib")

# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb; cgitb.enable()

from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb, wsgicgi
application = hgweb(config)
wsgicgi.launch(application)