asc99c
asc99c

Reputation: 3905

Mercurial requiring manual merges unexpectedly

I've got a project running under Mercurial and am finding a lot of situations where a file needs manually merging, when I believe it should be able to merge automatically. I am wondering whether there are any options that can be given to Mercurial to help it out in these areas.

The project has an underlying platform with a couple of hundred files that can't be edited on the project. When the platform is updated, the project gets updated versions of these core files outside of Mercurial. The sequence I'm seeing repeatedly is:

On central dev system (linked to the core platform update mechanism):

On my Linux box:

The last two core files I've had to merge have no changes between the base and local versions (the access time is updated during a build, but the content is the same). The only changes are on the remote revision I'm merging with.

The only non-standard configuration I'm aware of is that the central mercurial instance is running under Rhodecode, with a commit hook setup to update a Redmine repository.

Is there anything else that can be configured in mercurial to help it figure out merges?

Upvotes: 1

Views: 131

Answers (1)

Martin Geisler
Martin Geisler

Reputation: 73808

You can redo a merge with --debug to get more information about a merge. That is, take your repository and do

$ cd ..
$ hg clone my-project -r 123 -r 456 merge-test

where 123 and 456 is the two parents of the merge you want to examine closer. Then run

$ hg merge --debug

to see what Mercurial says. It should look like this if the file foo has only been changed in the branch you're merging in:

$ hg merge --debug
  searching for copies back to rev 2
resolving manifests
 overwrite: False, partial: False
 ancestor: 932f5550d0ce, local: b0c286a4a76d+, remote: c491d1593652
 foo: remote is newer -> g
updating: foo 1/1 files (100.00%)
getting foo
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)

Here I was on revision b0c286a4a76d and merged with c491d1593652.

You can also use

$ hg status --rev "ancestor(b0c286a4a76d, c491d1593652)" --rev "c491d1593652"
M foo
$ hg status --rev "ancestor(b0c286a4a76d, c491d1593652)" --rev "b0c286a4a76d"
M bar

to double-check which files have been changed between the ancestor revision and the two changesets you're merging. Above you see that I changed foo on one branch and bar on the other.

If you see a platform file appear in both status lists, well then something went wrong in your procedures and this can explain the merge conflicts.

If this isn't enough to figure out what went wrong, then I suggest asking this question on the Mercurial mailinglist. That's a great place for discussion and bug-hunting — much better than Stack Overflow.

Upvotes: 1

Related Questions