Patchwork [2,of,4,lazy-manifest,v2] manifest.c: allow None explicity in __contains__, and say it's not present

login
register
mail settings
Submitter Augie Fackler
Date Jan. 12, 2015, 8:04 p.m.
Message ID <326c0468a695484f5987.1421093087@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/7438/
State Changes Requested
Headers show

Comments

Augie Fackler - Jan. 12, 2015, 8:04 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1416425464 18000
#      Wed Nov 19 14:31:04 2014 -0500
# Node ID 326c0468a695484f5987eea0322cca91153843cf
# Parent  b9d67bf3ea8196c8530afdcf6b1727682b681259
manifest.c: allow None explicity in __contains__, and say it's not present

None is an invalid key for this object, so just say it's not present
instead of being grumpy about types. This fixes some mystifying
failures in mergecopies.

Patch

diff --git a/mercurial/manifest.c b/mercurial/manifest.c
--- a/mercurial/manifest.c
+++ b/mercurial/manifest.c
@@ -503,6 +503,12 @@  static int lazymanifest_contains(lazyman
 {
 	line needle;
 	line *hit;
+	/* I don't think this special case for lazymanifest containing
+	 * None (it never does) should really need to be here, but
+	 * some code (notably mergecopies) seems to do this in some
+	 * magical way that I don't understand. */
+	if (key == Py_None)
+		return 0;
 	if (!PyString_Check(key)) {
 		PyErr_Format(PyExc_TypeError,
 		             "contains: manifest keys must be a string.");