You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

There are two types of model merge: 3-way merge and 2-way merge. Choose the way of merge according to a particular case.

3-way merge

Conceptually, 3-way merge is a junction of two different sets, if we assume that a different set contains changes between a contributor and the ancestor. For example, a different set of v1-v2 represents changes between project v2 and ancestor v1 as well as v1-v3 does for project v3 and the same ancestor.

Use the 3-way merge, if you need to compare and merge changes from two projects into one and consider the ancestor of both projects. For example, you may need to merge two branches of the same server project that have been simultaneously developed by two different users in a collaborative environment, as shown in the following figure. As you can see, branch b.1 has been created from project version 2. Then both versions have been developed in parallel. The merge operation copies changes that have been made in the branch version to the trunk version.


 
2-way merge

2-way merge is a specific case of the 3-way merge. Use this type of merge for joining together two versions of the same local or server project. The logic of this type of merge is the same as of 3-way merge. However, the ancestor project version for TWCloud projects is found by using the following algorithms: 

  1. The lowest common ancestor (LCA) of two revisions v and w in a tree, or directed acyclic graph (DAG) T is the lowest (nearest) revision that has both v and w as descendants. Each revision is defined to be a descendant of itself (if v has a direct connection from ww is the lowest common ancestor). The LCA of v and w in T is the shared ancestor of v and w that is located farthest from the root. This algorithm considers both the direct parent path and merged path of v and w when finding a common ancestor. So, it can produce more than one common ancestor between v and w, if those lowest ancestors have the same distance from v and w.
  2. The lowest common ancestor (LCA) of two revisions v and w in a tree, or directed acyclic graph (DAG) T is the lowest (nearest) revision that has both v and w as descendants. Each revision defined to be a descendant of itself (if v has a direct connection from ww is the lowest common ancestor). The LCA of v and w in T is the shared ancestor of v and w that is located farthest from the root. This algorithm considers only the direct parent path of v and w when finding a common ancestor so there can be only one common ancestor between v and w.

Which algorithm will be used for a particular merge case depends on previous target project commits: 

  1. if there are Set As Latest and merge commits among previous target project commits, then the algorithm will be chosen by the rule which commit is the closest to the current target project:
    1. if the closest commit is from Set As Latest then the second algorithm will be used;
    2. if the closest commit is from same source project merge then first algorithm case will be used.
  2.  The second algorithm will be used if previous target project commits were not set as latest or revert commits; does not have merge commits of the same source project.