Show More
@@ -9,7 +9,7 | |||||
9 | import os |
|
9 | import os | |
10 | from mercurial.i18n import _ |
|
10 | from mercurial.i18n import _ | |
11 | from mercurial import ui, hg, util, templater, templatefilters |
|
11 | from mercurial import ui, hg, util, templater, templatefilters | |
12 |
from mercurial import |
|
12 | from mercurial import error, encoding | |
13 | from common import ErrorResponse, get_mtime, staticfile, paritygen,\ |
|
13 | from common import ErrorResponse, get_mtime, staticfile, paritygen,\ | |
14 | get_contact, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR |
|
14 | get_contact, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR | |
15 | from hgweb_mod import hgweb |
|
15 | from hgweb_mod import hgweb | |
@@ -30,11 +30,7 class hgwebdir(object): | |||||
30 | self.ui.setconfig('ui', 'report_untrusted', 'off') |
|
30 | self.ui.setconfig('ui', 'report_untrusted', 'off') | |
31 | self.ui.setconfig('ui', 'interactive', 'off') |
|
31 | self.ui.setconfig('ui', 'interactive', 'off') | |
32 |
|
32 | |||
33 | self.motd = None |
|
|||
34 | self.style = 'paper' |
|
|||
35 | self.stripecount = 1 |
|
|||
36 | self.repos_sorted = ('name', False) |
|
33 | self.repos_sorted = ('name', False) | |
37 | self._baseurl = None |
|
|||
38 |
|
34 | |||
39 | if isinstance(conf, (list, tuple)): |
|
35 | if isinstance(conf, (list, tuple)): | |
40 | self.repos = cleannames(conf) |
|
36 | self.repos = cleannames(conf) | |
@@ -42,45 +38,48 class hgwebdir(object): | |||||
42 | elif isinstance(conf, dict): |
|
38 | elif isinstance(conf, dict): | |
43 | self.repos = sorted(cleannames(conf.items())) |
|
39 | self.repos = sorted(cleannames(conf.items())) | |
44 | else: |
|
40 | else: | |
45 | if isinstance(conf, config.config): |
|
41 | self.ui.readconfig(conf, remap={'paths': 'hgweb-paths'}) | |
46 | cp = conf |
|
|||
47 | else: |
|
|||
48 | cp = config.config() |
|
|||
49 | cp.read(conf) |
|
|||
50 | self.repos = [] |
|
42 | self.repos = [] | |
51 | self.motd = cp.get('web', 'motd') |
|
43 | ||
52 | self.style = cp.get('web', 'style', 'paper') |
|
44 | self.motd = self.ui.config('web', 'motd') | |
53 |
|
|
45 | self.style = self.ui.config('web', 'style', 'paper') | |
54 | self._baseurl = cp.get('web', 'baseurl') |
|
46 | self.stripecount = self.ui.config('web', 'stripes', 1) | |
55 | if 'paths' in cp: |
|
47 | if self.stripecount: | |
56 | paths = cleannames(cp.items('paths')) |
|
48 | self.stripecount = int(self.stripecount) | |
57 | for prefix, root in paths: |
|
49 | self._baseurl = self.ui.config('web', 'baseurl') | |
58 | roothead, roottail = os.path.split(root) |
|
50 | ||
59 | # "foo = /bar/*" makes every subrepo of /bar/ to be |
|
51 | if self.repos: | |
60 | # mounted as foo/subrepo |
|
52 | return | |
61 | # and "foo = /bar/**" does even recurse inside the |
|
53 | ||
62 | # subdirectories, remember to use it without working dir. |
|
54 | for prefix, root in cleannames(self.ui.configitems('hgweb-paths')): | |
63 | try: |
|
55 | roothead, roottail = os.path.split(root) | |
64 | recurse = {'*': False, '**': True}[roottail] |
|
56 | # "foo = /bar/*" makes every subrepo of /bar/ to be | |
65 | except KeyError: |
|
57 | # mounted as foo/subrepo | |
66 | self.repos.append((prefix, root)) |
|
58 | # and "foo = /bar/**" also recurses into the subdirectories, | |
67 | continue |
|
59 | # remember to use it without working dir. | |
68 | roothead = os.path.normpath(roothead) |
|
60 | try: | |
69 | for path in util.walkrepos(roothead, followsym=True, |
|
61 | recurse = {'*': False, '**': True}[roottail] | |
70 | recurse=recurse): |
|
62 | except KeyError: | |
71 | path = os.path.normpath(path) |
|
63 | self.repos.append((prefix, root)) | |
72 | name = util.pconvert(path[len(roothead):]).strip('/') |
|
64 | continue | |
73 | if prefix: |
|
65 | roothead = os.path.normpath(roothead) | |
74 | name = prefix + '/' + name |
|
66 | for path in util.walkrepos(roothead, followsym=True, | |
75 | self.repos.append((name, path)) |
|
67 | recurse=recurse): | |
76 | for prefix, root in cp.items('collections'): |
|
68 | path = os.path.normpath(path) | |
77 | for path in util.walkrepos(root, followsym=True): |
|
69 | name = util.pconvert(path[len(roothead):]).strip('/') | |
78 | repo = os.path.normpath(path) |
|
70 | if prefix: | |
79 |
name = |
|
71 | name = prefix + '/' + name | |
80 | if name.startswith(prefix): |
|
72 | self.repos.append((name, path)) | |
81 | name = name[len(prefix):] |
|
73 | ||
82 | self.repos.append((name.lstrip(os.sep), repo)) |
|
74 | for prefix, root in self.ui.configitems('collections'): | |
83 | self.repos.sort() |
|
75 | for path in util.walkrepos(root, followsym=True): | |
|
76 | repo = os.path.normpath(path) | |||
|
77 | name = repo | |||
|
78 | if name.startswith(prefix): | |||
|
79 | name = name[len(prefix):] | |||
|
80 | self.repos.append((name.lstrip(os.sep), repo)) | |||
|
81 | ||||
|
82 | self.repos.sort() | |||
84 |
|
83 | |||
85 | def run(self): |
|
84 | def run(self): | |
86 | if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."): |
|
85 | if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."): |
@@ -58,7 +58,7 class ui(object): | |||||
58 | return False |
|
58 | return False | |
59 |
|
59 | |||
60 | def readconfig(self, filename, root=None, trust=False, |
|
60 | def readconfig(self, filename, root=None, trust=False, | |
61 | sections=None): |
|
61 | sections=None, remap=None): | |
62 | try: |
|
62 | try: | |
63 | fp = open(filename) |
|
63 | fp = open(filename) | |
64 | except IOError: |
|
64 | except IOError: | |
@@ -70,7 +70,7 class ui(object): | |||||
70 | trusted = sections or trust or self._is_trusted(fp, filename) |
|
70 | trusted = sections or trust or self._is_trusted(fp, filename) | |
71 |
|
71 | |||
72 | try: |
|
72 | try: | |
73 | cfg.read(filename, fp, sections=sections) |
|
73 | cfg.read(filename, fp, sections=sections, remap=remap) | |
74 | except error.ConfigError, inst: |
|
74 | except error.ConfigError, inst: | |
75 | if trusted: |
|
75 | if trusted: | |
76 | raise |
|
76 | raise |
General Comments 0
You need to be logged in to leave comments.
Login now