contrib/check-config.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Wed, 02 Dec 2020 10:51:40 +0100
changeset 46152 e166e8a035a7
parent 45830 c102b704edb5
child 46819 d4ba4d51f85f
permissions -rwxr-xr-x
copies-rust: use the entry API to overwrite deleted entry This is more efficient, more idiomatic and more compact. The main motivation for this change is to cleanup that area before start to do "overwrite" tracking. Such tracking will ultimately help to avoid costly is_ancestors call when merging changeset. Differential Revision: https://phab.mercurial-scm.org/D9494
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
#
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     5
# Copyright 2015 Matt Mackall <mpm@selenic.com>
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
28352
a92ee4d8a574 check-config: use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 27992
diff changeset
    10
from __future__ import absolute_import, print_function
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    11
import re
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    12
import sys
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    13
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    14
foundopts = {}
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    15
documented = {}
33195
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
    16
allowinconsistent = set()
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    17
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    18
configre = re.compile(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    19
    br'''
32847
e5a6a540ae63 check-config: use compiled regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28352
diff changeset
    20
    # Function call
32848
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32847
diff changeset
    21
    ui\.config(?P<ctype>|int|bool|list)\(
32847
e5a6a540ae63 check-config: use compiled regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28352
diff changeset
    22
        # First argument.
32848
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32847
diff changeset
    23
        ['"](?P<section>\S+)['"],\s*
32847
e5a6a540ae63 check-config: use compiled regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28352
diff changeset
    24
        # Second argument
32848
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32847
diff changeset
    25
        ['"](?P<option>\S+)['"](,\s+
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32847
diff changeset
    26
        (?:default=)?(?P<default>\S+?))?
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    27
    \)''',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    28
    re.VERBOSE | re.MULTILINE,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    29
)
32847
e5a6a540ae63 check-config: use compiled regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28352
diff changeset
    30
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    31
configwithre = re.compile(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    32
    br'''
32849
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
    33
    ui\.config(?P<ctype>with)\(
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
    34
        # 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
    35
        # 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
    36
        [^,]+,\s*
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
    37
        ['"](?P<section>\S+)['"],\s*
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
    38
        ['"](?P<option>\S+)['"](,\s+
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
    39
        (?:default=)?(?P<default>\S+?))?
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    40
    \)''',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    41
    re.VERBOSE | re.MULTILINE,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    42
)
32849
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
    43
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    44
configpartialre = br"""ui\.config"""
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    45
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    46
ignorere = re.compile(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    47
    br'''
33195
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
    48
    \#\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
    49
    config:\s(?P<config>\S+\.\S+)$
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    50
    ''',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    51
    re.VERBOSE | re.MULTILINE,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    52
)
33195
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
    53
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
    54
if sys.version_info[0] > 2:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    55
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
    56
    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
    57
        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
    58
            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
    59
        return b.decode('utf8')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    60
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    61
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
    62
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
    63
    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
    64
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
    65
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    66
def main(args):
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    67
    for f in args:
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
    68
        sect = b''
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
    69
        prevname = b''
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
    70
        confsect = b''
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
    71
        carryover = b''
33570
e470f12d7d05 check-config: mention the file and line of the error
Ryan McElroy <rmcelroy@fb.com>
parents: 33195
diff changeset
    72
        linenum = 0
35919
143d7b27b09c check-config: specify the mode 'rb' to open the file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33570
diff changeset
    73
        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
    74
            linenum += 1
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    75
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    76
            # check topic-like bits
