Mercurial > hg > Members > anatofuz > anatofuz-tools
comparison index.cgi.pl @ 4:c168b4b36ea3
add index.cgi.pl file
author | Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 07 May 2019 06:36:07 +0900 |
parents | |
children | 46d936853422 |
comparison
equal
deleted
inserted
replaced
3:f05a6c7471fa | 4:c168b4b36ea3 |
---|---|
1 #!/usr/bin/env perl | |
2 use strict; | |
3 use warnings; | |
4 | |
5 use DDP; | |
6 | |
7 my ($tartget_hg_version,) = map{ m|/usr/local/Cellar/mercurial/(.*)|; $1} glob "/usr/local/Cellar/mercurial/*"; | |
8 | |
9 while (my $line = <DATA>){ | |
10 if ($line =~ /^(?!#)sys\.path\.insert/) { | |
11 $line =~ s[(mercurial/)(\d+\.?\d+?)(/lib)][$1${tartget_hg_version}$3]; | |
12 } | |
13 print "$line"; | |
14 } | |
15 | |
16 | |
17 __DATA__ | |
18 #!/usr/bin/env python | |
19 # | |
20 # An example CGI script to export multiple hgweb repos, edit as necessary | |
21 | |
22 # adjust python path if not a system-wide install: | |
23 #sys.path.insert(0, "/path/to/python/lib") | |
24 import sys | |
25 sys.path.insert(0, "/usr/local/Cellar/mercurial/5.0/lib/python2.7/site-packages") | |
26 | |
27 # enable importing on demand to reduce startup time | |
28 from mercurial import demandimport; demandimport.enable() | |
29 | |
30 # Uncomment to send python tracebacks to the browser if an error occurs: | |
31 #import cgitb | |
32 #cgitb.enable() | |
33 | |
34 # If you'd like to serve pages with UTF-8 instead of your default | |
35 # locale charset, you can do so by uncommenting the following lines. | |
36 # Note that this will cause your .hgrc files to be interpreted in | |
37 # UTF-8 and all your repo files to be displayed using UTF-8. | |
38 # | |
39 import os | |
40 os.environ["HGENCODING"] = "UTF-8" | |
41 | |
42 from mercurial.hgweb.hgwebdir_mod import hgwebdir | |
43 import mercurial.hgweb.wsgicgi as wsgicgi | |
44 | |
45 # The config file looks like this. You can have paths to individual | |
46 # repos, collections of repos in a directory tree, or both. | |
47 # | |
48 # [paths] | |
49 # virtual/path1 = /real/path1 | |
50 # virtual/path2 = /real/path2 | |
51 # virtual/root = /real/root/* | |
52 # / = /real/root2/* | |
53 # virtual/root2 = /real/root2/** | |
54 # | |
55 # [collections] | |
56 # /prefix/to/strip/off = /root/of/tree/full/of/repos | |
57 # | |
58 # paths example: | |
59 # | |
60 # * First two lines mount one repository into one virtual path, like | |
61 # '/real/path1' into 'virtual/path1'. | |
62 # | |
63 # * The third entry mounts every mercurial repository found in '/real/root' | |
64 # in 'virtual/root'. This format is preferred over the [collections] one, | |
65 # since using absolute paths as configuration keys is not supported on every | |
66 # platform (especially on Windows). | |
67 # | |
68 # * The fourth entry is a special case mounting all repositories in | |
69 # /'real/root2' in the root of the virtual directory. | |
70 # | |
71 # * The fifth entry recursively finds all repositories under the real root, | |
72 # and mounts them using their relative path (to given real root) under the | |
73 # virtual root. | |
74 # | |
75 # collections example: say directory tree /foo contains repos /foo/bar, | |
76 # /foo/quux/baz. Give this config section: | |
77 # [collections] | |
78 # /foo = /foo | |
79 # Then repos will list as bar and quux/baz. | |
80 # | |
81 # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples | |
82 # or use a dictionary with entries like 'virtual/path': '/real/path' | |
83 | |
84 application = hgwebdir('hgweb.config') | |
85 wsgicgi.launch(application) |