What is a Cherry Pick Merge, and why do you recommend against them?
When you merge in TFS 2010, you have two choices:
- Merge all changes up to a specified version, which can be one of the following:
- Latest Version
- Workspace Version
- Or, merge Selected Changesets, where you select one or more changesets from a list of changesets that are in the source branch and not yet merged into the target branch of the Merge.
The latter option (selected changesets) is also called a Cherry Pick merge.
One problem with Cherry Picking, is changesets are not always granular enough. Consider a change where you added three new files. A second change where you modified two of the three. A third change where you modified a different two, and so on. How can you ensure that you pick all the changeset (and only the changesets) to get the changes you need into the merge without picking too little or too much.
Secondly, if you are doing Cherry Picking, it can be challenging to figure out exactly which changesets you want to merge. What if the developer didn’t put very descriptive comments on the changeset when checking-in changes. Do you need to look at individual files within individual changesets to decide to merge or not merge that specific changeset?
There is always a risk that when you do Cherry Picking, that the target branch will not build properly until you either pick additional changesets, or make manual changes to the files in the target branch to get to a successful build, or even to get to a code state that works. This is particularly a problem when the Main (stable) branch is the target of the merge. We try to recommend branching and merging approaches that keep Main as stable as possible.
Cherry Picking individual changesets for a merge may also leave you with a very confusing change history on the target branch. It is possible that the same code change is Cherry Picked multiple times over several merges.
How can you ensure that you pick all the changeset (and only the changesets) to get the changes you need into the merge without picking too little or too much. It is not as easy as you think.
Some have suggested that the challenges to being able to easily cherry pick changes for a merge is a deficiency of TFS. TFS does indeed make selecting candidate changesets for a merge rather easy. That is not the challenge. The challenge is being able to select the right changesets.
The challenge is somewhat like following a recipe for baking a cake:
In a medium bowl, cream together 1 Cup sugar and 1/2 Cup butter. Beat in 3 eggs, one at a time, then stir in 2 teaspoons vanilla. Combine 1 1/2 Cups all purpose flour and 1 3/4 teaspoons baking powder, add to the creamed mixture and mix well. Finally stir in the milk until batter is smooth.
Oh, sorry. I meant to say: Beat in 2 eggs. Go ahead and remove one of the eggs from the cake batter. Simple, right?
You can download the Microsoft VS ALM Rangers Branching Guidance here: http://tfsbranchingguideiii.codeplex.com/