##// END OF EJS Templates
check-config: syntax to allow inconsistent config values...
Gregory Szorc -
r33192:5d8942db default
parent child Browse files
Show More
@@ -13,6 +13,7 b' import sys'
13
13
14 foundopts = {}
14 foundopts = {}
15 documented = {}
15 documented = {}
16 allowinconsistent = set()
16
17
17 configre = re.compile(r'''
18 configre = re.compile(r'''
18 # Function call
19 # Function call
@@ -36,6 +37,11 b" configwithre = re.compile('''"
36
37
37 configpartialre = (r"""ui\.config""")
38 configpartialre = (r"""ui\.config""")
38
39
40 ignorere = re.compile(r'''
41 \#\s(?P<reason>internal|experimental|deprecated|developer|inconsistent)\s
42 config:\s(?P<config>\S+\.\S+)$
43 ''', re.VERBOSE | re.MULTILINE)
44
39 def main(args):
45 def main(args):
40 for f in args:
46 for f in args:
41 sect = ''
47 sect = ''
@@ -82,10 +88,12 b' def main(args):'
82 documented[m.group(1)] = 1
88 documented[m.group(1)] = 1
83
89
84 # look for ignore markers
90 # look for ignore markers
85 m = re.search(r'# (?:internal|experimental|deprecated|developer)'
91 m = ignorere.search(l)
86 ' config: (\S+\.\S+)$', l)
87 if m:
92 if m:
88 documented[m.group(1)] = 1
93 if m.group('reason') == 'inconsistent':
94 allowinconsistent.add(m.group('config'))
95 else:
96 documented[m.group('config')] = 1
89
97
90 # look for code-like bits
98 # look for code-like bits
91 line = carryover + l
99 line = carryover + l
@@ -100,7 +108,8 b' def main(args):'
100 default = ''
108 default = ''
101 if re.match('[a-z.]+$', default):
109 if re.match('[a-z.]+$', default):
102 default = '<variable>'
110 default = '<variable>'
103 if name in foundopts and (ctype, default) != foundopts[name]:
111 if (name in foundopts and (ctype, default) != foundopts[name]
112 and name not in allowinconsistent):
104 print(l)
113 print(l)
105 print("conflict on %s: %r != %r" % (name, (ctype, default),
114 print("conflict on %s: %r != %r" % (name, (ctype, default),
106 foundopts[name]))
115 foundopts[name]))
@@ -141,6 +141,7 b' def statprofile(ui, fp):'
141 showmax = ui.configwith(fraction, 'profiling', 'showmax', 0.999)
141 showmax = ui.configwith(fraction, 'profiling', 'showmax', 0.999)
142 kwargs.update(minthreshold=showmin, maxthreshold=showmax)
142 kwargs.update(minthreshold=showmin, maxthreshold=showmax)
143 elif profformat == 'hotpath':
143 elif profformat == 'hotpath':
144 # inconsistent config: profiling.showmin
144 limit = ui.configwith(fraction, 'profiling', 'showmin', 0.05)
145 limit = ui.configwith(fraction, 'profiling', 'showmin', 0.05)
145 kwargs['limit'] = limit
146 kwargs['limit'] = limit
146
147
@@ -14,6 +14,13 b' Sanity check check-config.py'
14 > # Missing with default value
14 > # Missing with default value
15 > foo = ui.configbool('ui', 'missingbool1', default=True)
15 > foo = ui.configbool('ui', 'missingbool1', default=True)
16 > foo = ui.configbool('ui', 'missingbool2', False)
16 > foo = ui.configbool('ui', 'missingbool2', False)
17 > # Inconsistent values for defaults.
18 > foo = ui.configint('ui', 'intdefault', default=1)
19 > foo = ui.configint('ui', 'intdefault', default=42)
20 > # Can suppress inconsistent value error
21 > foo = ui.configint('ui', 'intdefault2', default=1)
22 > # inconsistent config: ui.intdefault2
23 > foo = ui.configint('ui', 'intdefault2', default=42)
17 > EOF
24 > EOF
18
25
19 $ cat > files << EOF
26 $ cat > files << EOF
@@ -24,7 +31,12 b' Sanity check check-config.py'
24 $ cd "$TESTDIR"/..
31 $ cd "$TESTDIR"/..
25
32
26 $ $PYTHON contrib/check-config.py < $TESTTMP/files
33 $ $PYTHON contrib/check-config.py < $TESTTMP/files
34 foo = ui.configint('ui', 'intdefault', default=42)
35
36 conflict on ui.intdefault: ('int', '42') != ('int', '1')
27 undocumented: ui.doesnotexist (str)
37 undocumented: ui.doesnotexist (str)
38 undocumented: ui.intdefault (int) [42]
39 undocumented: ui.intdefault2 (int) [42]
28 undocumented: ui.missingbool1 (bool) [True]
40 undocumented: ui.missingbool1 (bool) [True]
29 undocumented: ui.missingbool2 (bool)
41 undocumented: ui.missingbool2 (bool)
30 undocumented: ui.missingint (int)
42 undocumented: ui.missingint (int)
@@ -33,6 +45,3 b' New errors are not allowed. Warnings are'
33
45
34 $ syshg files "set:(**.py or **.txt) - tests/**" | sed 's|\\|/|g' |
46 $ syshg files "set:(**.py or **.txt) - tests/**" | sed 's|\\|/|g' |
35 > $PYTHON contrib/check-config.py
47 > $PYTHON contrib/check-config.py
36 limit = ui.configwith(fraction, 'profiling', 'showmin', 0.05)
37
38 conflict on profiling.showmin: ('with', '0.05') != ('with', '0.005')
General Comments 0
You need to be logged in to leave comments. Login now