Merged in changes from bugzilla extension in mercurial 1.8.2.
3 # An example CGI script to export multiple hgweb repos, edit as necessary
5 # adjust python path if not a system-wide install:
7 #sys.path.insert(0, "/path/to/python/lib")
9 # enable importing on demand to reduce startup time
10 from mercurial import demandimport; demandimport.enable()
12 # Uncomment to send python tracebacks to the browser if an error occurs:
16 # If you'd like to serve pages with UTF-8 instead of your default
17 # locale charset, you can do so by uncommenting the following lines.
18 # Note that this will cause your .hgrc files to be interpreted in
19 # UTF-8 and all your repo files to be displayed using UTF-8.
22 #os.environ["HGENCODING"] = "UTF-8"
24 from mercurial import extensions
25 from mercurial.hgweb.hgwebdir_mod import hgwebdir
26 import mercurial.hgweb.wsgicgi as wsgicgi
28 # The config file looks like this. You can have paths to individual
29 # repos, collections of repos in a directory tree, or both.
32 # virtual/path1 = /real/path1
33 # virtual/path2 = /real/path2
34 # virtual/root = /real/root/*
36 # virtual/root2 = /real/root2/**
39 # /prefix/to/strip/off = /root/of/tree/full/of/repos
43 # * First two lines mount one repository into one virtual path, like
44 # '/real/path1' into 'virtual/path1'.
46 # * The third entry mounts every mercurial repository found in '/real/root'
47 # in 'virtual/root'. This format is preferred over the [collections] one,
48 # since using absolute paths as configuration keys is not supported on every
49 # platform (especially on Windows).
51 # * The fourth entry is a special case mounting all repositories in
52 # /'real/root2' in the root of the virtual directory.
54 # * The fifth entry recursively finds all repositories under the real root,
55 # and mounts them using their relative path (to given real root) under the
58 # collections example: say directory tree /foo contains repos /foo/bar,
59 # /foo/quux/baz. Give this config section:
62 # Then repos will list as bar and quux/baz.
64 # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
65 # or use a dictionary with entries like 'virtual/path': '/real/path'
68 path = os.environ['SCRIPT_NAME']
71 if path is None or path is '':
74 path = path.replace('/', hgroot + '/', 1)
76 for item in os.listdir(path):
77 repo_path = os.path.join(path, item)
78 if os.path.isdir(os.path.join(repo_path, '.hg')):
79 repo_list.append(( item, repo_path ))
83 application = hgwebdir(repo_list)
84 application._baseurl = None
85 extensions.loadall(application.ui)
86 wsgicgi.launch(application)