Patchwork D11124: dirstate-item: introduce a `dm_otherparent` property

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

Comments

phabricator - July 19, 2021, 10:40 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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cext/parsers.c
  mercurial/dirstatemap.py
  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
@@ -195,6 +195,14 @@ 
         """
         return self.state != b'n' or self.mtime == AMBIGUOUS_TIME
 
+    @property
+    def dm_otherparent(self):
+        """True is the entry is `otherparent` in the dirstatemap sense
+
+        There is no reason for any code, but the dirstatemap one to use this.
+        """
+        return self._size == FROM_P2
+
     def v1_state(self):
         """return a "state" suitable for v1 serialization"""
         return self._state
diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -197,7 +197,7 @@ 
         e = self._map[f] = DirstateItem(state, mode, size, mtime)
         if e.dm_nonnormal:
             self.nonnormalset.add(f)
-        if size == FROM_P2:
+        if e.dm_otherparent:
             self.otherparentset.add(f)
 
     def removefile(self, f, in_merge=False):
diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c
--- a/mercurial/cext/parsers.c
+++ b/mercurial/cext/parsers.c
@@ -150,6 +150,14 @@ 
 		Py_RETURN_FALSE;
 	}
 };
+static PyObject *dm_otherparent(dirstateItemObject *self)
+{
+	if (self->size == dirstate_v1_from_p2) {
+		Py_RETURN_TRUE;
+	} else {
+		Py_RETURN_FALSE;
+	}
+};
 
 static PyObject *dirstate_item_need_delay(dirstateItemObject *self,
                                           PyObject *value)
@@ -232,6 +240,8 @@ 
      METH_NOARGS, "mark a file as \"possibly dirty\""},
     {"dm_nonnormal", (PyCFunction)dm_nonnormal, METH_NOARGS,
      "True is the entry is non-normal in the dirstatemap sense"},
+    {"dm_otherparent", (PyCFunction)dm_otherparent, METH_NOARGS,
+     "True is the entry is `otherparent` in the dirstatemap sense"},
     {NULL} /* Sentinel */
 };