annotate contrib/check-config.py @ 52073:569e074894fa

manifest: drop the CamelCase name for `manifest.memtreemanifestctx` See 61557734c0ae for the reasoning.
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 23 Oct 2024 16:45:12 -0400
parents ca7bde5dbafb
children
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
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
60 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
61 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
62
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
63
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
64 def main(args):
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
65 for f in args:
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
66 sect = b''
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
67 prevname = b''
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
68 confsect = b''
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
69 carryover = b''
33570
e470f12d7d05 check-config: mention the file and line of the error
Ryan McElroy <rmcelroy@fb.com>
parents: 33195
diff changeset
70 linenum = 0
35919
143d7b27b09c check-config: specify the mode 'rb' to open the file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33570
diff changeset
71 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
72 linenum += 1
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
73
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
74 # check topic-like bits
41541
595a67a301ee check-config: use raw strings for regular expressions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40259
diff changeset
75 m = re.match(br'\s*``(\S+)``', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
76 if m:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
77 prevname = m.group(1)
41541
595a67a301ee check-config: use raw strings for regular expressions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40259
diff changeset
78 if re.match(br'^\s*-+$', l):
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
79 sect = prevname
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
80 prevname = b''
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
81
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
82 if sect and prevname:
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
83 name = sect + b'.' + prevname
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
84 documented[name] = 1
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
85
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
86 # check docstring bits
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
87 m = re.match(br'^\s+\[(\S+)\]', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
88 if m:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
89 confsect = m.group(1)
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
90 continue
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
91 m = re.match(br'^\s+(?:#\s*)?(\S+) = ', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
92 if m:
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
93 name = confsect + b'.' + m.group(1)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
94 documented[name] = 1
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
95
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
96 # like the bugzilla extension
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
97 m = re.match(br'^\s*(\S+\.\S+)$', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
98 if m:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
99 documented[m.group(1)] = 1
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
100
27310
9c98fe1416c2 check-config: recognize convert style documentation
timeless <timeless@mozdev.org>
parents: 25849
diff changeset
101 # like convert
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
102 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
103 if m:
9c98fe1416c2 check-config: recognize convert style documentation
timeless <timeless@mozdev.org>
parents: 25849
diff changeset
104 documented[m.group(1)] = 1
9c98fe1416c2 check-config: recognize convert style documentation
timeless <timeless@mozdev.org>
parents: 25849
diff changeset
105
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
106 # 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
107 m = re.match(br'.*?``(\S+\.\S+)``', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
108 if m:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
109 documented[m.group(1)] = 1
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
110
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
111 # look for ignore markers
33195
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
112 m = ignorere.search(l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
113 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
114 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
115 allowinconsistent.add(m.group('config'))
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
116 else:
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
117 documented[m.group('config')] = 1
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
118
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
119 # look for code-like bits
27313
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
120 line = carryover + l
32849
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
121 m = configre.search(line) or configwithre.search(line)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
122 if m:
32848
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32847
diff changeset
123 ctype = m.group('ctype')
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
124 if not ctype:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
125 ctype = 'str'
39708
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35920
diff changeset
126 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
127 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
128 if default in (
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
129 None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
130 b'False',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
131 b'None',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
132 b'0',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
133 b'[]',
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 ):
39708
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35920
diff changeset
137 default = b''
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
138 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
139 default = b'<variable>'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
140 if (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
141 name in foundopts
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
142 and (ctype, default) != foundopts[name]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
143 and name not in allowinconsistent
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
144 ):
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
145 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
146 fctype, fdefault = foundopts[name]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
147 print(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
148 "conflict on %s: %r != %r"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
149 % (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
150 mkstr(name),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
151 (mkstr(ctype), mkstr(default)),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
152 (mkstr(fctype), mkstr(fdefault)),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
153 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
154 )
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
155 print("at %s:%d:" % (mkstr(f), linenum))
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
156 foundopts[name] = (ctype, default)
39708
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35920
diff changeset
157 carryover = b''
27313
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
158 else:
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
159 m = re.search(configpartialre, line)
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
160 if m:
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
161 carryover = line
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
162 else:
39708
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35920
diff changeset
163 carryover = b''
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
164
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
165 for name in sorted(foundopts):
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
166 if name not in documented:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
167 if not (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
168 name.startswith(b"devel.")
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
169 or name.startswith(b"experimental.")
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
170 or name.startswith(b"debug.")
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
171 ):
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
172 ctype, default = foundopts[name]
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
173 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
174 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
175 default = mkstr(default)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
176 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
177 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
178 default = mkstr(default)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
179 print(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
180 "undocumented: %s (%s)%s"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
181 % (mkstr(name), mkstr(ctype), default)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
182 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
183
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
184
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
185 if __name__ == "__main__":
27992
8f244b75cc5e tests: execute check-config.py without xargs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 27313
diff changeset
186 if len(sys.argv) > 1:
8f244b75cc5e tests: execute check-config.py without xargs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 27313
diff changeset
187 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
188 else:
8f244b75cc5e tests: execute check-config.py without xargs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 27313
diff changeset
189 sys.exit(main([l.rstrip() for l in sys.stdin]))