views:

44

answers:

2

I'm working on a project where I have a commit that introduced a feature with major problems that weren't discovered immediately. Now I want to completely remove that revision while keeping the work following it but i'm having a hard time wrapping my head around this 3 way merge. Here is a simplified graph of my project.

o  changeset:   134:7f81764aa03a
|  tag:         tip
|  parent:      128:451d8a19edea
|  summary:     Backed out changeset 451d8a19edea
|
| @  changeset:   133:5eefa40e2a29
| |  summary:     (Change I need to keep keep)
| |
*snip 3 commits*
| o  changeset:   129:5f6182a97d40
|/   summary:     (Change I need to keep keep)
|
o  changeset:   128:451d8a19edea
|  summary:     (Change that introduced a major problem)
|
o  changeset:   127:4f26dc55455d
|  summary:     (summary doesn't matter for this question)

If I understand this correctly, r127 and r134 are exactly the same. When I hg up -C -r 133 and then run hg merge, Meld pops up with three forms of one of my files: local, base, and other. local seems to be r133 but i'm having a hard time wrapping my head around what "base" and "other" mean.

+3  A: 

Local is r133

Other is r134

Base is r128 (the common ancestor to both r133 and r 134)

When you perform a 3 way merge it compares all three of those together to help you decide what to take and from where. By seeing what change is in the other revision and what the common ancestor looked like you are able to make a much more informed decision about what to keep and what to change.

Matthew Manela
A: 

hmm your questino is really confusing, but here are some information that may help you.

  • what is base?

base is the unmodified version of the revision that you have currently checked out and worked on. where possibily other changes have forked off (you can have revisions in between your currentl local and base!). its just where the nearest revision where no other fork has diverted from afterwards (same parent) (in your case r128)

  • what is head?

head is the latest revision in version control. if you work alone on only one copy it will probably be base. but a co worker might have modified the same file and checked it into versino control, then head is later than your base.

  • what is local?

local is your modified version (in your case r133)

  • what is other?

other is the some fork/branch that has also your base as parent (in your case r134)

  • how does 3-way merge work?

3 way merge works (at least in meld) hirachically. usually from left to right like this:

local > base > other / head

local/base is mostly trivial because its just what you modified

then you can merge your changes into the head revision or the one of your co worker or whatever.

there can be multiple other/head revisions, but then its not your job to merge in and therefore more than 3 way compare doesnt make sense.

Joe Hopfgartner
Your definition of head isn't accurate for mercurial. The latest revision in mercurial is called 'tip'. A tip is always a head but a head is not always a tip. In a merge 'head' is never 'base' becuase 'base is the most recent common ancestor of the two changesets being merged.
Ry4an
+1 thanks for that input, did not know that!
Joe Hopfgartner