Show More
@@ -57,7 +57,7 b' class config:' | |||
|
57 | 57 | self._data[section] = sortdict() |
|
58 | 58 | self._data[section][item] = (value, source) |
|
59 | 59 | |
|
60 | def read(self, path, fp): | |
|
60 | def read(self, path, fp=None): | |
|
61 | 61 | sectionre = re.compile(r'\[([^\[]+)\]') |
|
62 | 62 | itemre = re.compile(r'([^=\s]+)\s*=\s*(.*)') |
|
63 | 63 | contre = re.compile(r'\s+(\S.*)') |
@@ -66,6 +66,10 b' class config:' | |||
|
66 | 66 | item = None |
|
67 | 67 | line = 0 |
|
68 | 68 | cont = 0 |
|
69 | ||
|
70 | if not fp: | |
|
71 | fp = open(path) | |
|
72 | ||
|
69 | 73 | for l in fp: |
|
70 | 74 | line += 1 |
|
71 | 75 | if cont: |
@@ -8,7 +8,8 b'' | |||
|
8 | 8 | |
|
9 | 9 | import os |
|
10 | 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 | 13 | from common import ErrorResponse, get_mtime, staticfile, paritygen,\ |
|
13 | 14 | get_contact, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR |
|
14 | 15 | from hgweb_mod import hgweb |
@@ -16,7 +17,7 b' from request import wsgirequest' | |||
|
16 | 17 | |
|
17 | 18 | # This is a stopgap |
|
18 | 19 | class hgwebdir(object): |
|
19 |
def __init__(self, conf |
|
|
20 | def __init__(self, conf, parentui=None): | |
|
20 | 21 | def cleannames(items): |
|
21 | 22 | return [(util.pconvert(name).strip('/'), path) |
|
22 | 23 | for name, path in items] |
@@ -33,28 +34,23 b' class hgwebdir(object):' | |||
|
33 | 34 | self.stripecount = None |
|
34 | 35 | self.repos_sorted = ('name', False) |
|
35 | 36 | self._baseurl = None |
|
36 |
if isinstance(conf |
|
|
37 |
self.repos = cleannames(conf |
|
|
37 | if isinstance(conf, (list, tuple)): | |
|
38 | self.repos = cleannames(conf) | |
|
38 | 39 | self.repos_sorted = ('', False) |
|
39 |
elif isinstance(conf |
|
|
40 |
self.repos = util.sort(cleannames(conf |
|
|
40 | elif isinstance(conf, dict): | |
|
41 | self.repos = util.sort(cleannames(conf.items())) | |
|
41 | 42 | else: |
|
42 |
if isinstance(conf |
|
|
43 |
cp = conf |
|
|
43 | if isinstance(conf, config.config): | |
|
44 | cp = conf | |
|
44 | 45 | else: |
|
45 |
cp = |
|
|
46 |
cp.read(conf |
|
|
46 | cp = config.config() | |
|
47 | cp.read(conf) | |
|
47 | 48 | self.repos = [] |
|
48 |
|
|
|
49 | if cp.has_option('web', 'motd'): | |
|
50 |
|
|
|
51 |
|
|
|
52 | self.style = cp.get('web', 'style') | |
|
53 | if cp.has_option('web', 'stripes'): | |
|
54 | self.stripecount = int(cp.get('web', 'stripes')) | |
|
55 | if cp.has_option('web', 'baseurl'): | |
|
56 | self._baseurl = cp.get('web', 'baseurl') | |
|
57 | if cp.has_section('paths'): | |
|
49 | self.motd = cp.get('web', 'motd') | |
|
50 | self.style = cp.get('web', 'style', 'paper') | |
|
51 | self.stripecount = cp.get('web', 'stripes') | |
|
52 | self._baseurl = cp.get('web', 'baseurl') | |
|
53 | if 'paths' in cp: | |
|
58 | 54 | paths = cleannames(cp.items('paths')) |
|
59 | 55 | for prefix, root in paths: |
|
60 | 56 | roothead, roottail = os.path.split(root) |
@@ -75,14 +71,13 b' class hgwebdir(object):' | |||
|
75 | 71 | if prefix: |
|
76 | 72 | name = prefix + '/' + name |
|
77 | 73 | self.repos.append((name, path)) |
|
78 |
|
|
|
79 | for prefix, root in cp.items('collections'): | |
|
80 | for path in util.walkrepos(root, followsym=True): | |
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
|
84 | name = name[len(prefix):] | |
|
85 | self.repos.append((name.lstrip(os.sep), repo)) | |
|
74 | for prefix, root in cp.items('collections'): | |
|
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)) | |
|
86 | 81 | self.repos.sort() |
|
87 | 82 | |
|
88 | 83 | def run(self): |
@@ -320,8 +315,7 b' class hgwebdir(object):' | |||
|
320 | 315 | style = config('web', 'style', '') |
|
321 | 316 | if 'style' in req.form: |
|
322 | 317 | style = req.form['style'][0] |
|
323 | if self.stripecount is None: | |
|
324 | self.stripecount = int(config('web', 'stripes', 1)) | |
|
318 | self.stripecount = int(self.stripecount or config('web', 'stripes', 1)) | |
|
325 | 319 | mapfile = templater.stylemap(style) |
|
326 | 320 | tmpl = templater.templater(mapfile, templatefilters.filters, |
|
327 | 321 | defaults={"header": header, |
General Comments 0
You need to be logged in to leave comments.
Login now