5a30d0a6ca83

api: Accept empty line in diffs, fix issue57
[view raw] [browse files]
author Benoit Allard <benoit@aeteurope.nl>
date Wed, 28 Jul 2010 15:48:43 +0200
parents bf2c74655b2f
children 971a3a6e1df9
branches/tags (none)
files review/api.py review/web.py

Changes

--- a/review/api.py	Wed Jul 28 01:26:38 2010 -0400
+++ b/review/api.py	Wed Jul 28 15:48:43 2010 +0200
@@ -615,7 +615,7 @@
             for n, line in enumerate(d):
                 start = n - context if n > context else 0
                 end = n + context + 1
-                if any(filter(lambda l: l[0] in '+-', d[start:end])):
+                if any(filter(lambda l: l and l[0] in '+-', d[start:end])):
                     yield (n, line)
 
         for filename, content in ds.iteritems():
--- a/review/web.py	Wed Jul 28 01:26:38 2010 -0400
+++ b/review/web.py	Wed Jul 28 15:48:43 2010 +0200
@@ -48,7 +48,10 @@
     return 'http://www.gravatar.com/avatar/%s?s=%d' % (md5(email(cset.user())).hexdigest(), size)
 
 def _line_type(line):
-    return 'rem' if line[0] == '-' else 'add' if line[0] == '+' else 'con'
+    try:
+        return {'+': 'add', '-':'rem'}[line[0]]
+    except (IndexError, KeyError):
+        return 'con'
 
 def _categorize_signoffs(signoffs):
     return { 'yes': len(filter(lambda s: s.opinion == 'yes', signoffs)),