diff tests/test-import-eol @ 10127:d8214e944b84

patch: fix eolmode=auto with new files If target file does not exist or has no eol, current code was normalizing eols to LF. Preserve patch file eols instead.
author Patrick Mezard <pmezard@gmail.com>
date Wed, 23 Dec 2009 19:31:47 +0100
parents 1720d70cd6d4
children 7936cd261dc9
line wrap: on
line diff
--- a/tests/test-import-eol	Wed Dec 23 19:18:03 2009 +0100
+++ b/tests/test-import-eol	Wed Dec 23 19:31:47 2009 +0100
@@ -57,6 +57,21 @@
 python -c 'print repr(file("a","rb").read())'
 hg st
 
+echo % auto EOL on new file or source without any EOL
+python -c 'file("noeol", "wb").write("noeol")'
+hg add noeol
+hg commit -m 'add noeol'
+python -c 'file("noeol", "wb").write("noeol\r\nnoeol\n")'
+python -c 'file("neweol", "wb").write("neweol\nneweol\r\n")'
+hg add neweol
+hg diff --git > noeol.diff
+hg revert --no-backup noeol neweol
+rm neweol
+hg --traceback --config patch.eol='auto' import -m noeol noeol.diff
+python -c 'print repr(file("noeol","rb").read())'
+python -c 'print repr(file("neweol","rb").read())'
+hg st
+
 # Test --eol and binary patches
 python -c 'file("b", "wb").write("a\x00\nb")'
 hg ci -Am addb