fix test-mq-eol under --pure (mimic diffhelper.c behaviour) stable
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Fri, 26 Feb 2010 16:52:43 +0100
branchstable
changeset 10551 f61dced1367a
parent 10550 8036bc1871c2
child 10552 cc9f16a1f545
fix test-mq-eol under --pure (mimic diffhelper.c behaviour) bug discovered by apycot (apycot.hg-scm.org)
mercurial/pure/diffhelpers.py
--- a/mercurial/pure/diffhelpers.py	Wed Feb 24 19:43:13 2010 -0800
+++ b/mercurial/pure/diffhelpers.py	Fri Feb 26 16:52:43 2010 +0100
@@ -34,11 +34,15 @@
 
 def fix_newline(hunk, a, b):
     l = hunk[-1]
-    c = l[0]
-    hline = l[:-1]
+    # tolerate CRLF in last line
+    if l.endswith('\r\n'):
+        hline = l[:-2]
+    else:
+        hline = l[:-1]
+    c = hline[0]
 
     if c == " " or c == "+":
-        b[-1] = l[1:-1]
+        b[-1] = hline[1:]
     if c == " " or c == "-":
         a[-1] = hline
     hunk[-1] = hline