contrib/check-config.py
author Pulkit Goyal <7895pulkit@gmail.com>
Wed, 22 May 2019 02:59:48 +0530
changeset 42432 c767e655ffda
parent 41555 595a67a301ee
child 43076 2372284d9457
permissions -rwxr-xr-x
narrow: use narrow_widen wireproto command to widen in case of ellipses Few releases ago, we introduce narrow_widen wireproto command to be used to widen narrow repositories. Before this patch, that was used in non-ellipses cases only. In ellipses cases, we still do exchange.pull() which can pull more data than required. After this patch, the client will first check whether server supports doing ellipses widening using wireproto command or not by checking server's wireproto capability. If the server is upto date and support latest ellipses capability, we call the wireproto command. Otherwise we fallback to exchange.pull() like before. The compat code make sure that things works even if one of the client or server is old. The initial version of this patch does not had this compat code. It's added to help Google release things smoothly internally. I plan to drop the compat code before the upcoming major release. Due to change to wireproto command, the code looks a bit dirty, next patches will clean that up. Differential Revision: https://phab.mercurial-scm.org/D6436
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     1
#!/usr/bin/env python
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 = {}
33197
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32867
diff changeset
    16
allowinconsistent = set()
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    17
35960
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
diff changeset
    18
configre = re.compile(br'''
32865
e5a6a540ae63 check-config: use compiled regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28352
diff changeset
    19
    # Function call
32866
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32865
diff changeset
    20
    ui\.config(?P<ctype>|int|bool|list)\(
32865
e5a6a540ae63 check-config: use compiled regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28352
diff changeset
    21
        # First argument.
32866
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32865
diff changeset
    22
        ['"](?P<section>\S+)['"],\s*
32865
e5a6a540ae63 check-config: use compiled regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28352
diff changeset
    23
        # Second argument
32866
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32865
diff changeset
    24
        ['"](?P<option>\S+)['"](,\s+
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32865
diff changeset
    25
        (?:default=)?(?P<default>\S+?))?
32865
e5a6a540ae63 check-config: use compiled regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28352
diff changeset
    26
    \)''', re.VERBOSE | re.MULTILINE)
e5a6a540ae63 check-config: use compiled regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28352
diff changeset
    27
41555
595a67a301ee check-config: use raw strings for regular expressions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40259
diff changeset
    28
configwithre = re.compile(br'''
32867
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32866
diff changeset
    29
    ui\.config(?P<ctype>with)\(
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32866
diff changeset
    30
        # First argument is callback function. This doesn't parse robustly
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32866
diff changeset
    31
        # if it is e.g. a function call.
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32866
diff changeset
    32
        [^,]+,\s*
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32866
diff changeset
    33
        ['"](?P<section>\S+)['"],\s*
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32866
diff changeset
    34
        ['"](?P<option>\S+)['"](,\s+
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32866
diff changeset
    35
        (?:default=)?(?P<default>\S+?))?
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32866
diff changeset
    36
    \)''', re.VERBOSE | re.MULTILINE)
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32866
diff changeset
    37
35960
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
diff changeset
    38
configpartialre = (br"""ui\.config""")
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    39
35960
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
diff changeset
    40
ignorere = re.compile(br'''
33197
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32867
diff changeset
    41
    \#\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: 32867
diff changeset
    42
    config:\s(?P<config>\S+\.\S+)$
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32867
diff changeset
    43
    ''', re.VERBOSE | re.MULTILINE)
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32867
diff changeset
    44
40259
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39724
diff changeset
    45
if sys.version_info[0] > 2:
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39724
diff changeset
    46
    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: 39724
diff changeset
    47
        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: 39724
diff changeset
    48
            return b
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39724
diff changeset
    49
        return b.decode('utf8')
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39724
diff changeset
    50
else:
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39724
diff changeset
    51
    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: 39724
diff changeset
    52
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    53
def main(args):
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    54
    for f in args:
35960
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
diff changeset
    55
        sect = b''
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
diff changeset
    56
        prevname = b''
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
diff changeset
    57
        confsect = b''
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
diff changeset
    58
        carryover = b''
33570
e470f12d7d05 check-config: mention the file and line of the error
Ryan McElroy <rmcelroy@fb.com>
parents: 33197
diff changeset
    59
        linenum = 0
35959
143d7b27b09c check-config: specify the mode 'rb' to open the file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33570
diff changeset
    60
        for l in open(f, 'rb'):
33570
e470f12d7d05 check-config: mention the file and line of the error
Ryan McElroy <rmcelroy@fb.com>
parents: 33197
diff changeset
    61
            linenum += 1
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    62
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    63
            # check topic-like bits
