From 13d0efd6d786cc993a7f3266bdb3f897e3006d72 Mon Sep 17 00:00:00 2001 From: Nicolas Dumazet Date: Fri, 18 Feb 2011 12:20:34 +0900 Subject: [PATCH 1/2] use mercurial's ui.configbool API to retrieve booleans --- CONTRIBUTORS.txt | 1 + flake8/run.py | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index e57d3b0..b30a438 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -3,4 +3,5 @@ Project created by Tarek Ziadé. Contributors: - Tamás Gulácsi +- Nicolas Dumazet diff --git a/flake8/run.py b/flake8/run.py index 68682bd..222a800 100644 --- a/flake8/run.py +++ b/flake8/run.py @@ -70,11 +70,9 @@ def hg_hook(ui, repo, **kwargs): for file_ in _get_files(repo, **kwargs): warnings += check_file(file_) - strict = ui.config('flake8', 'strict') - if strict is None: - strict = True + strict = ui.configbool('flake8', 'strict', default=True) - if strict.lower() in ('1', 'true'): + if strict: return warnings return 0 From 06d30763b31ee67ef2786206c858b477d828bde9 Mon Sep 17 00:00:00 2001 From: Nicolas Dumazet Date: Fri, 18 Feb 2011 12:23:15 +0900 Subject: [PATCH 2/2] mercurial hook: skip duplicates If a push contains several commits affecting many times the same file, we only need to check once for the changed file. --- flake8/run.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flake8/run.py b/flake8/run.py index 222a800..983396e 100644 --- a/flake8/run.py +++ b/flake8/run.py @@ -55,8 +55,12 @@ def main(): def _get_files(repo, **kwargs): + seen = set() for rev in xrange(repo[kwargs['node']], len(repo)): for file_ in repo[rev].files(): + if file_ in seen: + continue + seen.add(file_) if not file_.endswith('.py'): continue if skip_file(file_):