Understanding Mercurial Merge Logic

Say myfile been changed in two repositories (A and B). In A, we do hg pull ../B , which receives these changes:

 A1 - A2 - A3 - A4 - A5 \ B3 - B4 

Since we have two heads (A5, B4), we do hg merge .

Now, if there are conflicts, Mercurial launches our Beyond Compare tool, and we get three types: left - local, center - parent, and right - "other". Given our structure, the left (local) will be A5, the center (parent) will be A2, and the right (other) will be B4?

Secondly, what exactly is the logic that Mercurial uses to determine if a merge is required? Does he see that there are two versions of myfile without any children? And how exactly does it determine that A2 is the parent?

+4
source share
1 answer

As indicated in Tool Merge Configuration

The merge tool starts with a list of args arguments with the following extended variables:

  • $output expanded to an existing file that already contains the version from the first parent - and this also means that the merge result ends / should end
  • $local extends to file.orig, which is created as a copy of the file in the working directory version - so it contains an unrelated version from the first parent
  • $ base expands to /tmp/file~base.* , which is created by the version from the general version of the ancestor ( see hg debugancestor )
  • $ other extends to /tmp/file~other.* , which is created with the version from the new second parent version, with which the first parent merges with

(so yes, "left (local) is A5, center (parent) is A2, and right (other) is B4")

enter image description here

(see merge execution ")

+5
source

Source: https://habr.com/ru/post/1347194/


All Articles