dirstate-entry: add a `mode` property
This is clearer than "tuple" indexing.
Differential Revision: https://phab.mercurial-scm.org/D10979
--- a/mercurial/cext/parsers.c Sun Jul 04 02:28:08 2021 +0200
+++ b/mercurial/cext/parsers.c Sun Jul 04 02:33:21 2021 +0200
@@ -169,6 +169,11 @@
{NULL} /* Sentinel */
};
+static PyObject *dirstatetuple_get_mode(dirstateTupleObject *self)
+{
+ return PyInt_FromLong(self->mode);
+};
+
static PyObject *dirstatetuple_get_state(dirstateTupleObject *self)
{
return PyBytes_FromStringAndSize(&self->state, 1);
@@ -238,6 +243,7 @@
};
static PyGetSetDef dirstatetuple_getset[] = {
+ {"mode", (getter)dirstatetuple_get_mode, NULL, "mode", NULL},
{"state", (getter)dirstatetuple_get_state, NULL, "state", NULL},
{"tracked", (getter)dirstatetuple_get_tracked, NULL, "tracked", NULL},
{"added", (getter)dirstatetuple_get_added, NULL, "added", NULL},
--- a/mercurial/dirstate.py Sun Jul 04 02:28:08 2021 +0200
+++ b/mercurial/dirstate.py Sun Jul 04 02:33:21 2021 +0200
@@ -1307,7 +1307,7 @@
# general. That is much slower than simply accessing and storing the
# tuple members one by one.
t = dget(fn)
- mode = t[1]
+ mode = t.mode
size = t[2]
time = t[3]
--- a/mercurial/pure/parsers.py Sun Jul 04 02:28:08 2021 +0200
+++ b/mercurial/pure/parsers.py Sun Jul 04 02:33:21 2021 +0200
@@ -72,6 +72,10 @@
raise IndexError(idx)
@property
+ def mode(self):
+ return self._mode
+
+ @property
def state(self):
"""
States are: