# HG changeset patch # User Patrick Mezard # Date 1261593108 -3600 # Node ID 900ccbd79ef701b9a4bb5c1bd004cf8dbe7f7aa6 # Parent ea7c392f2b08f5e4758ed0247c2d39f191b563ad 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. diff -r ea7c392f2b08 -r 900ccbd79ef7 mercurial/diffhelpers.c --- 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]; diff -r ea7c392f2b08 -r 900ccbd79ef7 tests/test-mq-eol --- 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