diff mercurial/cext/parsers.c @ 47514:559aee84b889

dirstate-entry: add a `from_p2` property Lets start to define and use more semantic property. Differential Revision: https://phab.mercurial-scm.org/D10956
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 03 Jul 2021 04:26:28 +0200
parents 10e740292dff
children c94d3ff46fd5
line wrap: on
line diff
--- a/mercurial/cext/parsers.c	Sat Jul 03 04:07:21 2021 +0200
+++ b/mercurial/cext/parsers.c	Sat Jul 03 04:26:28 2021 +0200
@@ -29,6 +29,8 @@
 
 static const char *const versionerrortext = "Python minor version mismatch";
 
+static const int dirstate_v1_from_p2 = -2;
+
 static PyObject *dict_new_presized(PyObject *self, PyObject *args)
 {
 	Py_ssize_t expected_size;
@@ -164,9 +166,19 @@
 	}
 };
 
+static PyObject *dirstatetuple_get_from_p2(dirstateTupleObject *self)
+{
+	if (self->size == dirstate_v1_from_p2) {
+		Py_RETURN_TRUE;
+	} else {
+		Py_RETURN_FALSE;
+	}
+};
+
 static PyGetSetDef dirstatetuple_getset[] = {
     {"state", (getter)dirstatetuple_get_state, NULL, "state", NULL},
     {"merged", (getter)dirstatetuple_get_merged, NULL, "merged", NULL},
+    {"from_p2", (getter)dirstatetuple_get_from_p2, NULL, "from_p2", NULL},
     {NULL} /* Sentinel */
 };