Patchwork [1,of,4] check-code: rewrite py3 exclusion pattern with negative lookahead

login
register
mail settings
Submitter Yuya Nishihara
Date May 3, 2017, 1:50 a.m.
Message ID <92e0bf3b4a6615fb8f11.1493776221@mimosa>
Download mbox | patch
Permalink /patch/20385/
State Accepted
Headers show

Comments

Yuya Nishihara - May 3, 2017, 1:50 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1493626222 -32400
#      Mon May 01 17:10:22 2017 +0900
# Node ID 92e0bf3b4a6615fb8f119b487cb4bbc324228050
# Parent  9b1232b9e87d69465744d8b50a7c84fc2e60347a
check-code: rewrite py3 exclusion pattern with negative lookahead

I want to add more patterns, but negative lookbehind requires patterns of
the same length so not useful.

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -492,7 +492,7 @@  py3pats = [
 checks = [
     ('python', r'.*\.(py|cgi)$', r'^#!.*python', pyfilters, pypats),
     ('python', r'.*hgext.*\.py$', '', [], pyextnfpats),
-    ('python 3', r'.*(hgext|mercurial).*(?<!pycompat)\.py', '',
+    ('python 3', r'.*(hgext|mercurial)/(?!pycompat).*\.py', '',
             pyfilters, py3pats),
     ('test script', r'(.*/)?test-[^.~]*$', '', testfilters, testpats),
     ('c', r'.*\.[ch]$', '', cfilters, cpats),