diff --git a/mercurial/diffhelpers.c b/mercurial/diffhelpers.c --- a/mercurial/diffhelpers.c +++ b/mercurial/diffhelpers.c @@ -22,6 +22,9 @@ static void _fix_newline(PyObject *hunk, 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]; diff --git a/tests/test-mq-eol b/tests/test-mq-eol --- a/tests/test-mq-eol +++ b/tests/test-mq-eol @@ -20,7 +20,7 @@ w(' c\r\n') 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