0

I have a theoretical question about possible VCS merging. I know that many VCS use 3 revision merge, which is common ancestor, "mine" and "your" revision. I know how they works.

I've thought about another alternative, recursive revision merge, haven't found this in Google. "You found America!" you might think. I know Git use recursive merge. But the reason Git is using recursive merge is for criss-cross merge

I'm talking about a normal case, non criss-cross merge.

For example, we have a common ancestor, A, and to branches, 1 and 2.

branch 1: B,  C,  D,  E,  F,  G

branch 2: B', C', D', E', F', G'

As said before, A is the common ancestor so it's the parent of B and B'.

We want to merge G and G' into branch 1. The common way that Git and Mercurial use is the diff3:

diff3(ancestor = A, mine = G, yours = G')

This will compute merge by computing 3 version only, which is O(1).

The alternative algorithm I thought about is O(n):

  1. merge the closest revisions to ancestor first.

  2. merge the result with the next closest revision from branch 1

  3. merge the result with the next closest revision from branch 2 (if remain)

  4. repeat (in loop) to step 2 if there any revision in branch 1 remain.

In the above example it looks like:

  1. merge B and B'

  2. merge the result with C

  3. merge the result with C'

  4. merge the result with D

  5. and so on...

The question I couldn't resolve is - Is there any case that my way is safer and more accurate (in non criss-cross merge) than the traditional 3 revision merge?

Can my way avoid conflicts that the traditional way cause?

Can my way create new conflicts that the tradition way doesn't cause?

Does my way conflicts are not "real" conflicts? (which the tradition way doesn't cause)

Tal
  • 347
  • 2
  • 16

1 Answers1

0

We want to merge G and G' into branch 1.

Why we want merge G into branch1? G is already in branch1. In best case we give nothing from this merge, in worst - conflict. Same for all other revisions without '

So only B' - G' need to be merged to branch1. And this is the 3-way merge.

BTW. third component of 3-way merge not 'common ancestor', but 'base'. Common ancestor can be base but not always.

Sergey Azarkevich
  • 2,641
  • 2
  • 22
  • 38
  • I meant merging G' into G in branch 1, was confused between words "and" and "into", and between "common ancestor" and "base". You still haven't reply my question. – Tal Nov 10 '13 at 17:13
  • You can't merge G' into G. G immutable and can't be changed at all(at least with merge command). You can merge G' into branch1 and result of merge will be new node(revision) - H' – Sergey Azarkevich Nov 11 '13 at 04:30
  • (continue) H will contains logical changes A, B, C, D, E, F, G, G' I can't answer last 3 questions, because seems do not understand your idea. But if suppose that my understanding is correct, then: No Yes Yes – Sergey Azarkevich Nov 11 '13 at 04:38
  • Thanks for your last answer! That is what I wanted to know. Sorry for my unprofessional terms. – Tal Nov 12 '13 at 13:57