Show More
@@ -493,9 +493,9 b' class DiffSet(object):' | |||||
493 | after.append(line) |
|
493 | after.append(line) | |
494 | elif line['action'] == 'del': |
|
494 | elif line['action'] == 'del': | |
495 | before.append(line) |
|
495 | before.append(line) | |
496 |
elif line['action'] == ' |
|
496 | elif line['action'] == 'old-no-nl': | |
497 | before.append(line) |
|
497 | before.append(line) | |
498 |
elif line['action'] == ' |
|
498 | elif line['action'] == 'new-no-nl': | |
499 | after.append(line) |
|
499 | after.append(line) | |
500 |
|
500 | |||
501 | result.lines.extend( |
|
501 | result.lines.extend( | |
@@ -527,25 +527,31 b' class DiffSet(object):' | |||||
527 | modified = AttributeDict() |
|
527 | modified = AttributeDict() | |
528 |
|
528 | |||
529 | if before: |
|
529 | if before: | |
530 | before_tokens = self.get_line_tokens( |
|
530 | if before['action'] == 'old-no-nl': | |
531 | line_text=before['line'], line_number=before['old_lineno'], |
|
531 | before_tokens = [('nonl', before['line'])] | |
532 |
|
|
532 | else: | |
|
533 | before_tokens = self.get_line_tokens( | |||
|
534 | line_text=before['line'], line_number=before['old_lineno'], | |||
|
535 | file=source_file) | |||
533 | original.lineno = before['old_lineno'] |
|
536 | original.lineno = before['old_lineno'] | |
534 | original.content = before['line'] |
|
537 | original.content = before['line'] | |
535 | original.action = self.action_to_op(before['action']) |
|
538 | original.action = self.action_to_op(before['action']) | |
536 |
|
539 | |||
537 | if after: |
|
540 | if after: | |
538 |
|
|
541 | if after['action'] == 'new-no-nl': | |
539 | line_text=after['line'], line_number=after['new_lineno'], |
|
542 | after_tokens = [('nonl', after['line'])] | |
540 |
|
|
543 | else: | |
|
544 | after_tokens = self.get_line_tokens( | |||
|
545 | line_text=after['line'], line_number=after['new_lineno'], | |||
|
546 | file=target_file) | |||
541 | modified.lineno = after['new_lineno'] |
|
547 | modified.lineno = after['new_lineno'] | |
542 | modified.content = after['line'] |
|
548 | modified.content = after['line'] | |
543 | modified.action = self.action_to_op(after['action']) |
|
549 | modified.action = self.action_to_op(after['action']) | |
544 |
|
550 | |||
545 |
|
||||
546 | # diff the lines |
|
551 | # diff the lines | |
547 | if before_tokens and after_tokens: |
|
552 | if before_tokens and after_tokens: | |
548 |
o_tokens, m_tokens, similarity = tokens_diff( |
|
553 | o_tokens, m_tokens, similarity = tokens_diff( | |
|
554 | before_tokens, after_tokens) | |||
549 | original.content = render_tokenstream(o_tokens) |
|
555 | original.content = render_tokenstream(o_tokens) | |
550 | modified.content = render_tokenstream(m_tokens) |
|
556 | modified.content = render_tokenstream(m_tokens) | |
551 | elif before_tokens: |
|
557 | elif before_tokens: | |
@@ -594,8 +600,8 b' class DiffSet(object):' | |||||
594 | 'add': '+', |
|
600 | 'add': '+', | |
595 | 'del': '-', |
|
601 | 'del': '-', | |
596 | 'unmod': ' ', |
|
602 | 'unmod': ' ', | |
597 |
' |
|
603 | 'old-no-nl': ' ', | |
598 |
' |
|
604 | 'new-no-nl': ' ', | |
599 | }.get(action, action) |
|
605 | }.get(action, action) | |
600 |
|
606 | |||
601 | def as_unified(self, lines): |
|
607 | def as_unified(self, lines): |
@@ -180,8 +180,8 b' class Action(object):' | |||||
180 | UNMODIFIED = 'unmod' |
|
180 | UNMODIFIED = 'unmod' | |
181 |
|
181 | |||
182 | CONTEXT = 'context' |
|
182 | CONTEXT = 'context' | |
183 | CONTEXT_OLD = 'context-old' |
|
183 | OLD_NO_NL = 'old-no-nl' | |
184 | CONTEXT_NEW = 'context-new' |
|
184 | NEW_NO_NL = 'new-no-nl' | |
185 |
|
185 | |||
186 |
|
186 | |||
187 | class DiffProcessor(object): |
|
187 | class DiffProcessor(object): | |
@@ -846,9 +846,9 b' class DiffProcessor(object):' | |||||
846 | # we need to append to lines, since this is not |
|
846 | # we need to append to lines, since this is not | |
847 | # counted in the line specs of diff |
|
847 | # counted in the line specs of diff | |
848 | if affects_old: |
|
848 | if affects_old: | |
849 |
action = Action. |
|
849 | action = Action.OLD_NO_NL | |
850 | elif affects_new: |
|
850 | elif affects_new: | |
851 |
action = Action. |
|
851 | action = Action.NEW_NO_NL | |
852 | else: |
|
852 | else: | |
853 | raise Exception('invalid context for no newline') |
|
853 | raise Exception('invalid context for no newline') | |
854 |
|
854 |
General Comments 0
You need to be logged in to leave comments.
Login now