##// 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 553 # line 6: """
554 554
555 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 573 while before_lines or after_lines:
557 574 before, after = None, None
558 575 before_tokens, after_tokens = None, None
@@ -605,6 +622,13 b' class DiffSet(object):'
605 622 modified.content = render_tokenstream(
606 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 632 lines.append(AttributeDict({
609 633 'original': original,
610 634 'modified': modified,
@@ -226,6 +226,14 b' DIFF_FIXTURES = ['
226 226 CHMOD_FILENODE: 'modified file chmod 100755 => 100644'}}),
227 227 ]),
228 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 237 'hg_diff_mod_file_and_rename.diff',
230 238 [('README.rst', 'M',
231 239 {'added': 3,
General Comments 0
You need to be logged in to leave comments. Login now