Patchwork D11119: dirstate-item: add a `set_possibly_dirty` method

login
register
mail settings
Submitter phabricator
Date July 19, 2021, 10:39 a.m.
Message ID <differential-rev-PHID-DREV-gbm6upqc4bn2zbn6rp5c-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49435/
State Superseded
Headers show

Comments

phabricator - July 19, 2021, 10:39 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  See inline documentation for details.
  
  The pushes the AMBIGUOUS_TIME implementation further down the line within the
  DirstateItem only. When this cleanup is done we will be able to stop using this
  representation internally.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -81,6 +81,14 @@ 
             mtime=mtime,
         )
 
+    def set_possibly_dirty(self):
+        """Mark a file as "possibly dirty"
+
+        This means the next status call will have to actually check its content
+        to make sure it is correct.
+        """
+        self._mtime = AMBIGUOUS_TIME
+
     def __getitem__(self, idx):
         if idx == 0 or idx == -4:
             msg = b"do not use item[x], use item.state"
diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c
--- a/mercurial/cext/parsers.c
+++ b/mercurial/cext/parsers.c
@@ -31,6 +31,7 @@ 
 
 static const int dirstate_v1_from_p2 = -2;
 static const int dirstate_v1_nonnormal = -1;
+static const int ambiguous_time = -1;
 
 static PyObject *dict_new_presized(PyObject *self, PyObject *args)
 {
@@ -197,6 +198,14 @@ 
 	return (PyObject *)t;
 };
 
+/* This means the next status call will have to actually check its content
+   to make sure it is correct. */
+static PyObject *dirstate_item_set_possibly_dirty(dirstateItemObject *self)
+{
+	self->mtime = ambiguous_time;
+	Py_RETURN_NONE;
+}
+
 static PyMethodDef dirstate_item_methods[] = {
     {"v1_state", (PyCFunction)dirstate_item_v1_state, METH_NOARGS,
      "return a \"state\" suitable for v1 serialization"},
@@ -210,6 +219,8 @@ 
      "True if the stored mtime would be ambiguous with the current time"},
     {"from_v1_data", (PyCFunction)dirstate_item_from_v1_meth, METH_O,
      "build a new DirstateItem object from V1 data"},
+    {"set_possibly_dirty", (PyCFunction)dirstate_item_set_possibly_dirty,
+     METH_NOARGS, "mark a file as \"possibly dirty\""},
     {NULL} /* Sentinel */
 };