OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # An example CGI script to export multiple hgweb repos, edit as necessary | 3 # An example CGI script to export multiple hgweb repos, edit as necessary |
4 | 4 |
5 import re | 5 import re |
6 | 6 |
7 # adjust python path if not a system-wide install: | 7 # adjust python path if not a system-wide install: |
8 #import sys | 8 #import sys |
9 #sys.path.insert(0, "/path/to/python/lib") | 9 #sys.path.insert(0, "/path/to/python/lib") |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 # UTF-8 and all your repo files to be displayed using UTF-8. | 21 # UTF-8 and all your repo files to be displayed using UTF-8. |
22 # | 22 # |
23 #import os | 23 #import os |
24 #os.environ["HGENCODING"] = "UTF-8" | 24 #os.environ["HGENCODING"] = "UTF-8" |
25 | 25 |
26 from mercurial.hgweb.hgwebdir_mod import hgwebdir | 26 from mercurial.hgweb.hgwebdir_mod import hgwebdir |
27 from flup.server.fcgi import WSGIServer | 27 from flup.server.fcgi import WSGIServer |
28 from urllib import unquote | 28 from urllib import unquote |
29 import sys | 29 import sys |
30 | 30 |
31 # Serialize ui.setconfig() accesses to avoid hitting http://bz.selenic.com/show_
bug.cgi?id=3953 | |
32 from mercurial.ui import ui | |
33 import thread | |
34 | |
35 config_lock = thread.allocate_lock() | |
36 orig_setconfig = ui.setconfig | |
37 | |
38 def new_setconfig(*args, **kwargs): | |
39 with config_lock: | |
40 orig_setconfig(*args, **kwargs) | |
41 | |
42 ui.setconfig = new_setconfig | |
43 | |
44 # The config file looks like this. You can have paths to individual | 31 # The config file looks like this. You can have paths to individual |
45 # repos, collections of repos in a directory tree, or both. | 32 # repos, collections of repos in a directory tree, or both. |
46 # | 33 # |
47 # [paths] | 34 # [paths] |
48 # virtual/path1 = /real/path1 | 35 # virtual/path1 = /real/path1 |
49 # virtual/path2 = /real/path2 | 36 # virtual/path2 = /real/path2 |
50 # virtual/root = /real/root/* | 37 # virtual/root = /real/root/* |
51 # / = /real/root2/* | 38 # / = /real/root2/* |
52 # | 39 # |
53 # [collections] | 40 # [collections] |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 else: | 73 else: |
87 return result | 74 return result |
88 | 75 |
89 def do_filter(self, iter, req): | 76 def do_filter(self, iter, req): |
90 for chunk in iter: | 77 for chunk in iter: |
91 yield re.sub(r'\bemail=.*?([\r\n]|$)', r'email=xxxx\1',
chunk) | 78 yield re.sub(r'\bemail=.*?([\r\n]|$)', r'email=xxxx\1',
chunk) |
92 if hasattr(iter, 'close'): | 79 if hasattr(iter, 'close'): |
93 iter.close() | 80 iter.close() |
94 | 81 |
95 WSGIServer(hgwebdir_with_filter('/etc/hgweb.ini'), debug=False).run() | 82 WSGIServer(hgwebdir_with_filter('/etc/hgweb.ini'), debug=False).run() |
OLD | NEW |