Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve merging conflicts in Mercurial (v1.0.2)?

I have a merging conflict, using Mercurial 1.0.2:

merging test.h
warning: conflicts during merge.
merging test.h failed!
6 files updated, 0 files merged, 0 files removed, 1 files unresolved
There are unresolved merges, you can redo the full merge using:
  hg update -C 19
  hg merge 18

I can't figure out how to resolve this. Google search results instruct to use:

hg resolve

but for some reason my Mercurial (v1.0.2) doesn't have a resolve command:

hg: unknown command 'resolve'

How can I resolve this conflict?

like image 717
lajos Avatar asked Apr 28 '09 06:04

lajos


People also ask

How does mercurial resolve merge conflict?

To resolve the conflict, we open 'hello. c' in an editor, delete the conflict markers and keep the "sure am glad I'm using Mercurial!\ n" line, deleting the line about CVS. We can then save and quit the editor.

How do you resolve a merge conflict on the same branch?

To fix this situation, you need to create new commits that mimic those on the branch. The easiest way to do that is with git rebase -f . Now you can merge branch in again.


3 Answers

To highlight an answer in a comment for Hg 1.1+:

For Hg 1.1+ fix the file by hand and then do

hg resolve -m test.h 

to mark the file as merged.

like image 127
David Sykes Avatar answered Sep 19 '22 13:09

David Sykes


Valid for hg < v1.1 only

There is no need to call any hg commands. Unlike svn, Mercurial does not track conflicted files. If you call hg status, you'll see that the file is simply marked as modified.

Just fix the file by hand and commit.

like image 27
avakar Avatar answered Sep 19 '22 13:09

avakar


Tracking conflicts was introduced in Mercurial 1.1, which is a newer version that you are using (you should really upgrade, Mercurial 1.1. was released in December 2008). In that version you gained the resolve command which works similarly to svn resolve.

As I remember it, Mercurial would leave merge markers (the <<<< and >>>> lines) in your file when there is a conflict, unless you have configured a merge tool. This also applies to newer versions -- I have no merge tool configured and get the merge markers when conflicts occur. I can then manually fix the file and mark it resolved with hg resolve.

like image 41
Martin Geisler Avatar answered Sep 17 '22 13:09

Martin Geisler