patch: fix parsing patch files containing CRs not followed by LFs stable
authorWagner Bruna <wbruna@softwareexpress.com.br>
Mon, 04 Jul 2011 19:53:39 -0300
branchstable
changeset 14832 d60e4f227d75
parent 14831 0407b7613e99
child 14833 308e1b5acc87
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.
mercurial/patch.py
tests/test-patch.t
--- 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