Mercurial > hg > Members > anatofuz > anatofuz-tools
annotate index.cgi.pl @ 9:2711ab9baa52 default tip
use core module only
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 04 Jan 2021 11:00:54 +0900 |
parents | 5b8f7c3dd929 |
children |
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 |
6
5b8f7c3dd929
fix sort python versions index.cgi.pl
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
5
diff
changeset
|
5 my ($tartget_hg_version,) = sort { $b <=> $a } map{ m|/usr/local/Cellar/mercurial/(.*)|; $1} glob "/usr/local/Cellar/mercurial/*"; |
4
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 while (my $line = <DATA>){ |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 if ($line =~ /^(?!#)sys\.path\.insert/) { |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 $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
|
10 } |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 print "$line"; |
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 |
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 __DATA__ |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 #!/usr/bin/env python |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 # |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 # 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
|
19 |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 # 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
|
21 #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
|
22 import sys |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 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
|
24 |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 # 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
|
26 from mercurial import demandimport; demandimport.enable() |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 # 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
|
29 #import cgitb |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 #cgitb.enable() |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 # 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
|
33 # 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
|
34 # 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
|
35 # 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
|
36 # |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 import os |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 os.environ["HGENCODING"] = "UTF-8" |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 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
|
41 import mercurial.hgweb.wsgicgi as wsgicgi |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 # 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
|
44 # 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
|
45 # |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46 # [paths] |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 # virtual/path1 = /real/path1 |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
48 # virtual/path2 = /real/path2 |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49 # virtual/root = /real/root/* |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 # / = /real/root2/* |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51 # virtual/root2 = /real/root2/** |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
52 # |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 # [collections] |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
54 # /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
|
55 # |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
56 # paths example: |
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 # * 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
|
59 # '/real/path1' into 'virtual/path1'. |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
60 # |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
61 # * 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
|
62 # 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
|
63 # 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
|
64 # platform (especially on Windows). |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
65 # |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
66 # * 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
|
67 # /'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
|
68 # |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
69 # * 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
|
70 # 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
|
71 # virtual root. |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
72 # |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
73 # 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
|
74 # /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
|
75 # [collections] |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
76 # /foo = /foo |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
77 # 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
|
78 # |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
79 # 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
|
80 # 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
|
81 |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
82 application = hgwebdir('hgweb.config') |
c168b4b36ea3
add index.cgi.pl file
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
83 wsgicgi.launch(application) |