##// END OF EJS Templates
diffs: fixed problem with rendering no newline at the end of file markers....
marcink -
r2380:8531a2ca default
parent child Browse files
Show More
@@ -0,0 +1,10 b''
1 diff --git a/server.properties b/server.properties
2 --- a/server.properties
3 +++ b/server.properties
4 @@ -1,2 +1,3 @@
5 property=value
6 -anotherProperty=value
7 \ No newline at end of file
8 +anotherProperty=value
9 +newProperty=super_important_value
10 \ No newline at end of file No newline at end of file
@@ -553,6 +553,23 b' class DiffSet(object):'
553 # line 6: """
553 # line 6: """
554
554
555 lines = []
555 lines = []
556
557 before_newline = AttributeDict()
558 after_newline = AttributeDict()
559 if before_lines and before_lines[-1]['action'] == 'old-no-nl':
560 before_newline_line = before_lines.pop(-1)
561 before_newline.content = '\n {}'.format(
562 render_tokenstream(
563 [(x[0], '', x[1])
564 for x in [('nonl', before_newline_line['line'])]]))
565
566 if after_lines and after_lines[-1]['action'] == 'new-no-nl':
567 after_newline_line = after_lines.pop(-1)
568 after_newline.content = '\n {}'.format(
569 render_tokenstream(
570 [(x[0], '', x[1])
571 for x in [('nonl', after_newline_line['line'])]]))
572
556 while before_lines or after_lines:
573 while before_lines or after_lines:
557 before, after = None, None
574 before, after = None, None
558 before_tokens, after_tokens = None, None
575 before_tokens, after_tokens = None, None
@@ -605,6 +622,13 b' class DiffSet(object):'
605 modified.content = render_tokenstream(
622 modified.content = render_tokenstream(
606 [(x[0], '', x[1]) for x in after_tokens])
623 [(x[0], '', x[1]) for x in after_tokens])
607
624
625 if not before_lines and before_newline:
626 original.content += before_newline.content
627 before_newline = None
628 if not after_lines and after_newline:
629 modified.content += after_newline.content
630 after_newline = None
631
608 lines.append(AttributeDict({
632 lines.append(AttributeDict({
609 'original': original,
633 'original': original,
610 'modified': modified,
634 'modified': modified,
@@ -779,7 +779,7 b' class DiffProcessor(object):'
779 'action': action,
779 'action': action,
780 'line': self._clean_line(line, command)
780 'line': self._clean_line(line, command)
781 })
781 })
782 raw_diff.append(line)
782 raw_diff.append(line)
783
783
784 line = diff_iter.next()
784 line = diff_iter.next()
785
785
@@ -226,6 +226,14 b' DIFF_FIXTURES = ['
226 CHMOD_FILENODE: 'modified file chmod 100755 => 100644'}}),
226 CHMOD_FILENODE: 'modified file chmod 100755 => 100644'}}),
227 ]),
227 ]),
228 ('hg',
228 ('hg',
229 'hg_diff_no_newline.diff',
230 [('server.properties', 'M',
231 {'added': 2,
232 'deleted': 1,
233 'binary': False,
234 'ops': {MOD_FILENODE: 'modified file'}}),
235 ]),
236 ('hg',
229 'hg_diff_mod_file_and_rename.diff',
237 'hg_diff_mod_file_and_rename.diff',
230 [('README.rst', 'M',
238 [('README.rst', 'M',
231 {'added': 3,
239 {'added': 3,
General Comments 0
You need to be logged in to leave comments. Login now