##// END OF EJS Templates
dirstate-entry: add a `need_delay` method...
marmoute -
r48321:ccbabaee default
parent child Browse files
Show More
@@ -141,6 +141,20 static PyObject *dirstatetuple_v1_mtime(
141 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 158 static PyMethodDef dirstatetuple_methods[] = {
145 159 {"v1_state", (PyCFunction)dirstatetuple_v1_state, METH_NOARGS,
146 160 "return a \"state\" suitable for v1 serialization"},
@@ -150,6 +164,8 static PyMethodDef dirstatetuple_methods
150 164 "return a \"size\" suitable for v1 serialization"},
151 165 {"v1_mtime", (PyCFunction)dirstatetuple_v1_mtime, METH_NOARGS,
152 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 169 {NULL} /* Sentinel */
154 170 };
155 171
@@ -754,7 +754,7 class dirstate(object):
754 754 if delaywrite > 0:
755 755 # do we have any files to delay for?
756 756 for f, e in pycompat.iteritems(self._map):
757 if e.state == b'n' and e[3] == now:
757 if e.need_delay(now):
758 758 import time # to avoid useless import
759 759
760 760 # rather than sleep n seconds, sleep until the next
@@ -153,6 +153,10 class dirstatetuple(object):
153 153 """return a "mtime" suitable for v1 serialization"""
154 154 return self._mtime
155 155
156 def need_delay(self, now):
157 """True if the stored mtime would be ambiguous with the current time"""
158 return self._state == b'n' and self._mtime == now
159
156 160
157 161 def gettype(q):
158 162 return int(q & 0xFFFF)
General Comments 0
You need to be logged in to leave comments. Login now