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