[PATCH 4 of 5] check-config: handle multiline config

timeless timeless at mozdev.org
Tue Dec 8 03:35:17 CST 2015


# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1449562906 0
#      Tue Dec 08 08:21:46 2015 +0000
# Node ID 9a475b110be4f22aade4b02019c70a31bcb4ef91
# Parent  7f2a4607333500cb5bb0d749ce6b1c9c161948bb
check-config: handle multiline config

diff --git a/contrib/check-config.py b/contrib/check-config.py
--- a/contrib/check-config.py
+++ b/contrib/check-config.py
@@ -13,14 +13,16 @@
 foundopts = {}
 documented = {}
 
-configre = (r"""ui\.config(|int|bool|list)\(['"](\S+)['"], ?"""
-            r"""['"](\S+)['"](,\s(?:default=)?(\S+?))?\)""")
+configre = (r"""ui\.config(|int|bool|list)\(['"](\S+)['"],\s*"""
+            r"""['"](\S+)['"](,\s+(?:default=)?(\S+?))?\)""")
+configpartialre = (r"""ui\.config""")
 
 def main(args):
     for f in args:
         sect = ''
         prevname = ''
         confsect = ''
+        carryover = ''
         for l in open(f):
 
             # check topic-like bits
@@ -67,7 +69,8 @@
                 documented[m.group(1)] = 1
 
             # look for code-like bits
-            m = re.search(configre, l)
+            line = carryover + l
+            m = re.search(configre, line, re.MULTILINE)
             if m:
                 ctype = m.group(1)
                 if not ctype:
@@ -83,6 +86,13 @@
                     print "conflict on %s: %r != %r" % (name, (ctype, default),
                                                         foundopts[name])
                 foundopts[name] = (ctype, default)
+                carryover = ''
+            else:
+                m = re.search(configpartialre, line)
+                if m:
+                    carryover = line
+                else:
+                    carryover = ''
 
     for name in sorted(foundopts):
         if name not in documented:


More information about the Mercurial-devel mailing list