From d42a9c7eba29bf54f4628839c18580d184f890b9 Mon Sep 17 00:00:00 2001 From: FUTATSUKI Yasuhito Date: Fri, 26 Nov 2021 04:46:23 +0900 Subject: [PATCH] RCSStream: Fix issue on inserting incomplete line on RCS diff * cvs2svn_lib/rcs_stream.py (generate_edits_from_blocks): Connect incomplete lines in old_lines and new_lines in command blocks. (RCSStream.generate_blocks): Add special case handling in 'a' command. --- cvs2svn_lib/rcs_stream.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cvs2svn_lib/rcs_stream.py b/cvs2svn_lib/rcs_stream.py index c045cf2da..db8fb8a0e 100644 --- a/cvs2svn_lib/rcs_stream.py +++ b/cvs2svn_lib/rcs_stream.py @@ -137,6 +137,8 @@ def generate_edits_from_blocks(blocks): input_position = 0 for (command, old_lines, new_lines) in blocks: + old_lines = msplit("".join(old_lines)) + new_lines = msplit("".join(new_lines)) if command == 'c': input_position += len(old_lines) elif command == 'r': @@ -252,7 +254,13 @@ def generate_blocks(self, edits): yield ('c', copied_lines, copied_lines) del copied_lines input_pos = start - yield ('r', [], lines) + if lines[-1].endswith('\n') or input_pos == len(self._lines): + yield ('r', [], lines) + else: + copied_line = self._lines[input_pos] + yield ('r', [copied_line], lines + [copied_line]) + del copied_line + input_pos = input_pos + 1 # Pass along the part of the input that follows all of the delta # blocks: