diff mercurial/cext/revlog.c @ 43534:0c659fc20207

index: add a `has_node` method (API) The new `index.has_node(node)` is to be preferred over: `node in index.nodemap`. This get us closer to be able to remove the `nodemap` attribute of the index. Differential Revision: https://phab.mercurial-scm.org/D7322
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 03 Nov 2019 00:01:09 +0100
parents 53581e220ba3
children bd87114ce341
line wrap: on
line diff
--- a/mercurial/cext/revlog.c	Sat Nov 09 05:54:22 2019 +0100
+++ b/mercurial/cext/revlog.c	Sun Nov 03 00:01:09 2019 +0100
@@ -2065,6 +2065,14 @@
 	}
 }
 
+static PyObject *index_m_has_node(indexObject *self, PyObject *args)
+{
+	int ret = index_contains(self, args);
+	if (ret < 0)
+		return NULL;
+	return PyBool_FromLong((long)ret);
+}
+
 typedef uint64_t bitmask;
 
 /*
@@ -2723,6 +2731,8 @@
     {"clearcaches", (PyCFunction)index_clearcaches, METH_NOARGS,
      "clear the index caches"},
     {"get", (PyCFunction)index_m_get, METH_VARARGS, "get an index entry"},
+    {"has_node", (PyCFunction)index_m_has_node, METH_O,
+     "return True if the node exist in the index"},
     {"computephasesmapsets", (PyCFunction)compute_phases_map_sets, METH_VARARGS,
      "compute phases"},
     {"reachableroots2", (PyCFunction)reachableroots2, METH_VARARGS,