views:

1517

answers:

3

Is there any way to take complete manual control over the merge process in Mercurial?

I want to be able to choose direction of file-merge, even for files without conflicts. Is that possible?

+2  A: 

A merge is always performed between the working directory's parent revision and another revision, by default the other head in your repository.

If you want to merge in the other "direction" you can change which branch is in your working directory by checking out a specific revision:

hg update -r [rev]

To see which heads you have in your repository run the following command:

hg heads

Alternatively, if you're using fetch you can use the --switch-parent option to merge in the other direction:

hg fetch --switch-parent

You can't change the direction of the merge on a file-by-file basis as Mercurial works with changesets which affect a whole repository not by tracking changes on to individual files like CVS.

Dave Webb
I see he accepted your answer, but I don't think it's actually what he was asking. You told him how to pick "left" or "right" for all non-conflicts, but if he wants to mix-and match he needs to turn the internal "pre-merge" off before launching his merge tool.
Ry4an
+12  A: 

Turn "pre-merge" off in your merge configuration. Then everything counts as a conflict and you can pick "left" or "right" for each and every file change.

[merge-tools]
mymergetool.premerge = False

from MergeToolConfiguration on the Mercurial wiki.

Ry4an
A: 

Edit your configuration file this way:

[ui]
merge = kdiff3

[merge-tools]
kdiff3.premerge = false
kdiff3.args=--L1 base --L2 local --L3 other $base $local $other -o $output

By default it puts the --auto argument on kdiff3 so kdiff3 auto merges.

Eduardo