When I first looked at the Source Control Explorer in TFS 2012, the thing I noticed first was the introduction of the “Reparent” Menu option in the context menu.
I know that this is not new, It was there in Visual Studio 2010 as well only it was hidden away deep down in the file menu.
I will be honest, until a few weeks ago I never used it. I did not have a scenario where this was handy and I could not really understand why someone wanted to Reparent a branch.
The scenario I had was actually pretty obvious. For the purpose of this blog I simplified it a bit but it is still the same thing.
Imagine you have a Generic Component. This is used in several project. You created a branch of a version of this Generic Library. As you can see in the picture below. The Generic MAIN was release to Release 2.0 and this Release is now used in a project.
In the meanwhile, people worked on Version 3.0 of the Generic Libraries. This was released before the project was finished. The project now wants to use the newest version of the Generic Libraries. This is scenario that makes sense.
When I came across this, I thought of the Reparent option. Just Reparent the Project Branch to the 3.0 Release and Voila! All Fine.
Almost …..but not really..
How Reparenting works
When you click reparent on the target branch, you initially see the following picture.
That is strange. How can you point to another parent then? The solution is baseless merging. First you do a baseless merge of the new parent to the target branch. With this action you set “a” relation between the 2 branches.
Baseless merge is something you do from a command prompt. Open a Visual Studio Command prompt, navigate to the workspace directory of your new parent branch and execute the following command
tf merge /recursive /baseless "$/GenericLibraries/RELEASES/GENERIC LIB RELEASE 2.0" "$/BranchProject/GENERIC LIB – Branch Project"
After this action you have pending changes. Check in the changes and view history on your target branch. You will see the merge action. When you choose “Track Changeset” on the merge action you see a nice picture drawn of you latest actions.
Now the relation is put into place, select the target branch and select the “Reparent” option (VS 2010 file menu, VS2012 Contect Menu—See above). This shows the current parent and the new parent. Select the new parent and press “Reparent”.
After this action the new parent is set.
Hope this helps!