annotate contrib/check-config.py @ 48906:e453c69821f8

hgweb: remove Python 2 support code Differential Revision: https://phab.mercurial-scm.org/D12309
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 21 Feb 2022 10:47:08 -0700
parents 6000f5b25c9b
children 493034cc3265
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45830
c102b704edb5 global: use python3 in shebangs
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43076
diff changeset
1 #!/usr/bin/env python3
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
2 #
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
3 # check-config - a config flag documentation checker for Mercurial
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
4 #
46819
d4ba4d51f85f contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents: 45830
diff changeset
5 # Copyright 2015 Olivia Mackall <olivia@selenic.com>
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
6 #
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
7 # This software may be used and distributed according to the terms of the
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
8 # GNU General Public License version 2 or any later version.
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
9
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
10 import re
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
11 import sys
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
12
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
13 foundopts = {}
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
14 documented = {}
33195
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
15 allowinconsistent = set()
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
16
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
17 configre = re.compile(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
18 br'''
32847
e5a6a540ae63 check-config: use compiled regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28352
diff changeset
19 # Function call
32848
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32847
diff changeset
20 ui\.config(?P<ctype>|int|bool|list)\(
32847
e5a6a540ae63 check-config: use compiled regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28352
diff changeset
21 # First argument.
32848
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32847
diff changeset
22 ['"](?P<section>\S+)['"],\s*
32847
e5a6a540ae63 check-config: use compiled regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28352
diff changeset
23 # Second argument
32848
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32847
diff changeset
24 ['"](?P<option>\S+)['"](,\s+
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32847
diff changeset
25 (?:default=)?(?P<default>\S+?))?
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
26 \)''',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
27 re.VERBOSE | re.MULTILINE,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
28 )
32847
e5a6a540ae63 check-config: use compiled regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28352
diff changeset
29
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
30 configwithre = re.compile(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
31 br'''
32849
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
32 ui\.config(?P<ctype>with)\(
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
33 # First argument is callback function. This doesn't parse robustly
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
34 # if it is e.g. a function call.
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
35 [^,]+,\s*
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
36 ['"](?P<section>\S+)['"],\s*
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
37 ['"](?P<option>\S+)['"](,\s+
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
38 (?:default=)?(?P<default>\S+?))?
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
39 \)''',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
40 re.VERBOSE | re.MULTILINE,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
41 )
32849
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
42
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
43 configpartialre = br"""ui\.config"""
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
44
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
45 ignorere = re.compile(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
46 br'''
33195
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
47 \#\s(?P<reason>internal|experimental|deprecated|developer|inconsistent)\s
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
48 config:\s(?P<config>\S+\.\S+)$
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
49 ''',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
50 re.VERBOSE | re.MULTILINE,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
51 )
33195
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
52
40259
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
53 if sys.version_info[0] > 2:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
54
40259
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
55 def mkstr(b):
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
56 if isinstance(b, str):
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
57 return b
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
58 return b.decode('utf8')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
59
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
60
40259
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
61 else:
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
62 mkstr = lambda x: x
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
63
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
64
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
65 def main(args):
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
66 for f in args:
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
67 sect = b''
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
68 prevname = b''
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
69 confsect = b''
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
70 carryover = b''
33570
e470f12d7d05 check-config: mention the file and line of the error
Ryan McElroy <rmcelroy@fb.com>
parents: 33195
diff changeset
71 linenum = 0
35919
143d7b27b09c check-config: specify the mode 'rb' to open the file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33570
diff changeset
72 for l in open(f, 'rb'):
33570
e470f12d7d05 check-config: mention the file and line of the error
Ryan McElroy <rmcelroy@fb.com>
parents: 33195
diff changeset
73 linenum += 1
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
74
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
75 # check topic-like bits
41541
595a67a301ee check-config: use raw strings for regular expressions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40259
diff changeset
76 m = re.match(br'\s*``(\S+)``', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
77 if m:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
78 prevname = m.group(1)
41541
595a67a301ee check-config: use raw strings for regular expressions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40259
diff changeset
79 if re.match(br'^\s*-+$', l):
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
80 sect = prevname
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
81 prevname = b''
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
82
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
83 if sect and prevname:
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
84 name = sect + b'.' + prevname
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
85 documented[name] = 1
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
86
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
87 # check docstring bits
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
88 m = re.match(br'^\s+\[(\S+)\]', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
89 if m:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
90 confsect = m.group(1)
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
91 continue
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
92 m = re.match(br'^\s+(?:#\s*)?(\S+) = ', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
93 if m:
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
94 name = confsect + b'.' + m.group(1)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
95 documented[name] = 1
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
96
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
97 # like the bugzilla extension
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
98 m = re.match(br'^\s*(\S+\.\S+)$', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
99 if m:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
100 documented[m.group(1)] = 1
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
101
27310
9c98fe1416c2 check-config: recognize convert style documentation
timeless <timeless@mozdev.org>
parents: 25849
diff changeset
102 # like convert
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
103 m = re.match(br'^\s*:(\S+\.\S+):\s+', l)
27310
9c98fe1416c2 check-config: recognize convert style documentation
timeless <timeless@mozdev.org>
parents: 25849
diff changeset
104 if m:
9c98fe1416c2 check-config: recognize convert style documentation
timeless <timeless@mozdev.org>
parents: 25849
diff changeset
105 documented[m.group(1)] = 1
9c98fe1416c2 check-config: recognize convert style documentation
timeless <timeless@mozdev.org>
parents: 25849
diff changeset
106
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
107 # quoted in help or docstrings
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
108 m = re.match(br'.*?``(\S+\.\S+)``', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
109 if m:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
110 documented[m.group(1)] = 1
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
111
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
112 # look for ignore markers
33195
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
113 m = ignorere.search(l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
114 if m:
40259
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
115 if m.group('reason') == b'inconsistent':
33195
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
116 allowinconsistent.add(m.group('config'))
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
117 else:
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
118 documented[m.group('config')] = 1
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
119
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
120 # look for code-like bits
27313
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
121 line = carryover + l
32849
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
122 m = configre.search(line) or configwithre.search(line)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
123 if m:
32848
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32847
diff changeset
124 ctype = m.group('ctype')
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
125 if not ctype:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
126 ctype = 'str'
39708
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35920
diff changeset
127 name = m.group('section') + b"." + m.group('option')
32848
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32847
diff changeset
128 default = m.group('default')
40259
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
129 if default in (
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
130 None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
131 b'False',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
132 b'None',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
133 b'0',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
134 b'[]',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
135 b'""',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
136 b"''",
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
137 ):
39708
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35920
diff changeset
138 default = b''
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
139 if re.match(b'[a-z.]+$', default):
39708
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35920
diff changeset
140 default = b'<variable>'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
141 if (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
142 name in foundopts
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
143 and (ctype, default) != foundopts[name]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
144 and name not in allowinconsistent
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
145 ):
40259
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
146 print(mkstr(l.rstrip()))
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
147 fctype, fdefault = foundopts[name]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
148 print(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
149 "conflict on %s: %r != %r"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
150 % (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
151 mkstr(name),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
152 (mkstr(ctype), mkstr(default)),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
153 (mkstr(fctype), mkstr(fdefault)),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
154 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
155 )
40259
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
156 print("at %s:%d:" % (mkstr(f), linenum))
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
157 foundopts[name] = (ctype, default)
39708
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35920
diff changeset
158 carryover = b''
27313
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
159 else:
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
160 m = re.search(configpartialre, line)
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
161 if m:
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
162 carryover = line
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
163 else:
39708
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35920
diff changeset
164 carryover = b''
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
165
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
166 for name in sorted(foundopts):
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
167 if name not in documented:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
168 if not (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
169 name.startswith(b"devel.")
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
170 or name.startswith(b"experimental.")
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
171 or name.startswith(b"debug.")
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
172 ):
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
173 ctype, default = foundopts[name]
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
174 if default:
40259
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
175 if isinstance(default, bytes):
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
176 default = mkstr(default)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
177 default = ' [%s]' % default
40259
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
178 elif isinstance(default, bytes):
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39708
diff changeset
179 default = mkstr(default)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
180 print(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
181 "undocumented: %s (%s)%s"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
182 % (mkstr(name), mkstr(ctype), default)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
183 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
184
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
185
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
186 if __name__ == "__main__":
27992
8f244b75cc5e tests: execute check-config.py without xargs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 27313
diff changeset
187 if len(sys.argv) > 1:
8f244b75cc5e tests: execute check-config.py without xargs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 27313
diff changeset
188 sys.exit(main(sys.argv[1:]))
8f244b75cc5e tests: execute check-config.py without xargs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 27313
diff changeset
189 else:
8f244b75cc5e tests: execute check-config.py without xargs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 27313
diff changeset
190 sys.exit(main([l.rstrip() for l in sys.stdin]))