# HG changeset patch # User Pierre-Yves David # Date 1625357574 -7200 # Node ID f5b8f0b9c1291a11003ba9a19bab44233d6299b2 # Parent a1745a29288502a35d8600c86cf13415bf3209cc dirstate-entry: add a `tracked` property This abstract the individual `state` value and has a clear semantic. Differential Revision: https://phab.mercurial-scm.org/D10973 diff -r a1745a292885 -r f5b8f0b9c129 mercurial/cext/parsers.c --- a/mercurial/cext/parsers.c Sun Jul 04 01:59:41 2021 +0200 +++ b/mercurial/cext/parsers.c Sun Jul 04 02:12:54 2021 +0200 @@ -158,6 +158,15 @@ return PyBytes_FromStringAndSize(&self->state, 1); }; +static PyObject *dirstatetuple_get_tracked(dirstateTupleObject *self) +{ + if (self->state == 'a' || self->state == 'm' || self->state == 'n') { + Py_RETURN_TRUE; + } else { + Py_RETURN_FALSE; + } +}; + static PyObject *dirstatetuple_get_added(dirstateTupleObject *self) { if (self->state == 'a') { @@ -214,6 +223,7 @@ static PyGetSetDef dirstatetuple_getset[] = { {"state", (getter)dirstatetuple_get_state, NULL, "state", NULL}, + {"tracked", (getter)dirstatetuple_get_tracked, NULL, "tracked", NULL}, {"added", (getter)dirstatetuple_get_added, NULL, "added", NULL}, {"merged_removed", (getter)dirstatetuple_get_merged_removed, NULL, "merged_removed", NULL}, diff -r a1745a292885 -r f5b8f0b9c129 mercurial/dirstate.py --- a/mercurial/dirstate.py Sun Jul 04 01:59:41 2021 +0200 +++ b/mercurial/dirstate.py Sun Jul 04 02:12:54 2021 +0200 @@ -1313,7 +1313,7 @@ size = t[2] time = t[3] - if not st and state in b"nma": + if not st and t.tracked: dadd(fn) elif state == b'n': if ( diff -r a1745a292885 -r f5b8f0b9c129 mercurial/pure/parsers.py --- a/mercurial/pure/parsers.py Sun Jul 04 01:59:41 2021 +0200 +++ b/mercurial/pure/parsers.py Sun Jul 04 02:12:54 2021 +0200 @@ -87,6 +87,11 @@ return self._state @property + def tracked(self): + """True is the file is tracked in the working copy""" + return self._state in b"nma" + + @property def added(self): """True if the file has been added""" return self._state == b'a'