Mercurial > hg
comparison contrib/check-config.py @ 27313:9d155accd8f1
check-config: handle multiline config
author | timeless <timeless@mozdev.org> |
---|---|
date | Tue, 08 Dec 2015 08:21:46 +0000 |
parents | f925d492113a |
children | 8f244b75cc5e |
comparison
equal
deleted
inserted
replaced
27312:f925d492113a | 27313:9d155accd8f1 |
---|---|
11 import sys | 11 import sys |
12 | 12 |
13 foundopts = {} | 13 foundopts = {} |
14 documented = {} | 14 documented = {} |
15 | 15 |
16 configre = (r"""ui\.config(|int|bool|list)\(['"](\S+)['"], ?""" | 16 configre = (r"""ui\.config(|int|bool|list)\(['"](\S+)['"],\s*""" |
17 r"""['"](\S+)['"](,\s(?:default=)?(\S+?))?\)""") | 17 r"""['"](\S+)['"](,\s+(?:default=)?(\S+?))?\)""") |
18 configpartialre = (r"""ui\.config""") | |
18 | 19 |
19 def main(args): | 20 def main(args): |
20 for f in args: | 21 for f in args: |
21 sect = '' | 22 sect = '' |
22 prevname = '' | 23 prevname = '' |
23 confsect = '' | 24 confsect = '' |
25 carryover = '' | |
24 for l in open(f): | 26 for l in open(f): |
25 | 27 |
26 # check topic-like bits | 28 # check topic-like bits |
27 m = re.match('\s*``(\S+)``', l) | 29 m = re.match('\s*``(\S+)``', l) |
28 if m: | 30 if m: |
65 ' config: (\S+\.\S+)$', l) | 67 ' config: (\S+\.\S+)$', l) |
66 if m: | 68 if m: |
67 documented[m.group(1)] = 1 | 69 documented[m.group(1)] = 1 |
68 | 70 |
69 # look for code-like bits | 71 # look for code-like bits |
70 m = re.search(configre, l) | 72 line = carryover + l |
73 m = re.search(configre, line, re.MULTILINE) | |
71 if m: | 74 if m: |
72 ctype = m.group(1) | 75 ctype = m.group(1) |
73 if not ctype: | 76 if not ctype: |
74 ctype = 'str' | 77 ctype = 'str' |
75 name = m.group(2) + "." + m.group(3) | 78 name = m.group(2) + "." + m.group(3) |
81 if name in foundopts and (ctype, default) != foundopts[name]: | 84 if name in foundopts and (ctype, default) != foundopts[name]: |
82 print l | 85 print l |
83 print "conflict on %s: %r != %r" % (name, (ctype, default), | 86 print "conflict on %s: %r != %r" % (name, (ctype, default), |
84 foundopts[name]) | 87 foundopts[name]) |
85 foundopts[name] = (ctype, default) | 88 foundopts[name] = (ctype, default) |
89 carryover = '' | |
90 else: | |
91 m = re.search(configpartialre, line) | |
92 if m: | |
93 carryover = line | |
94 else: | |
95 carryover = '' | |
86 | 96 |
87 for name in sorted(foundopts): | 97 for name in sorted(foundopts): |
88 if name not in documented: | 98 if name not in documented: |
89 if not (name.startswith("devel.") or | 99 if not (name.startswith("devel.") or |
90 name.startswith("experimental.") or | 100 name.startswith("experimental.") or |