diff mercurial/base85.c @ 16522:a8065323c003 stable

patch: display a nice error for invalid base85 data Before, import was terminating with a traceback. Now it says: $ hg import --no-commit ../bad.patch applying ../bad.patch abort: could not decode binary patch: bad base85 character at position 66
author Patrick Mezard <patrick@mezard.eu>
date Sat, 21 Apr 2012 19:58:18 +0200
parents a4e0908ce35b
children 1b9d54c00d50
line wrap: on
line diff
--- a/mercurial/base85.c	Thu Apr 26 14:24:46 2012 +0200
+++ b/mercurial/base85.c	Sat Apr 21 19:58:18 2012 +0200
@@ -109,7 +109,7 @@
 			if (c < 0)
 				return PyErr_Format(
 					PyExc_ValueError,
-					"Bad base85 character at position %d", i);
+					"bad base85 character at position %d", i);
 			acc = acc * 85 + c;
 		}
 		if (i++ < len)
@@ -118,13 +118,13 @@
 			if (c < 0)
 				return PyErr_Format(
 					PyExc_ValueError,
-					"Bad base85 character at position %d", i);
+					"bad base85 character at position %d", i);
 			/* overflow detection: 0xffffffff == "|NsC0",
 			 * "|NsC" == 0x03030303 */
 			if (acc > 0x03030303 || (acc *= 85) > 0xffffffff - c)
 				return PyErr_Format(
 					PyExc_ValueError,
-					"Bad base85 sequence at position %d", i);
+					"bad base85 sequence at position %d", i);
 			acc += c;
 		}