author | wenzelm |
Sat, 02 Aug 2014 19:38:32 +0200 | |
changeset 57844 | ae3eac418c5f |
parent 40385 | b70ef70733e8 |
permissions | -rwxr-xr-x |
27725
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
2 |
# |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
3 |
# An example CGI script to export multiple hgweb repos, edit as necessary |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
4 |
|
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
5 |
# adjust python path if not a system-wide install: |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
6 |
import sys |
40385
b70ef70733e8
reflect actual content of /home/isabelle/.html-data/cgi-bin/hgwebdir.cgi;
wenzelm
parents:
28930
diff
changeset
|
7 |
# using the hg installation provided by the system (AK, 3.3.2010) |
b70ef70733e8
reflect actual content of /home/isabelle/.html-data/cgi-bin/hgwebdir.cgi;
wenzelm
parents:
28930
diff
changeset
|
8 |
#sys.path.insert(0, "/home/isabelle-repository/repos/mercurial-www4/lib64/python2.5/site-packages") |
b70ef70733e8
reflect actual content of /home/isabelle/.html-data/cgi-bin/hgwebdir.cgi;
wenzelm
parents:
28930
diff
changeset
|
9 |
#sys.path.insert(0, "/usr/lib64/python2.5/site-packages") |
b70ef70733e8
reflect actual content of /home/isabelle/.html-data/cgi-bin/hgwebdir.cgi;
wenzelm
parents:
28930
diff
changeset
|
10 |
#sys.path.insert(0, "/home/isabelle-repository/repos/mercurial-1.3.1/lib64") |
b70ef70733e8
reflect actual content of /home/isabelle/.html-data/cgi-bin/hgwebdir.cgi;
wenzelm
parents:
28930
diff
changeset
|
11 |
#sys.path.insert(0, "/home/isabelle-repository/repos/testtool") |
b70ef70733e8
reflect actual content of /home/isabelle/.html-data/cgi-bin/hgwebdir.cgi;
wenzelm
parents:
28930
diff
changeset
|
12 |
|
27725
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
13 |
|
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
14 |
# enable importing on demand to reduce startup time |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
15 |
from mercurial import demandimport; demandimport.enable() |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
16 |
|
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
17 |
# Uncomment to send python tracebacks to the browser if an error occurs: |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
18 |
import cgitb |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
19 |
cgitb.enable() |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
20 |
|
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
21 |
# If you'd like to serve pages with UTF-8 instead of your default |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
22 |
# locale charset, you can do so by uncommenting the following lines. |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
23 |
# Note that this will cause your .hgrc files to be interpreted in |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
24 |
# UTF-8 and all your repo files to be displayed using UTF-8. |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
25 |
# |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
26 |
import os |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
27 |
os.environ["HGENCODING"] = "UTF-8" |
40385
b70ef70733e8
reflect actual content of /home/isabelle/.html-data/cgi-bin/hgwebdir.cgi;
wenzelm
parents:
28930
diff
changeset
|
28 |
os.environ["HGRCPATH"] = "/home/isabelle-repository/repos/hgrc" |
27725
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
29 |
|
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
30 |
from mercurial.hgweb.hgwebdir_mod import hgwebdir |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
31 |
import mercurial.hgweb.wsgicgi as wsgicgi |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
32 |
|
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
33 |
# The config file looks like this. You can have paths to individual |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
34 |
# repos, collections of repos in a directory tree, or both. |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
35 |
# |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
36 |
# [paths] |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
37 |
# virtual/path = /real/path |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
38 |
# virtual/path = /real/path |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
39 |
# |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
40 |
# [collections] |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
41 |
# /prefix/to/strip/off = /root/of/tree/full/of/repos |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
42 |
# |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
43 |
# collections example: say directory tree /foo contains repos /foo/bar, |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
44 |
# /foo/quux/baz. Give this config section: |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
45 |
# [collections] |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
46 |
# /foo = /foo |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
47 |
# Then repos will list as bar and quux/baz. |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
48 |
# |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
49 |
# Alternatively you can pass a list of ('virtual/path', '/real/path') tuples |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
50 |
# or use a dictionary with entries like 'virtual/path': '/real/path' |
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
51 |
|
28000
ca56bbb99607
replaced /home/isabelle/html-data/isabelle-repos by /home/isabelle-repository/repos;
wenzelm
parents:
27725
diff
changeset
|
52 |
application = hgwebdir('/home/isabelle-repository/repos/hgweb.config') |
27725
6d133c2b681f
replaced mercurial.cgi by hgwebdir.cgi, resulting in http://isabelle.in.tum.de/repos/isabelle/
wenzelm
parents:
diff
changeset
|
53 |
wsgicgi.launch(application) |