# HG changeset patch # User Matt Mackall # Date 2014-10-10 18:31:06 # Node ID 7e9cbb9c6053ef7a2d16318213f9ce90039d1c6c # Parent dfa44e25bb53902d917ff233d6537fdf50ec1434 dirstate: use 'm' state in otherparent to reduce ambiguity In rebase-like operations where we abandon the second parent, we can correctly fix up the state in setparents. diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -415,7 +415,13 @@ class dirstate(object): if self._pl[1] == nullid: raise util.Abort(_("setting %r to other parent " "only allowed in merges") % f) - self._addpath(f, 'n', 0, -2, -1) + if f in self and self[f] == 'n': + # merge-like + self._addpath(f, 'm', 0, -2, -1) + else: + # add-like + self._addpath(f, 'n', 0, -2, -1) + if f in self._copymap: del self._copymap[f] diff --git a/tests/test-filebranch.t b/tests/test-filebranch.t --- a/tests/test-filebranch.t +++ b/tests/test-filebranch.t @@ -66,11 +66,6 @@ Merging: $ echo 2b > baz $ echo new > quux -We shouldn't have anything but foo in merge state here: - - $ hg debugstate --nodates | grep "^m" - m 644 3 foo - $ hg ci -m "merge" main: we should have a merge here: diff --git a/tests/test-issue522.t b/tests/test-issue522.t --- a/tests/test-issue522.t +++ b/tests/test-issue522.t @@ -38,7 +38,7 @@ revision. (branch merge, don't forget to commit) $ hg debugstate | grep foo - n 0 -2 unset foo + m 0 -2 unset foo $ hg st -A foo M foo diff --git a/tests/test-merge-remove.t b/tests/test-merge-remove.t --- a/tests/test-merge-remove.t +++ b/tests/test-merge-remove.t @@ -21,7 +21,7 @@ (branch merge, don't forget to commit) $ hg debugstate --nodates - n 0 -2 bar + m 0 -2 bar m 644 14 foo1 copy: foo -> foo1 @@ -37,7 +37,7 @@ Removing foo1 and bar: $ hg rm -f foo1 bar $ hg debugstate --nodates - r 0 -2 bar + r 0 -1 bar r 0 -1 foo1 copy: foo -> foo1 @@ -55,7 +55,7 @@ Re-adding foo1 and bar: adding foo1 $ hg debugstate --nodates - n 0 -2 bar + m 644 5 bar m 644 14 foo1 copy: foo -> foo1 @@ -74,7 +74,7 @@ Reverting foo1 and bar: reverting foo1 $ hg debugstate --nodates - n 0 -2 bar + m 644 5 bar m 644 14 foo1 copy: foo -> foo1