pathencode: skip encoding if input is already longer than maxstorepathlen
authorAdrian Buehlmann <adrian@cadifra.com>
Sun, 30 Sep 2012 23:53:56 +0200
changeset 17692 fb458b3e72fc
parent 17691 c6c7e466dd3a
child 17693 0c6de45e1212
pathencode: skip encoding if input is already longer than maxstorepathlen Calling basicencode may make the path longer, never shorter. If it's already too long before, then we don't even need to basicencode it.
mercurial/pathencode.c
--- a/mercurial/pathencode.c	Sun Sep 30 23:53:56 2012 +0200
+++ b/mercurial/pathencode.c	Sun Sep 30 23:53:56 2012 +0200
@@ -501,6 +501,12 @@
 		return NULL;
 	}
 
+	if (len > maxstorepathlen) {
+		newobj = Py_None;
+		Py_INCREF(newobj);
+		return newobj;
+	}
+
 	newlen = len ? basicencode(NULL, 0, path, len + 1) : 1;
 
 	if (newlen <= maxstorepathlen + 1) {