[PATCH 1 of 5] check-code: only fix patterns once
Simon Heimberg
simohe at besonet.ch
Sat Jun 8 13:56:59 CDT 2013
# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1370715614 -7200
# Node ID e32bdfb08c8ff96f9f50bfb60888c187830e3ac6
# Parent 872f284aa54a17e62391de184cd5b1b586277101
check-code: only fix patterns once
The patterns were fixed once for every file. Now only do it once when loading
the file.
diff -r 872f284aa54a -r e32bdfb08c8f contrib/check-code.py
--- a/contrib/check-code.py Mit Jun 05 22:41:53 2013 +0200
+++ b/contrib/check-code.py Sam Jun 08 20:20:14 2013 +0200
@@ -317,6 +317,22 @@
('txt', r'.*\.txt$', txtfilters, txtpats),
]
+def _preparepats():
+ for c in checks:
+ failandwarn = c[-1]
+ for pats in failandwarn:
+ for i, pseq in enumerate(pats):
+ # fix-up regexes for multi-line searches
+ po = p = pseq[0]
+ # \s doesn't match \n
+ p = re.sub(r'(?<!\\)\\s', r'[ \\t]', p)
+ # [^...] doesn't match newline
+ p = re.sub(r'(?<!\\)\[\^', r'[^\\n', p)
+
+ #print po, '=>', p
+ pats[i] = (p,) + pseq[1:]
+_preparepats()
+
class norepeatlogger(object):
def __init__(self):
self._lastseen = None
@@ -403,15 +419,6 @@
p, msg = pat
ignore = None
- # fix-up regexes for multi-line searches
- po = p
- # \s doesn't match \n
- p = re.sub(r'(?<!\\)\\s', r'[ \\t]', p)
- # [^...] doesn't match newline
- p = re.sub(r'(?<!\\)\[\^', r'[^\\n', p)
-
- #print po, '=>', p
-
pos = 0
n = 0
for m in re.finditer(p, post, re.MULTILINE):
More information about the Mercurial-devel
mailing list