# HG changeset patch # User Pierre-Yves David # Date 2021-07-04 00:33:21 # Node ID 8e4b9fe3133489211bb480c16c2d3d3b1000e6c2 # Parent 6025353c9c55d6186bb350b526b69d017e3648e5 dirstate-entry: add a `mode` property This is clearer than "tuple" indexing. Differential Revision: https://phab.mercurial-scm.org/D10979 diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c --- a/mercurial/cext/parsers.c +++ b/mercurial/cext/parsers.c @@ -169,6 +169,11 @@ static PyMethodDef dirstatetuple_methods {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 PyObject *dirstatetuple_get_remov }; 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}, diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -1307,7 +1307,7 @@ class dirstate(object): # 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] diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py --- a/mercurial/pure/parsers.py +++ b/mercurial/pure/parsers.py @@ -72,6 +72,10 @@ class dirstatetuple(object): raise IndexError(idx) @property + def mode(self): + return self._mode + + @property def state(self): """ States are: