cgi-bin/repos.cgi
author Christian Urban <urbanc@in.tum.de>
Thu, 19 Apr 2018 13:44:34 +0100
changeset 528 3b76d8e0fa76
parent 474 10ae557fb308
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
#!/usr/bin/env python
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
#
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
# An example CGI script to export multiple hgweb repos, edit as necessary
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
# adjust python path if not a system-wide install:
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
import sys
362
3c0e119f5caa updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 20
diff changeset
     7
sys.path.append("/usr/local/lib/python2.7/site-packages/")
18
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
# enable importing on demand to reduce startup time
416
75df587e1bcd updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
    10
#from mercurial import demandimport; demandimport.enable()
18
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
# Uncomment to send python tracebacks to the browser if an error occurs:
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
import cgitb
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
cgitb.enable()
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
# If you'd like to serve pages with UTF-8 instead of your default
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
# locale charset, you can do so by uncommenting the following lines.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
# Note that this will cause your .hgrc files to be interpreted in
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
# UTF-8 and all your repo files to be displayed using UTF-8.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
#
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
import os
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
os.environ["HGENCODING"] = "UTF-8"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
from mercurial.hgweb.hgwebdir_mod import hgwebdir
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
import mercurial.hgweb.wsgicgi as wsgicgi
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
# The config file looks like this.  You can have paths to individual
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
# repos, collections of repos in a directory tree, or both.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
#
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
# [paths]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
# virtual/path = /real/path
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
# virtual/path = /real/path
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
#
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
# [collections]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
# /prefix/to/strip/off = /root/of/tree/full/of/repos
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
#
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
# collections example: say directory tree /foo contains repos /foo/bar,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
# /foo/quux/baz.  Give this config section:
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
#   [collections]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
#   /foo = /foo
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
# Then repos will list as bar and quux/baz.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
#
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
# Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
# or use a dictionary with entries like 'virtual/path': '/real/path'
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
474
10ae557fb308 updated
Christian Urban <urbanc@in.tum.de>
parents: 416
diff changeset
    46
application = hgwebdir('/home/k1192855/HGREPOS/hgweb.config')
18
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
wsgicgi.launch(application)