# HG changeset patch # User Steve Losh # Date 1279664873 14400 # Node ID a9a6bf62224c3935e94a326e659bb5722b979f44 # Parent 79f123993c818e1a43cc6c27e32d29e40f0f4ec9 api: handle diffs with no content (adds, removes, etc) diff -r 79f123993c81 -r a9a6bf62224c review/api.py --- a/review/api.py Tue Jul 20 18:27:47 2010 -0400 +++ b/review/api.py Tue Jul 20 18:27:53 2010 -0400 @@ -539,7 +539,11 @@ # the second is the diff's contents, which is what we want, # minus the header - diffs[filename] = '\n'.join(d.next().splitlines()[3:]) + try: + diffs[filename] = '\n'.join(d.next().splitlines()[3:]) + except StopIteration: + # This is an add, remove, or something else without a diff body. + diffs[filename] = None return diffs @@ -588,11 +592,14 @@ yield (n, line) for filename, content in ds.iteritems(): - content = content.splitlines() - ds[filename] = { - 'max': len(content) - 1, - 'content': list(_filter_diff(content)), - } + if content: + content = content.splitlines() + ds[filename] = { + 'max': len(content) - 1, + 'content': list(_filter_diff(content)), + } + else: + ds[filename] = {'max': None, 'content': []} return ds