I'm trying to convert from a different DVCS to Mercurial. I've found a situation where Mercurial won't let me do something that the other DVCS finds perfectly reasonable.
It seems that in the repo, one of the users is in the habit of working like this:
- fork
- do work in fork
- merge trunk -> fork
- test
- merge fork -> trunk
That all seems perfectly reasonable. Except that if trunk hasn't advanced while the user was testing, hg refuses to do the final merge, with
abort: nothing to merge
and --force doesn't help.
I can replicate this with the following test case:
echo "Test data" > file
hg add file
hg commit file -m "Ancestor"
# rev 0
echo "Trunk" > file
hg commit file -m "Trunk"
# rev 1
hg checkout 0
echo "Branch" > file
hg commit file -m "Branch"
# rev 2
hg merge --tool internal:local 1
hg commit -m "Merge trunk to branch"
# rev 3
hg checkout 1
hg merge --tool internal:local 3 # <--- fails
hg commit -m "Merge branch to trunk"
If I modify the test so that trunk advances between the two merges, so at the final merge trunk is now a new revision 4 and revision 3 is merged into it, everything works fine.
This is obviously all perfectly standard workflow --- I do this myself. So why isn't this working?
Update:
This test case works:
echo "Test data" > file
hg add file
hg commit file -m "Ancestor"
hg branch trunk
# rev 0
echo "Trunk" > file
hg commit file -m "Trunk"
# rev 1
hg checkout 0
hg branch branch
echo "Branch" > file
hg commit file -m "Branch"
# rev 2
hg merge --tool internal:local 1
hg commit -m "Merge trunk to branch"
# rev 3
hg checkout 1
hg merge --tool internal:local 3
hg commit -m "Merge branch to trunk"
This is exactly the same code as the first test case, except that trunk and fork are now explicitly branched rather than just using ad-hoc heads. All merges and checkouts use the same revisions as before. Apparently branches are magic.
Unfortunately I can't use branches in the real code, because the other DVCS is using ad-hoc heads, none of which have any branch information. I don't want to have to fake a branch for every fork.
How can I persuade Mercurial to let me do this without using explicit branches?