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