[PATCH 5 of 7] contrib: change return value of file checking function of check-code.py
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Thu Feb 28 13:16:15 EST 2019
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1551376389 -32400
# Fri Mar 01 02:53:09 2019 +0900
# Node ID 1b4340efc1c6e777f1a6fa9d1fe05e3ff7d07c05
# Parent 317e158d9224ef339c5a39a36cc29001e88aca2b
# Available At https://bitbucket.org/foozy/mercurial-wip
# hg pull https://bitbucket.org/foozy/mercurial-wip -r 1b4340efc1c6
# EXP-Topic tests-check-embedded-code
contrib: change return value of file checking function of check-code.py
This is a part of preparation to apply checking with check-code.py on
code fragments embedded in *.t test scripts.
After this patch, caller of _checkfiledata() can count number of
errors in each code fragments of an actual file.
This will be useful to share --per-file limitation by all embedded
code fragments.
diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -669,8 +669,9 @@ def checkfile(f, logfunc=_defaultlogger.
print("Skipping %s it has no-che?k-code (glob)" % f)
return "Skip" # skip checking this file
- if not _checkfiledata(name, f, pre, filters, pats, context,
- logfunc, maxerr, warnings, blame, debug, lineno):
+ fc = _checkfiledata(name, f, pre, filters, pats, context,
+ logfunc, maxerr, warnings, blame, debug, lineno)
+ if fc:
result = False
return result
@@ -695,13 +696,12 @@ def _checkfiledata(name, f, filedata, fi
:debug: whether debug information should be displayed
:lineno: whether lineno should be displayed at error reporting
- return True if no error is found, False otherwise.
+ returns number of detected errors.
"""
blamecache = context['blamecache']
fc = 0
pre = post = filedata
- result = True
if True: # TODO: get rid of this redundant 'if' block
for p, r in filters:
@@ -760,7 +760,6 @@ def _checkfiledata(name, f, filedata, fi
bd = '%s@%s' % (bu, br)
errors.append((f, lineno and n + 1, l, msg, bd))
- result = False
errors.sort()
for e in errors:
@@ -770,7 +769,7 @@ def _checkfiledata(name, f, filedata, fi
print(" (too many errors, giving up)")
break
- return result
+ return fc
def main():
parser = optparse.OptionParser("%prog [options] [files | -]")
More information about the Mercurial-devel
mailing list