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.
--- a/mercurial/dirstate.py Fri Oct 10 13:05:50 2014 -0500
+++ b/mercurial/dirstate.py Fri Oct 10 13:31:06 2014 -0500
@@ -415,7 +415,13 @@
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]
--- a/tests/test-filebranch.t Fri Oct 10 13:05:50 2014 -0500
+++ b/tests/test-filebranch.t Fri Oct 10 13:31:06 2014 -0500
@@ -66,11 +66,6 @@
$ 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:
--- a/tests/test-issue522.t Fri Oct 10 13:05:50 2014 -0500
+++ b/tests/test-issue522.t Fri Oct 10 13:31:06 2014 -0500
@@ -38,7 +38,7 @@
(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
--- a/tests/test-merge-remove.t Fri Oct 10 13:05:50 2014 -0500
+++ b/tests/test-merge-remove.t Fri Oct 10 13:31:06 2014 -0500
@@ -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 @@
$ 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 @@
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
$ hg debugstate --nodates
- n 0 -2 bar
+ m 644 5 bar
m 644 14 foo1
copy: foo -> foo1