[PATCH] pathencode: skip encoding if input is already longer than maxstorepathlen

Adrian Buehlmann adrian at cadifra.com
Fri Sep 21 16:04:33 CDT 2012


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1348261363 -7200
# Node ID b532af187425e6ff650b5c112bf553b52ae4c560
# Parent  331d611813eca2098fdb75c741cb7f5cc72b6567
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.

diff --git a/mercurial/pathencode.c b/mercurial/pathencode.c
--- a/mercurial/pathencode.c
+++ b/mercurial/pathencode.c
@@ -508,6 +508,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) {


More information about the Mercurial-devel mailing list