D10959: dirstate-entry: restrict `from_p2` property to tracked file
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Sun Jul 4 21:53:30 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
The other case is now handled in `from_p2_removed`, and should ideally be moved
to a lower level. So we can drop the `state == 'n'` narrowing and move it in the
property itself.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10959
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
@@ -98,9 +98,11 @@
def from_p2(self):
"""True if the file have been fetched from p2 during the current merge
+ This is only True is the file is currently tracked.
+
Should only be set if a merge is in progress in the dirstate
"""
- return self._size == FROM_P2
+ return self._state == b'n' and self._size == FROM_P2
@property
def from_p2_removed(self):
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -393,7 +393,7 @@
copies[f] = source
self.normallookup(f)
# Also fix up otherparent markers
- elif s.state == b'n' and s.from_p2:
+ elif s.from_p2:
source = self._map.copymap.get(f)
if source:
copies[f] = source
@@ -542,7 +542,7 @@
if source is not None:
self.copy(source, f)
return
- elif entry.merged or entry.state == b'n' and entry.from_p2:
+ elif entry.merged or entry.from_p2:
return
self._addpath(f, b'n', 0, possibly_dirty=True)
self._map.copymap.pop(f, None)
diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c
--- a/mercurial/cext/parsers.c
+++ b/mercurial/cext/parsers.c
@@ -178,7 +178,7 @@
static PyObject *dirstatetuple_get_from_p2(dirstateTupleObject *self)
{
- if (self->size == dirstate_v1_from_p2) {
+ if (self->state == 'n' && self->size == dirstate_v1_from_p2) {
Py_RETURN_TRUE;
} else {
Py_RETURN_FALSE;
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list