comparison mercurial/cext/parsers.c @ 47532:ccbabaee5c36

dirstate-entry: add a `need_delay` method This abstract the internal processing need for entry that would have an ambiguous mtime (If I understand things correctly). Differential Revision: https://phab.mercurial-scm.org/D10974
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 04 Jul 2021 02:13:53 +0200
parents f5b8f0b9c129
children 8e4b9fe31334
comparison
equal deleted inserted replaced
47531:f5b8f0b9c129 47532:ccbabaee5c36
139 static PyObject *dirstatetuple_v1_mtime(dirstateTupleObject *self) 139 static PyObject *dirstatetuple_v1_mtime(dirstateTupleObject *self)
140 { 140 {
141 return PyInt_FromLong(self->mtime); 141 return PyInt_FromLong(self->mtime);
142 }; 142 };
143 143
144 static PyObject *dirstatetuple_need_delay(dirstateTupleObject *self,
145 PyObject *value)
146 {
147 long now;
148 if (!pylong_to_long(value, &now)) {
149 return NULL;
150 }
151 if (self->state == 'n' && self->mtime == now) {
152 Py_RETURN_TRUE;
153 } else {
154 Py_RETURN_FALSE;
155 }
156 };
157
144 static PyMethodDef dirstatetuple_methods[] = { 158 static PyMethodDef dirstatetuple_methods[] = {
145 {"v1_state", (PyCFunction)dirstatetuple_v1_state, METH_NOARGS, 159 {"v1_state", (PyCFunction)dirstatetuple_v1_state, METH_NOARGS,
146 "return a \"state\" suitable for v1 serialization"}, 160 "return a \"state\" suitable for v1 serialization"},
147 {"v1_mode", (PyCFunction)dirstatetuple_v1_mode, METH_NOARGS, 161 {"v1_mode", (PyCFunction)dirstatetuple_v1_mode, METH_NOARGS,
148 "return a \"mode\" suitable for v1 serialization"}, 162 "return a \"mode\" suitable for v1 serialization"},
149 {"v1_size", (PyCFunction)dirstatetuple_v1_size, METH_NOARGS, 163 {"v1_size", (PyCFunction)dirstatetuple_v1_size, METH_NOARGS,
150 "return a \"size\" suitable for v1 serialization"}, 164 "return a \"size\" suitable for v1 serialization"},
151 {"v1_mtime", (PyCFunction)dirstatetuple_v1_mtime, METH_NOARGS, 165 {"v1_mtime", (PyCFunction)dirstatetuple_v1_mtime, METH_NOARGS,
152 "return a \"mtime\" suitable for v1 serialization"}, 166 "return a \"mtime\" suitable for v1 serialization"},
167 {"need_delay", (PyCFunction)dirstatetuple_need_delay, METH_O,
168 "True if the stored mtime would be ambiguous with the current time"},
153 {NULL} /* Sentinel */ 169 {NULL} /* Sentinel */
154 }; 170 };
155 171
156 static PyObject *dirstatetuple_get_state(dirstateTupleObject *self) 172 static PyObject *dirstatetuple_get_state(dirstateTupleObject *self)
157 { 173 {