# HG changeset patch # User Colin Caughie # Date 1245165762 -3600 # Node ID 6c9dce20ed70069f2669c47c3e6d82b6248dc1f3 # Parent a7c4eb0cc0ede2880e3c1065bb698f7db1e649b9 Fixed patch.eol bug that truncated all patched lines to one character Also updated the import-eol test to test with lines longer than one character, and also empty lines. diff -r a7c4eb0cc0ed -r 6c9dce20ed70 mercurial/patch.py --- a/mercurial/patch.py Mon Jun 15 02:51:10 2009 -0500 +++ b/mercurial/patch.py Tue Jun 16 16:22:42 2009 +0100 @@ -299,7 +299,7 @@ if self.eol and self.eol != '\n': for l in lines: if l and l[-1] == '\n': - l = l[:1] + self.eol + l = l[:-1] + self.eol fp.write(l) else: fp.writelines(lines) diff -r a7c4eb0cc0ed -r 6c9dce20ed70 tests/test-import-eol --- a/tests/test-import-eol Mon Jun 15 02:51:10 2009 -0500 +++ b/tests/test-import-eol Tue Jun 16 16:22:42 2009 +0100 @@ -9,9 +9,10 @@ w('+++ b/a\n') w('@@ -1,5 +1,5 @@\n') w(' a\n') -w('-b\r\n') -w('+y\r\n') -w(' c\r\n') +w('-bbb\r\n') +w('+yyyy\r\n') +w(' cc\r\n') +w(' \n') w(' d\n') w('-e\n') w('\ No newline at end of file\n') @@ -24,7 +25,7 @@ echo '\.diff' > .hgignore # Test different --eol values -python -c 'file("a", "wb").write("a\nb\nc\nd\ne")' +python -c 'file("a", "wb").write("a\nbbb\ncc\n\nd\ne")' hg ci -Am adda python ../makepatch.py echo % invalid eol diff -r a7c4eb0cc0ed -r 6c9dce20ed70 tests/test-import-eol.out --- a/tests/test-import-eol.out Mon Jun 15 02:51:10 2009 -0500 +++ b/tests/test-import-eol.out Tue Jun 16 16:22:42 2009 +0100 @@ -5,11 +5,11 @@ abort: Unsupported line endings type: LFCR % force LF applying eol.diff -'a\ny\nc\nd\nz' +'a\nyyyy\ncc\n\nd\ne' % force CRLF 1 files updated, 0 files merged, 0 files removed, 0 files unresolved applying eol.diff -'a\r\ny\r\nc\r\nd\r\nz' +'a\r\nyyyy\r\ncc\r\n\r\nd\r\ne' adding b % binary patch with --eol applying bin.diff