[PATCH 04 of 11 V1] pathencode: skip encoding if input is already longer than maxstorepathlen

Adrian Buehlmann adrian at cadifra.com
Sun Sep 30 16:56:41 CDT 2012


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1349042036 -7200
# Node ID 6937206a96c8235bebc65592e28782ffe827d99c
# Parent  c7f9dcccc54236fb8675fe7cc3a87ca21461300d
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
@@ -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) {


More information about the Mercurial-devel mailing list