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

52,118

Solution 1

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.

Solution 2

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.

Solution 3

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.

Share:
52,118
Berry Ligtermoet
Author by

Berry Ligtermoet

Updated on March 06, 2020

Comments

  • Berry Ligtermoet
    Berry Ligtermoet over 4 years

    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?

  • Berry Ligtermoet
    Berry Ligtermoet about 15 years
    So it looks like Mercurial moved my local copy to test.h.orig and test.h is now from the other head... is there any way to prevent creation of the .orig file so it doesn't get added accidentally?
  • avakar
    avakar about 15 years
    I'm not sure it's possible, but you can add *.orig to your .hgignore file.
  • Nick Zalutskiy
    Nick Zalutskiy about 15 years
    If you simply edit the file and then commit, its possible that it wont be recognized as a merge of the two branches, merely a new commit on your working one. I think you have to fix the file by hand and then do hg resolve -m test.h to mark the file as merged.
  • avakar
    avakar about 15 years
    The second parent is automatically added to the working directory even when 'hg merge' fails to resolve some conflicted files.
  • Nick
    Nick over 14 years
    Note This answer is for hg pre 1.1.
  • Imran Raheem
    Imran Raheem over 13 years
    same question. What to do with .orig files then?
  • Dori
    Dori about 12 years
    here is a nice quick way to do this hg st -un | grep orig | xargs rm
  • Collin Klopfenstein
    Collin Klopfenstein almost 12 years
    Dori, I would add a $ to the end of that grep, just so you don't accidentally catch something you didn't mean to.
  • Sandeep Chauhan
    Sandeep Chauhan over 10 years
    @lajos could you accept the (now) correct answer below, please?