comparison contrib/check-config.py @ 33570:e470f12d7d05

check-config: mention the file and line of the error I used this to more quickly track down a failing test-check-config.t issue in another repo. I thought it might be useful more generally, so I'm sending it out in case others think it's a worthwhile change.
author Ryan McElroy <rmcelroy@fb.com>
date Tue, 18 Jul 2017 06:27:36 -0700
parents 5d8942dbe49e
children 143d7b27b09c
comparison
equal deleted inserted replaced
33569:d341677d667d 33570:e470f12d7d05
46 for f in args: 46 for f in args:
47 sect = '' 47 sect = ''
48 prevname = '' 48 prevname = ''
49 confsect = '' 49 confsect = ''
50 carryover = '' 50 carryover = ''
51 linenum = 0
51 for l in open(f): 52 for l in open(f):
53 linenum += 1
52 54
53 # check topic-like bits 55 # check topic-like bits
54 m = re.match('\s*``(\S+)``', l) 56 m = re.match('\s*``(\S+)``', l)
55 if m: 57 if m:
56 prevname = m.group(1) 58 prevname = m.group(1)
108 default = '' 110 default = ''
109 if re.match('[a-z.]+$', default): 111 if re.match('[a-z.]+$', default):
110 default = '<variable>' 112 default = '<variable>'
111 if (name in foundopts and (ctype, default) != foundopts[name] 113 if (name in foundopts and (ctype, default) != foundopts[name]
112 and name not in allowinconsistent): 114 and name not in allowinconsistent):
113 print(l) 115 print(l.rstrip())
114 print("conflict on %s: %r != %r" % (name, (ctype, default), 116 print("conflict on %s: %r != %r" % (name, (ctype, default),
115 foundopts[name])) 117 foundopts[name]))
118 print("at %s:%d:" % (f, linenum))
116 foundopts[name] = (ctype, default) 119 foundopts[name] = (ctype, default)
117 carryover = '' 120 carryover = ''
118 else: 121 else:
119 m = re.search(configpartialre, line) 122 m = re.search(configpartialre, line)
120 if m: 123 if m: