106

When merging conflicting changes using hg merge, Mercurial inserts a set of markers into the files to be merged in my working copy like this:

<<<<<<< local
  version = 0.2
=======
  version = 0.1
>>>>>>> other

Then I manually edit all files marked as U from a list produced by hg resolve --all -l and then I tell mercurial I have resolved them by hg resolve -m file1 file2 file3 ...

In many situations I would like however accept either my-only or their-only changes on some conflicting files. I am thinking to create two simple sed/awk/whatever scripts named accept-theirs.sh and accept-my.sh or is there any "proper" way to do it?

chepner
  • 446,329
  • 63
  • 468
  • 610
psihodelia
  • 28,154
  • 35
  • 107
  • 154

2 Answers2

181

Use

hg resolve -t internal:other --all

to accept theirs and

hg resolve -t internal:local --all

to accept yours

Noffls
  • 5,297
  • 2
  • 29
  • 36
  • Thank you very much! I don't understand what @djc means, but your solution works like a charm. – psihodelia Mar 21 '13 at 15:05
  • @psihodelia djc said pretty much the same, try `hg help merge-tools` (mergetools is an alias in latter versions) – MGP Mar 21 '13 at 21:14
  • 6
    As a side note, I aliased this: `[alias] mine = resolve -t internal:local theirs = resolve -t internal:other` –  May 05 '13 at 16:33
  • 1
    Those are three lines to add to one's own `.hgrc`, for the newbies: `[alias]`, then `mine = resolve -t internal:local`, then `theirs = resolve -t internal:other`. After that you can use `hg mine some_file.py` or `hg theirs -a` (for All) – Tobia Apr 04 '14 at 16:28
  • 4
    As of https://phab.mercurial-scm.org/D4379, you may also need to include the `--re-merge` flag (e.g. `hg resolve -t internal:other --re-merge --all`) – Ethan Koenig Nov 27 '19 at 01:06
25

Try this:

hg merge --tool internal:other

See also hg help merge-tools for more information.

Clonkex
  • 3,036
  • 6
  • 36
  • 50
djc
  • 11,305
  • 5
  • 41
  • 50