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.
--- 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)
--- 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
--- 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