Question

When merging file in visual studio I use a 3 way merge tool. In the visual studio options under Source Control > Visual Studio Team Foundation Server > Configure User Tools I have the option to add a Base file (%3) in as an argument to be passed to the merge tool.

How does Visual Studio/TFS work out what the base file is?

If I merge file X from branch A to branch B am I right in thinking:

  • The modified file is file X from the changeset I'm merging from branch A
  • The original file is file X from the last changeset where file X was changed in branch B
  • The base file is file X from newest changeset where file X was checked in before the changeset I'm merging

Is this logic correct?

Was it helpful?

Solution

The "base file" is more commonly called the "common ancestor". It is the version of file X that most recently existed in both branches.

When you first create some branch, let's say $/A to $/B as changeset 10, then file X has not yet been modified in either branch. In this case, the common ancestor is equal to both the versions in branch $/A and $/B.

If you were to then change $/A/x as changeset 11 and $/B/x as changeset 12, your common ancestor would remain changeset 10. This will allow you to determine how each branch has changed independently from the base.

Now when you perform a merge from $/B back to $/A as changeset 13, you have deemed x to be merged and the common ancestor resets. Subsequent merge operations will take changeset 13 to be the new base so that only subsequent changes made in the two branches will be merged.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top