dirstate-item: introduce a `dm_otherparent` property
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 14 Jul 2021 22:06:13 +0200
changeset 47686 e43128ee436f
parent 47685 265cdfaad372
child 47687 e59bd6723f2f
dirstate-item: introduce a `dm_otherparent` property See inline documentation for details. Differential Revision: https://phab.mercurial-scm.org/D11124
mercurial/cext/parsers.c
mercurial/dirstatemap.py
mercurial/pure/parsers.py
--- a/mercurial/cext/parsers.c	Wed Jul 14 21:59:18 2021 +0200
+++ b/mercurial/cext/parsers.c	Wed Jul 14 22:06:13 2021 +0200
@@ -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 */
 };
 
--- a/mercurial/dirstatemap.py	Wed Jul 14 21:59:18 2021 +0200
+++ b/mercurial/dirstatemap.py	Wed Jul 14 22:06:13 2021 +0200
@@ -199,7 +199,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):
--- a/mercurial/pure/parsers.py	Wed Jul 14 21:59:18 2021 +0200
+++ b/mercurial/pure/parsers.py	Wed Jul 14 22:06:13 2021 +0200
@@ -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