Don't critique deleted files
authorGregory Szorc <gps@mozilla.com>
Wed, 13 Nov 2013 15:52:30 -0800
changeset 83 35f92fa51b96
parent 82 e6ff03aa4f5f
child 84 2948a807c49c
push id60
push usergszorc@mozilla.com
push date2013-11-13 23:52 +0000
Don't critique deleted files
__init__.py
--- a/__init__.py
+++ b/__init__.py
@@ -392,28 +392,31 @@ def critique(ui, repo, entire=False, nod
         for p in ('flake8', 'mccabe', 'pep8', 'pyflakes'):
             sys.path.insert(0, os.path.join(our_dir, p))
 
     from flake8.engine import get_style_guide
     from pep8 import DiffReport, parse_udiff
 
     style = get_style_guide(parse_argv=False, ignore='E128')
 
+    ctx = repo[node]
+
     if not entire:
-        diff = ''.join(repo[node].diff())
+        diff = ''.join(ctx.diff())
         style.options.selected_lines = {}
         for k, v in parse_udiff(diff).items():
             if k.startswith('./'):
                 k = k[2:]
 
             style.options.selected_lines[k] = v
 
         style.options.report = DiffReport(style.options)
 
-    files = [f for f in repo[node].files() if f.endswith('.py')]
+    deleted = repo.status(ctx.p1().node(), ctx.node())[2]
+    files = [f for f in ctx.files() if f.endswith('.py') and f not in deleted]
     style.check_files(files)
 
     demandimport.enable()
 
 
 @command('moztrees', [], _('hg moztrees'))
 def moztrees(ui, **opts):
     """Show information about Mozilla source trees."""