diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c --- a/mercurial/cext/parsers.c +++ b/mercurial/cext/parsers.c @@ -155,8 +155,18 @@ return PyBytes_FromStringAndSize(&self->state, 1); }; +static PyObject *dirstatetuple_get_merged(dirstateTupleObject *self) +{ + if (self->state == 'm') { + Py_RETURN_TRUE; + } else { + Py_RETURN_FALSE; + } +}; + static PyGetSetDef dirstatetuple_getset[] = { {"state", (getter)dirstatetuple_get_state, NULL, "state", NULL}, + {"merged", (getter)dirstatetuple_get_merged, NULL, "merged", NULL}, {NULL} /* Sentinel */ }; diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -355,7 +355,7 @@ def setparents(self, p1, p2=None): """Set dirstate parents to p1 and p2. - When moving from two parents to one, 'm' merged entries a + When moving from two parents to one, "merged" entries a adjusted to normal and previous copy records discarded and returned by the call. @@ -386,8 +386,8 @@ if s is None: continue - # Discard 'm' markers when moving away from a merge state - if s.state == b'm': + # Discard "merged" markers when moving away from a merge state + if s.merged: source = self._map.copymap.get(f) if source: copies[f] = source @@ -527,7 +527,7 @@ '''Mark a file normal, but possibly dirty.''' if self.in_merge: # if there is a merge going on and the file was either - # in state 'm' (-1) or coming from other parent (-2) before + # "merged" or coming from other parent (-2) before # being removed, restore that state. entry = self._map.get(f) if entry is not None: @@ -540,11 +540,7 @@ if source: self.copy(source, f) return - if ( - entry.state == b'm' - or entry.state == b'n' - and entry[2] == FROM_P2 - ): + if entry.merged or entry.state == b'n' and entry[2] == FROM_P2: return self._addpath(f, b'n', 0, possibly_dirty=True) self._map.copymap.pop(f, None) @@ -1362,7 +1358,7 @@ ladd(fn) elif listclean: cadd(fn) - elif state == b'm': + elif t.merged: madd(fn) elif state == b'a': aadd(fn) diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py --- a/mercurial/dirstatemap.py +++ b/mercurial/dirstatemap.py @@ -171,7 +171,7 @@ # would be nice. if entry is not None: # backup the previous state - if entry[0] == b'm': # merge + if entry.merged: # merge size = NONNORMAL elif entry[0] == b'n' and entry[2] == FROM_P2: # other parent size = FROM_P2 diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py --- a/mercurial/pure/parsers.py +++ b/mercurial/pure/parsers.py @@ -79,6 +79,14 @@ """ return self._state + @property + def merged(self): + """True if the file has been merged + + Should only be set if a merge is in progress in the dirstate + """ + return self._state == b'm' + def v1_state(self): """return a "state" suitable for v1 serialization""" return self._state