Skip to content
Snippets Groups Projects
Commit 5519697b authored by Augie Fackler's avatar Augie Fackler
Browse files

contrib: fix up output in check-config.py to use strs to avoid b prefixes

Differential Revision: https://phab.mercurial-scm.org/D5059
parent 2f47703c
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,14 @@
config:\s(?P<config>\S+\.\S+)$
''', re.VERBOSE | re.MULTILINE)
if sys.version_info[0] > 2:
def mkstr(b):
if isinstance(b, str):
return b
return b.decode('utf8')
else:
mkstr = lambda x: x
def main(args):
for f in args:
sect = b''
......@@ -92,7 +100,7 @@
# look for ignore markers
m = ignorere.search(l)
if m:
if m.group('reason') == 'inconsistent':
if m.group('reason') == b'inconsistent':
allowinconsistent.add(m.group('config'))
else:
documented[m.group('config')] = 1
......@@ -106,9 +114,10 @@
ctype = 'str'
name = m.group('section') + b"." + m.group('option')
default = m.group('default')
if default in (None, 'False', 'None', '0', '[]', '""', "''"):
if default in (
None, b'False', b'None', b'0', b'[]', b'""', b"''"):
default = b''
if re.match(b'[a-z.]+$', default):
default = b'<variable>'
if (name in foundopts and (ctype, default) != foundopts[name]
and name not in allowinconsistent):
......@@ -110,12 +119,15 @@
default = b''
if re.match(b'[a-z.]+$', default):
default = b'<variable>'
if (name in foundopts and (ctype, default) != foundopts[name]
and name not in allowinconsistent):
print(l.rstrip())
print("conflict on %s: %r != %r" % (name, (ctype, default),
foundopts[name]))
print("at %s:%d:" % (f, linenum))
print(mkstr(l.rstrip()))
fctype, fdefault = foundopts[name]
print("conflict on %s: %r != %r" % (
mkstr(name),
(mkstr(ctype), mkstr(default)),
(mkstr(fctype), mkstr(fdefault))))
print("at %s:%d:" % (mkstr(f), linenum))
foundopts[name] = (ctype, default)
carryover = b''
else:
......@@ -132,4 +144,6 @@
name.startswith(b"debug.")):
ctype, default = foundopts[name]
if default:
if isinstance(default, bytes):
default = mkstr(default)
default = ' [%s]' % default
......@@ -135,5 +149,8 @@
default = ' [%s]' % default
print("undocumented: %s (%s)%s" % (name, ctype, default))
elif isinstance(default, bytes):
default = mkstr(default)
print("undocumented: %s (%s)%s" % (
mkstr(name), mkstr(ctype), default))
if __name__ == "__main__":
if len(sys.argv) > 1:
......
......@@ -59,6 +59,7 @@
test-changelog-exec.t
test-check-code.t
test-check-commit.t
test-check-config.py
test-check-execute.t
test-check-interfaces.py
test-check-module-imports.t
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment