Chris@1576: #!/usr/bin/env python Chris@1576: # Chris@1576: # An example CGI script to export multiple hgweb repos, edit as necessary Chris@1576: Chris@1576: # adjust python path if not a system-wide install: Chris@1576: #import sys Chris@1576: #sys.path.insert(0, "/path/to/python/lib") Chris@1576: Chris@1576: # enable importing on demand to reduce startup time Chris@1576: from mercurial import demandimport; demandimport.enable() Chris@1576: Chris@1576: # Uncomment to send python tracebacks to the browser if an error occurs: Chris@1622: #import cgitb Chris@1622: #cgitb.enable() Chris@1576: Chris@1576: # If you'd like to serve pages with UTF-8 instead of your default Chris@1576: # locale charset, you can do so by uncommenting the following lines. Chris@1576: # Note that this will cause your .hgrc files to be interpreted in Chris@1576: # UTF-8 and all your repo files to be displayed using UTF-8. Chris@1576: # Chris@1576: import os Chris@1576: os.environ["HGENCODING"] = "UTF-8" Chris@1576: Chris@1576: from mercurial.hgweb.hgwebdir_mod import hgwebdir Chris@1576: import mercurial.hgweb.wsgicgi as wsgicgi Chris@1576: Chris@1576: # The config file looks like this. You can have paths to individual Chris@1576: # repos, collections of repos in a directory tree, or both. Chris@1576: # Chris@1576: # [paths] Chris@1576: # virtual/path1 = /real/path1 Chris@1576: # virtual/path2 = /real/path2 Chris@1576: # virtual/root = /real/root/* Chris@1576: # / = /real/root2/* Chris@1576: # virtual/root2 = /real/root2/** Chris@1576: # Chris@1576: # [collections] Chris@1576: # /prefix/to/strip/off = /root/of/tree/full/of/repos Chris@1576: # Chris@1576: # paths example: Chris@1576: # Chris@1576: # * First two lines mount one repository into one virtual path, like Chris@1576: # '/real/path1' into 'virtual/path1'. Chris@1576: # Chris@1576: # * The third entry mounts every mercurial repository found in '/real/root' Chris@1576: # in 'virtual/root'. This format is preferred over the [collections] one, Chris@1576: # since using absolute paths as configuration keys is not supported on every Chris@1576: # platform (especially on Windows). Chris@1576: # Chris@1576: # * The fourth entry is a special case mounting all repositories in Chris@1576: # /'real/root2' in the root of the virtual directory. Chris@1576: # Chris@1576: # * The fifth entry recursively finds all repositories under the real root, Chris@1576: # and mounts them using their relative path (to given real root) under the Chris@1576: # virtual root. Chris@1576: # Chris@1576: # collections example: say directory tree /foo contains repos /foo/bar, Chris@1576: # /foo/quux/baz. Give this config section: Chris@1576: # [collections] Chris@1576: # /foo = /foo Chris@1576: # Then repos will list as bar and quux/baz. Chris@1576: # Chris@1576: # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples Chris@1576: # or use a dictionary with entries like 'virtual/path': '/real/path' Chris@1576: Chris@1576: application = hgwebdir('hgweb.config') Chris@1576: wsgicgi.launch(application)