[Updated] D10974: dirstate-entry: add a `need_delay` method

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Tue Jul 6 19:13:40 UTC 2021


Closed by commit rHGccbabaee5c36: dirstate-entry: add a `need_delay` method (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D10974?vs=28876&id=28913

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D10974/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D10974

AFFECTED FILES
  mercurial/cext/parsers.c
  mercurial/dirstate.py
  mercurial/pure/parsers.py

CHANGE DETAILS

diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -153,6 +153,10 @@
         """return a "mtime" suitable for v1 serialization"""
         return self._mtime
 
+    def need_delay(self, now):
+        """True if the stored mtime would be ambiguous with the current time"""
+        return self._state == b'n' and self._mtime == now
+
 
 def gettype(q):
     return int(q & 0xFFFF)
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -754,7 +754,7 @@
         if delaywrite > 0:
             # do we have any files to delay for?
             for f, e in pycompat.iteritems(self._map):
-                if e.state == b'n' and e[3] == now:
+                if e.need_delay(now):
                     import time  # to avoid useless import
 
                     # rather than sleep n seconds, sleep until the next
diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c
--- a/mercurial/cext/parsers.c
+++ b/mercurial/cext/parsers.c
@@ -141,6 +141,20 @@
 	return PyInt_FromLong(self->mtime);
 };
 
+static PyObject *dirstatetuple_need_delay(dirstateTupleObject *self,
+                                          PyObject *value)
+{
+	long now;
+	if (!pylong_to_long(value, &now)) {
+		return NULL;
+	}
+	if (self->state == 'n' && self->mtime == now) {
+		Py_RETURN_TRUE;
+	} else {
+		Py_RETURN_FALSE;
+	}
+};
+
 static PyMethodDef dirstatetuple_methods[] = {
     {"v1_state", (PyCFunction)dirstatetuple_v1_state, METH_NOARGS,
      "return a \"state\" suitable for v1 serialization"},
@@ -150,6 +164,8 @@
      "return a \"size\" suitable for v1 serialization"},
     {"v1_mtime", (PyCFunction)dirstatetuple_v1_mtime, METH_NOARGS,
      "return a \"mtime\" suitable for v1 serialization"},
+    {"need_delay", (PyCFunction)dirstatetuple_need_delay, METH_O,
+     "True if the stored mtime would be ambiguous with the current time"},
     {NULL} /* Sentinel */
 };
 



To: marmoute, #hg-reviewers, SimonSapin, pulkit
Cc: Alphare, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210706/df425394/attachment-0002.html>


More information about the Mercurial-patches mailing list