Show More
@@ -141,6 +141,20 b' static PyObject *dirstatetuple_v1_mtime(' | |||||
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"}, | |
@@ -150,6 +164,8 b' static PyMethodDef dirstatetuple_methods' | |||||
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 |
@@ -754,7 +754,7 b' class dirstate(object):' | |||||
754 | if delaywrite > 0: |
|
754 | if delaywrite > 0: | |
755 | # do we have any files to delay for? |
|
755 | # do we have any files to delay for? | |
756 | for f, e in pycompat.iteritems(self._map): |
|
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 | import time # to avoid useless import |
|
758 | import time # to avoid useless import | |
759 |
|
759 | |||
760 | # rather than sleep n seconds, sleep until the next |
|
760 | # rather than sleep n seconds, sleep until the next |
@@ -153,6 +153,10 b' class dirstatetuple(object):' | |||||
153 | """return a "mtime" suitable for v1 serialization""" |
|
153 | """return a "mtime" suitable for v1 serialization""" | |
154 | return self._mtime |
|
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 | def gettype(q): |
|
161 | def gettype(q): | |
158 | return int(q & 0xFFFF) |
|
162 | return int(q & 0xFFFF) |
General Comments 0
You need to be logged in to leave comments.
Login now