patch: fix parsing patch files containing CRs not followed by LFs
Since
1e64e1e12195 , patch lines containing a CR not followed by a LF
would be incorrectly splitten, causing a failure to apply the patch.
--- a/mercurial/patch.py Tue Jul 05 11:53:32 2011 +0100
+++ b/mercurial/patch.py Mon Jul 04 19:53:39 2011 -0300
@@ -593,7 +593,7 @@
self.exists = backend.exists(self.fname)
self.missing = False
if data:
- self.lines = data.splitlines(True)
+ self.lines = mdiff.splitnewlines(data)
if self.mode is None:
self.mode = mode
if self.lines:
--- a/tests/test-patch.t Tue Jul 05 11:53:32 2011 +0100
+++ b/tests/test-patch.t Mon Jul 04 19:53:39 2011 -0300
@@ -46,9 +46,9 @@
$ rm $HGRCPATH
$ hg init c
$ cd c
- $ echo 0 > a
+ $ printf "a\rc" > a
$ hg ci -A -m 0 a -d '0 0'
- $ echo 1 >> a
+ $ printf "a\rb\rc" > a
$ cat << eof > log
> first line which can't start with '# '
> # second line is a comment but that shouldn't be a problem.
@@ -73,7 +73,7 @@
$ hg import ../c/p
applying ../c/p
$ hg log -v -r 1
- changeset: 1:e8cc66fbbaa6
+ changeset: 1:cd0bde79c428
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000