diffhelpers: handle CRLF in hunk last line without EOL
Note that diff generation code always ends last lines without newline with a
LF, so this is a tolerance.
--- a/mercurial/diffhelpers.c Wed Dec 23 19:31:48 2009 +0100
+++ b/mercurial/diffhelpers.c Wed Dec 23 19:31:48 2009 +0100
@@ -22,6 +22,9 @@
PyObject *s = PyList_GET_ITEM(hunk, hunksz-1);
char *l = PyString_AS_STRING(s);
int sz = PyString_GET_SIZE(s);
+ if (sz > 1 && l[sz-2] == '\r')
+ /* tolerate CRLF in last line */
+ sz -= 1;
int alen = PyList_Size(a);
int blen = PyList_Size(b);
char c = l[0];
--- a/tests/test-mq-eol Wed Dec 23 19:31:48 2009 +0100
+++ b/tests/test-mq-eol Wed Dec 23 19:31:48 2009 +0100
@@ -20,7 +20,7 @@
w(' d\n')
w('-e\n')
w('\ No newline at end of file\n')
-w('+z\n')
+w('+z\r\n')
w('\ No newline at end of file\r\n')
EOF