##// END OF EJS Templates
hgwebdir: read --webdir-conf as actual configuration to ui (issue1586)...
Alexander Solovyov -
r8345:dcebff8a default
parent child Browse files
Show More
@@ -9,7 +9,7 b''
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 config, error, encoding
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 b' 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,24 +38,25 b' 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 self.stripecount = cp.get('web', 'stripes', 1)
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')
50
51 if self.repos:
52 return
53
54 for prefix, root in cleannames(self.ui.configitems('hgweb-paths')):
58 roothead, roottail = os.path.split(root)
55 roothead, roottail = os.path.split(root)
59 # "foo = /bar/*" makes every subrepo of /bar/ to be
56 # "foo = /bar/*" makes every subrepo of /bar/ to be
60 # mounted as foo/subrepo
57 # mounted as foo/subrepo
61 # and "foo = /bar/**" does even recurse inside the
58 # and "foo = /bar/**" also recurses into the subdirectories,
62 # subdirectories, remember to use it without working dir.
59 # remember to use it without working dir.
63 try:
60 try:
64 recurse = {'*': False, '**': True}[roottail]
61 recurse = {'*': False, '**': True}[roottail]
65 except KeyError:
62 except KeyError:
@@ -73,13 +70,15 b' class hgwebdir(object):'
73 if prefix:
70 if prefix:
74 name = prefix + '/' + name
71 name = prefix + '/' + name
75 self.repos.append((name, path))
72 self.repos.append((name, path))
76 for prefix, root in cp.items('collections'):
73
74 for prefix, root in self.ui.configitems('collections'):
77 for path in util.walkrepos(root, followsym=True):
75 for path in util.walkrepos(root, followsym=True):
78 repo = os.path.normpath(path)
76 repo = os.path.normpath(path)
79 name = repo
77 name = repo
80 if name.startswith(prefix):
78 if name.startswith(prefix):
81 name = name[len(prefix):]
79 name = name[len(prefix):]
82 self.repos.append((name.lstrip(os.sep), repo))
80 self.repos.append((name.lstrip(os.sep), repo))
81
83 self.repos.sort()
82 self.repos.sort()
84
83
85 def run(self):
84 def run(self):
@@ -58,7 +58,7 b' 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 b' 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