41555
595a67a301ee check-config: use raw strings for regular expressions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40259
diff changeset
    64
            m = re.match(br'\s*``(\S+)``', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    65
            if m:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    66
                prevname = m.group(1)
41555
595a67a301ee check-config: use raw strings for regular expressions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40259
diff changeset
    67
            if re.match(br'^\s*-+$', l):
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    68
                sect = prevname
35960
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
diff changeset
    69
                prevname = b''
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    70
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    71
            if sect and prevname:
35960
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
diff changeset
    72
                name = sect + b'.' + prevname
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    73
                documented[name] = 1
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 docstring bits
35960
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
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
                confsect = m.group(1)
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    79
                continue
35960
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
diff changeset
    80
            m = re.match(br'^\s+(?:#\s*)?(\S+) = ', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    81
            if m:
35960
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
diff changeset
    82
                name = confsect + b'.' + m.group(1)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    83
                documented[name] = 1
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    84
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    85
            # like the bugzilla extension
35960
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
diff changeset
    86
            m = re.match(br'^\s*(\S+\.\S+)$', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    87
            if m:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    88
                documented[m.group(1)] = 1
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    89
27310
9c98fe1416c2 check-config: recognize convert style documentation
timeless <timeless@mozdev.org>
parents: 25849
diff changeset
    90
            # like convert
35960
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
diff changeset
    91
            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
    92
            if m:
9c98fe1416c2 check-config: recognize convert style documentation
timeless <timeless@mozdev.org>
parents: 25849
diff changeset
    93
                documented[m.group(1)] = 1
9c98fe1416c2 check-config: recognize convert style documentation
timeless <timeless@mozdev.org>
parents: 25849
diff changeset
    94
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    95
            # quoted in help or docstrings
35960
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
diff changeset
    96
            m = re.match(br'.*?``(\S+\.\S+)``', l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    97
            if m:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    98
                documented[m.group(1)] = 1
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    99
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   100
            # look for ignore markers
33197
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32867
diff changeset
   101
            m = ignorere.search(l)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   102
            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: 39724
diff changeset
   103
                if m.group('reason') == b'inconsistent':
33197
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32867
diff changeset
   104
                    allowinconsistent.add(m.group('config'))
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32867
diff changeset
   105
                else:
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32867
diff changeset
   106
                    documented[m.group('config')] = 1
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   107
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   108
            # look for code-like bits
27313
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
   109
            line = carryover + l
32867
e9fc5550be46 check-config: look for ui.configwith
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32866
diff changeset
   110
            m = configre.search(line) or configwithre.search(line)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   111
            if m:
32866
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32865
diff changeset
   112
                ctype = m.group('ctype')
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   113
                if not ctype:
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   114
                    ctype = 'str'
39724
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35960
diff changeset
   115
                name = m.group('section') + b"." + m.group('option')
32866
485b8e87e244 check-config: use named groups in regexp
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32865
diff changeset
   116
                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: 39724
diff changeset
   117
                if default in (
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39724
diff changeset
   118
                        None, b'False', b'None', b'0', b'[]', b'""', b"''"):
39724
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35960
diff changeset
   119
                    default = b''
35960
2912bed9b0c7 py3: add b'' to literals in check-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35959
diff changeset
   120
                if re.match(b'[a-z.]+$', default):
39724
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35960
diff changeset
   121
                    default = b'<variable>'
33197
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32867
diff changeset
   122
                if (name in foundopts and (ctype, default) != foundopts[name]
5d8942dbe49e check-config: syntax to allow inconsistent config values
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32867
diff changeset
   123
                    and name not in allowinconsistent):
40259
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39724
diff changeset
   124
                    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: 39724
diff changeset
   125
                    fctype, fdefault = foundopts[name]
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39724
diff changeset
   126
                    print("conflict on %s: %r != %r" % (
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39724
diff changeset
   127
                        mkstr(name),
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39724
diff changeset
   128
                        (mkstr(ctype), mkstr(default)),
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39724
diff changeset
   129
                        (mkstr(fctype), mkstr(fdefault))))
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39724
diff changeset
   130
                    print("at %s:%d:" % (mkstr(f), linenum))
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   131
                foundopts[name] = (ctype, default)
39724
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35960
diff changeset
   132
                carryover = b''
27313
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
   133
            else:
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
   134
                m = re.search(configpartialre, line)
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
   135
                if m:
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
   136
                    carryover = line
9d155accd8f1 check-config: handle multiline config
timeless <timeless@mozdev.org>
parents: 27312
diff changeset
   137
                else:
39724
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35960
diff changeset
   138
                    carryover = b''
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   139
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   140
    for name in sorted(foundopts):
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   141
        if name not in documented:
39724
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35960
diff changeset
   142
            if not (name.startswith(b"devel.") or
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35960
diff changeset
   143
                    name.startswith(b"experimental.") or
fe28267d5223 py3: byteify contrib/check-config.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 35960
diff changeset
   144
                    name.startswith(b"debug.")):
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   145
                ctype, default = foundopts[name]
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   146
                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: 39724
diff changeset
   147
                    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: 39724
diff changeset
   148
                        default = mkstr(default)
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   149
                    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: 39724
diff changeset
   150
                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: 39724
diff changeset
   151
                    default = mkstr(default)
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39724
diff changeset
   152
                print("undocumented: %s (%s)%s" % (
5519697b71b3 contrib: fix up output in check-config.py to use strs to avoid b prefixes
Augie Fackler <augie@google.com>
parents: 39724
diff changeset
   153
                    mkstr(name), mkstr(ctype), default))
25790
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   154
db5b6a1c064d check-config: add config option checker
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
   155
if __name__ == "__main__":
27992
8f244b75cc5e tests: execute check-config.py without xargs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 27313
diff changeset
   156
    if len(sys.argv) > 1:
8f244b75cc5e tests: execute check-config.py without xargs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 27313
diff changeset
   157
        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
   158
    else:
8f244b75cc5e tests: execute check-config.py without xargs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 27313
diff changeset
   159
        sys.exit(main([l.rstrip() for l in sys.stdin]))