41541
595a67a301ee check-config: use raw strings for regular expressions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40259
diff changeset
    77
            m = re.match(br'\s*``(\S+)``', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    78
            if m:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    79
                prevname = m.group(1)
41541
595a67a301ee check-config: use raw strings for regular expressions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40259
diff changeset
    80
            if re.match(br'^\s*-+$', l):
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    81
                sect = prevname
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
    82
                prevname = b''
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    83
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    84
            if sect and prevname:
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
    85
                name = sect + b'.' + prevname
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    86
                documented[name] = 1
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    87
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    88
            # check docstring bits
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
    89
            m = re.match(br'^\s+\[(\S+)\]', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    90
            if m:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    91
                confsect = m.group(1)
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    92
                continue
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
    93
            m = re.match(br'^\s+(?:#\s*)?(\S+) = ', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    94
            if m:
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
    95
                name = confsect + b'.' + m.group(1)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    96
                documented[name] = 1
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    97
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    98
            # like the bugzilla extension
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
    99
            m = re.match(br'^\s*(\S+\.\S+)$', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   100
            if m:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   101
                documented[m.group(1)] = 1
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   102
27310
9c98fe1416c2 check-config: recognize convert style documentation
timeless <timeless@mozdev.org>
parents: 25849
diff changeset
   103
            # like convert
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
   104
            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
   105
            if m:
9c98fe1416c2 check-config: recognize convert style documentation
timeless <timeless@mozdev.org>
parents: 25849
diff changeset
   106
                documented[m.group(1)] = 1
9c98fe1416c2 check-config: recognize convert style documentation
timeless <timeless@mozdev.org>
parents: 25849
diff changeset
   107
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   108
            # 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
   109
            m = re.match(br'.*?``(\S+\.\S+)``', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   110
            if m:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   111
                documented[m.group(1)] = 1
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   112
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   113
            # look for ignore markers
33195
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
   114
            m = ignorere.search(l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   115
            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
   116
                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
   117
                    allowinconsistent.add(m.group('config'))
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
   118
                else:
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32849
diff changeset
   119
                    documented[m.group('config')] = 1
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   120
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   121
            # look for code-like bits
27313
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
   122
            line = carryover + l
32849
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32848
diff changeset
   123
            m = configre.search(line) or configwithre.search(line)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   124
            if m:
32848
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32847
diff changeset
   125
                ctype = m.group('ctype')
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   126
                if not ctype:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   127
                    ctype = 'str'
39708
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35920
diff changeset
   128
                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
   129
                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
   130
                if default in (
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   131
                    None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   132
                    b'False',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   133
                    b'None',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   134
                    b'0',
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
                    b"''",
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   138
                ):
39708
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35920
diff changeset
   139
                    default = b''
35920
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35919
diff changeset
   140
                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
   141
                    default = b'<variable>'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   142
                if (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   143
                    name in foundopts
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   144
                    and (ctype, default) != foundopts[name]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   145
                    and name not in allowinconsistent
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   146
                ):
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
   147
                    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
   148
                    fctype, fdefault = foundopts[name]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   149
                    print(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   150
                        "conflict on %s: %r != %r"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   151
                        % (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   152
                            mkstr(name),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   153
                            (mkstr(ctype), mkstr(default)),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   154
                            (mkstr(fctype), mkstr(fdefault)),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   155
                        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   156
                    )
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
   157
                    print("at %s:%d:" % (mkstr(f), linenum))
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   158
                foundopts[name] = (ctype, default)
39708
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35920
diff changeset
   159
                carryover = b''
27313
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
   160
            else:
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
   161
                m = re.search(configpartialre, line)
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
   162
                if m:
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
   163
                    carryover = line
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
   164
                else:
39708
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35920
diff changeset
   165
                    carryover = b''
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   166
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   167
    for name in sorted(foundopts):
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   168
        if name not in documented:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   169
            if not (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   170
                name.startswith(b"devel.")
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   171
                or name.startswith(b"experimental.")
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   172
                or name.startswith(b"debug.")
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   173
            ):
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   174
                ctype, default = foundopts[name]
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   175
                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
   176
                    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
   177
                        default = mkstr(default)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   178
                    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
   179
                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
   180
                    default = mkstr(default)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   181
                print(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   182
                    "undocumented: %s (%s)%s"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   183
                    % (mkstr(name), mkstr(ctype), default)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   184
                )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41541
diff changeset
   185
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   186
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   187
if __name__ == "__main__":
27992
8f244b75cc5e tests: execute check-config.py without xargs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 27313
diff changeset
   188
    if len(sys.argv) > 1:
8f244b75cc5e tests: execute check-config.py without xargs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 27313
diff changeset
   189
        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
   190
    else:
8f244b75cc5e tests: execute check-config.py without xargs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 27313
diff changeset
   191
        sys.exit(main([l.rstrip() for l in sys.stdin]))