Mercurial > hg
diff mercurial/cext/parsers.c @ 47516:b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Lets start to define and use more semantic property. These two might be a bit
too low level and could be shaved off later, however this seems an improvement
for now.
Differential Revision: https://phab.mercurial-scm.org/D10958
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 03 Jul 2021 20:34:09 +0200 |
parents | c94d3ff46fd5 |
children | 28632eb3ca3e |
line wrap: on
line diff
--- a/mercurial/cext/parsers.c Sat Jul 03 04:18:54 2021 +0200 +++ b/mercurial/cext/parsers.c Sat Jul 03 20:34:09 2021 +0200 @@ -30,6 +30,7 @@ static const char *const versionerrortext = "Python minor version mismatch"; static const int dirstate_v1_from_p2 = -2; +static const int dirstate_v1_nonnormal = -1; static PyObject *dict_new_presized(PyObject *self, PyObject *args) { @@ -166,6 +167,15 @@ } }; +static PyObject *dirstatetuple_get_merged_removed(dirstateTupleObject *self) +{ + if (self->state == 'r' && self->size == dirstate_v1_nonnormal) { + Py_RETURN_TRUE; + } else { + Py_RETURN_FALSE; + } +}; + static PyObject *dirstatetuple_get_from_p2(dirstateTupleObject *self) { if (self->size == dirstate_v1_from_p2) { @@ -175,6 +185,15 @@ } }; +static PyObject *dirstatetuple_get_from_p2_removed(dirstateTupleObject *self) +{ + if (self->state == 'r' && self->size == dirstate_v1_from_p2) { + Py_RETURN_TRUE; + } else { + Py_RETURN_FALSE; + } +}; + static PyObject *dirstatetuple_get_removed(dirstateTupleObject *self) { if (self->state == 'r') { @@ -186,7 +205,11 @@ static PyGetSetDef dirstatetuple_getset[] = { {"state", (getter)dirstatetuple_get_state, NULL, "state", NULL}, + {"merged_removed", (getter)dirstatetuple_get_merged_removed, NULL, + "merged_removed", NULL}, {"merged", (getter)dirstatetuple_get_merged, NULL, "merged", NULL}, + {"from_p2_removed", (getter)dirstatetuple_get_from_p2_removed, NULL, + "from_p2_removed", NULL}, {"from_p2", (getter)dirstatetuple_get_from_p2, NULL, "from_p2", NULL}, {"removed", (getter)dirstatetuple_get_removed, NULL, "removed", NULL}, {NULL} /* Sentinel */