Wednesday, May 8, 2013

Baseless merge!


Baseless merge in TFS ? or a Baseless Question? :-)


A colleague came over wondering for what someone asked him to do - and that is to merge two branches. I believe, the tool allows you to do that however, I wouldn't recommend it simply because it is a sort of sibling-sibling merge rather than (what it is intended for) parent-child merge.


Reference to support my perspective ...

How do I merge two branches?

To perform a merge, you can use the merge functionality in Source Control Explorer, or you can use the merge command-line tool. You can merge based on changeset, label, date, or version.
You might find that your branching structure becomes deeper than one level. If this happens, keep in mind that it is only possible to merge one level at a time. For example, consider the following source tree structure:
  • Development – Container for isolation development branches.
    • Feature A
      • Source
    • Feature B
      • Source
  • Main – Main integration build branch
    • Source
    • Other asset folders
  • Releases– Container for Release branches
    • Release 1
      • Source
    • Release 2 – Current release being locked down
      • Source
When the source code contained in the Release 2 branch changes, you might want to eventually merge that change into a Feature branch; for example, to incorporate a bug fix into the latest feature code. It is not easy to merge directly from Release 2 into Feature B; instead, you merge from Release 2 into its logical parent, Main, and then from Main into its logical child Feature B. If you need to merge between branches that do not have a direct parent-child relationship, you need to perform a baseless merge.


O.K., so what is a baseless merge?


The branch command will create a relationship between two folders. You can leverage this connection to perform merges of code between the branches. Branches that are not a direct child or a direct parent of the merge target do not have this relationship. As defined in MSDN, a baseless merge “performs a merge without a basis version. That is, allows the user to merge files and folders that do not have a branch/merge relationship. After a baseless merge, a merge relationship exists and future merges do not have to be baseless”.
A baseless merge will result in many more conflicts than a normal merge. However, after the first baseless merge, future merges between these branches will no longer be baseless, thus minimizing conflicts.
Baseless merges can only be created from the command line. Even after the first baseless merge, when a relationship has been created between the branches, future merges still need to be created from the command line.

No comments:

Post a Comment