rlm@0
|
1 #!/usr/bin/env python
|
rlm@0
|
2 #
|
rlm@0
|
3 # An example CGI script to export multiple hgweb repos, edit as necessary
|
rlm@0
|
4
|
rlm@0
|
5 # adjust python path if not a system-wide install:
|
rlm@0
|
6 #import sys
|
rlm@0
|
7 #sys.path.insert(0, "/path/to/python/lib")
|
rlm@0
|
8
|
rlm@0
|
9 # enable importing on demand to reduce startup time
|
rlm@0
|
10 from mercurial import demandimport; demandimport.enable()
|
rlm@0
|
11
|
rlm@0
|
12 # Uncomment to send python tracebacks to the browser if an error occurs:
|
rlm@0
|
13 #import cgitb
|
rlm@0
|
14 #cgitb.enable()
|
rlm@0
|
15
|
rlm@0
|
16 # If you'd like to serve pages with UTF-8 instead of your default
|
rlm@0
|
17 # locale charset, you can do so by uncommenting the following lines.
|
rlm@0
|
18 # Note that this will cause your .hgrc files to be interpreted in
|
rlm@0
|
19 # UTF-8 and all your repo files to be displayed using UTF-8.
|
rlm@0
|
20 #
|
rlm@0
|
21 #import os
|
rlm@0
|
22 #os.environ["HGENCODING"] = "UTF-8"
|
rlm@0
|
23
|
rlm@0
|
24 from mercurial.hgweb.hgwebdir_mod import hgwebdir
|
rlm@0
|
25 import mercurial.hgweb.wsgicgi as wsgicgi
|
rlm@0
|
26
|
rlm@0
|
27 # The config file looks like this. You can have paths to individual
|
rlm@0
|
28 # repos, collections of repos in a directory tree, or both.
|
rlm@0
|
29 #
|
rlm@0
|
30 # [paths]
|
rlm@0
|
31 # virtual/path1 = /real/path1
|
rlm@0
|
32 # virtual/path2 = /real/path2
|
rlm@0
|
33 # virtual/root = /real/root/*
|
rlm@0
|
34 # / = /real/root2/*
|
rlm@0
|
35 # virtual/root2 = /real/root2/**
|
rlm@0
|
36 #
|
rlm@0
|
37 # [collections]
|
rlm@0
|
38 # /prefix/to/strip/off = /root/of/tree/full/of/repos
|
rlm@0
|
39 #
|
rlm@0
|
40 # paths example:
|
rlm@0
|
41 #
|
rlm@0
|
42 # * First two lines mount one repository into one virtual path, like
|
rlm@0
|
43 # '/real/path1' into 'virtual/path1'.
|
rlm@0
|
44 #
|
rlm@0
|
45 # * The third entry mounts every mercurial repository found in '/real/root'
|
rlm@0
|
46 # in 'virtual/root'. This format is preferred over the [collections] one,
|
rlm@0
|
47 # since using absolute paths as configuration keys is not supported on every
|
rlm@0
|
48 # platform (especially on Windows).
|
rlm@0
|
49 #
|
rlm@0
|
50 # * The fourth entry is a special case mounting all repositories in
|
rlm@0
|
51 # /'real/root2' in the root of the virtual directory.
|
rlm@0
|
52 #
|
rlm@0
|
53 # * The fifth entry recursively finds all repositories under the real root,
|
rlm@0
|
54 # and mounts them using their relative path (to given real root) under the
|
rlm@0
|
55 # virtual root.
|
rlm@0
|
56 #
|
rlm@0
|
57 # collections example: say directory tree /foo contains repos /foo/bar,
|
rlm@0
|
58 # /foo/quux/baz. Give this config section:
|
rlm@0
|
59 # [collections]
|
rlm@0
|
60 # /foo = /foo
|
rlm@0
|
61 # Then repos will list as bar and quux/baz.
|
rlm@0
|
62 #
|
rlm@0
|
63 # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
|
rlm@0
|
64 # or use a dictionary with entries like 'virtual/path': '/real/path'
|
rlm@0
|
65
|
rlm@0
|
66 application = hgwebdir('hgweb.config')
|
rlm@0
|
67 wsgicgi.launch(application)
|