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

login
register
mail settings
Submitter Augie Fackler
Date Jan. 8, 2015, 8:34 p.m.
Message ID <1165b1c87091d12209a3.1420749299@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/7387/
State Changes Requested
Headers show

Comments

Augie Fackler - Jan. 8, 2015, 8:34 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1416425464 18000
#      Wed Nov 19 14:31:04 2014 -0500
# Node ID 1165b1c87091d12209a3346834be5c1e3db8a9e4
# Parent  788bb2dacad048f161dfed583d3a95f708e91d1e
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
@@ -486,6 +486,12 @@  static PyMappingMethods lzm_mapping_meth
 
 static int lzm_contains(lazymanifest * self, PyObject * key)
 {
+	/* 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.");