[PATCH 2 of 7] check-code: put grouping around regexps generated from testpats
Mads Kiilerich
mads at kiilerich.com
Sun Apr 22 19:18:54 CDT 2012
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1335139008 -7200
# Branch stable
# Node ID 60c726966c8b9eea9c5f24570b819395c121d86b
# Parent 7b311bdc9614bb4f9e2715ca41d328978ad5618b
check-code: put grouping around regexps generated from testpats
This removes the pitfall that would make the testpath r'a|b' match 'b' on all
lines in .t tests.
diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -43,7 +43,7 @@
testpats = [
[
- (r'(pushd|popd)', "don't use 'pushd' or 'popd', use 'cd'"),
+ (r'pushd|popd', "don't use 'pushd' or 'popd', use 'cd'"),
(r'\W\$?\(\([^\)\n]*\)\)', "don't use (()) or $(()), use 'expr'"),
(r'^function', "don't use 'function', use old style"),
(r'grep.*-q', "don't use 'grep -q', redirect to /dev/null"),
@@ -108,9 +108,9 @@
for i in [0, 1]:
for p, m in testpats[i]:
if p.startswith(r'^'):
- p = uprefix + p[1:]
+ p = r"^ \$ (%s)" % p[1:]
else:
- p = uprefix + ".*" + p
+ p = r"^ \$ .*(%s)" % p
utestpats[i].append((p, m))
utestfilters = [
More information about the Mercurial-devel
mailing list