Show More
@@ -134,6 +134,7 b' class DiffProcessor(object):' | |||||
134 | can be used to render it in a HTML template. |
|
134 | can be used to render it in a HTML template. | |
135 | """ |
|
135 | """ | |
136 | _chunk_re = re.compile(r'@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)') |
|
136 | _chunk_re = re.compile(r'@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)') | |
|
137 | _newline_marker = '\\ No newline at end of file\n' | |||
137 |
|
138 | |||
138 | def __init__(self, diff, differ='diff', format='gitdiff'): |
|
139 | def __init__(self, diff, differ='diff', format='gitdiff'): | |
139 | """ |
|
140 | """ | |
@@ -345,11 +346,17 b' class DiffProcessor(object):' | |||||
345 | }) |
|
346 | }) | |
346 |
|
347 | |||
347 | line = lineiter.next() |
|
348 | line = lineiter.next() | |
|
349 | ||||
348 | while old_line < old_end or new_line < new_end: |
|
350 | while old_line < old_end or new_line < new_end: | |
349 | if line: |
|
351 | if line: | |
350 |
command |
|
352 | command = line[0] | |
|
353 | if command in ['+', '-', ' ']: | |||
|
354 | #only modify the line if it's actually a diff | |||
|
355 | # thing | |||
|
356 | line = line[1:] | |||
351 | else: |
|
357 | else: | |
352 | command = ' ' |
|
358 | command = ' ' | |
|
359 | ||||
353 | affects_old = affects_new = False |
|
360 | affects_old = affects_new = False | |
354 |
|
361 | |||
355 | # ignore those if we don't expect them |
|
362 | # ignore those if we don't expect them | |
@@ -367,15 +374,7 b' class DiffProcessor(object):' | |||||
367 | affects_old = affects_new = True |
|
374 | affects_old = affects_new = True | |
368 | action = 'unmod' |
|
375 | action = 'unmod' | |
369 |
|
376 | |||
370 |
if line |
|
377 | if line != self._newline_marker: | |
371 | lines.append({ |
|
|||
372 | 'old_lineno': '...', |
|
|||
373 | 'new_lineno': '...', |
|
|||
374 | 'action': 'context', |
|
|||
375 | 'line': line |
|
|||
376 | }) |
|
|||
377 |
|
||||
378 | else: |
|
|||
379 | old_line += affects_old |
|
378 | old_line += affects_old | |
380 | new_line += affects_new |
|
379 | new_line += affects_new | |
381 | lines.append({ |
|
380 | lines.append({ | |
@@ -386,6 +385,15 b' class DiffProcessor(object):' | |||||
386 | }) |
|
385 | }) | |
387 |
|
386 | |||
388 | line = lineiter.next() |
|
387 | line = lineiter.next() | |
|
388 | if line == self._newline_marker: | |||
|
389 | # we need to append to lines, since this is not | |||
|
390 | # counted in the line specs of diff | |||
|
391 | lines.append({ | |||
|
392 | 'old_lineno': '...', | |||
|
393 | 'new_lineno': '...', | |||
|
394 | 'action': 'context', | |||
|
395 | 'line': line | |||
|
396 | }) | |||
389 |
|
397 | |||
390 | except StopIteration: |
|
398 | except StopIteration: | |
391 | pass |
|
399 | pass |
General Comments 0
You need to be logged in to leave comments.
Login now