TFS 2010 Version Control: Branching and Branch Hierarchy

Posted by: Subodh Sohoni , on 6/18/2009, in Category VSTS & TFS (Azure DevOps)
Views: 74398
Abstract: One of the features of TFS 2008 I found interesting is ability to view branch hierarchy. The way branching process behaves in TFS 2010 is different than the way it behaves in 2008.
TFS 2010 Version Control: Branching and Branch Hierarchy
One of the features of TFS 2008 I found interesting is ability to view branch hierarchy. The way branching process behaves in TFS 2010 is different than the way it behaves in 2008. When we create a branch in TFS 2010 it just creates a folder of the branch with the name that we give to the branch. I created a code to check if that folder is treated as a branch or not:  
public List<string> GetBranches(string SelectedTeamProject, string RootName)
   List<string> branches = new List<string>();
   ItemIdentifier ii = new ItemIdentifier("$/" + SelectedTeamProject + "/" + RootName);
   BranchObject[] branchObjects = tfvc.QueryBranchObjects(ii, RecursionType.Full);
   for (int i = 0; i < branchObjects.Length; i++)
   return branches;
Public Function GetBranches(ByVal SelectedTeamProject As String, ByVal RootName As String) As List(Of String)
   Dim branches As New List(Of String)()
   Dim ii As New ItemIdentifier("$/" & SelectedTeamProject & "/" & RootName)
   Dim branchObjects() As BranchObject = tfvc.QueryBranchObjects(ii, RecursionType.Full)
   For i As Integer = 0 To branchObjects.Length - 1
   Next i
   Return branches
End Function
I found that newly created branch does not get added to the BrachObjects array. By the way QueryBranchObjects and BrachObject are new set of APIs I have seen and they reduce the code considerably. We can use this code for identifying a branch which can be built in the application for custom build creation and execution through code.     
 After the branch is created but appears as folder,  we can right click that folder and convert it to a branch. In the above picture, WISpawner is shown as a plain folder and then in the picture below I have right clicked on it and selected to convert it to a branch. In the next picture you can see that it has got converted to a branch along with its child branch.
There is an option to convert the branch back to folder if necessary. Another option is to re-parent the branch which works for only the linear descendant.
A feature which was very much in demand which is added now is the hierarchy view of the branch structure. We can select any branch and in the context sensitive menu (right click menu) get the option to view the hierarchy. By default the hierarchy show is for ancestors – descendants of the selected branch but we have the option to select other types of relations like Parent – Child, only ancestors or only descendants etc. View can even be customized to show only specific branches instead of all fitting the filter.  A nice graphical view shows the hierarchy of branches. This is the logical view of branch structure of source control whereas what we see in the source control editor is the physical view.
Branch properties now have some additional options which can provide us the access to the metadata of the branch. It has options to view and change Owner of the branch, view relations of the branch and permissions to users to modify branch. By default it is the user who created the branch but may be edited. Relations tab provides the view of parent – child view of all branches. Matt Mitrik, Program Manager, TFS, Version Control in his blog has mentioned that it is the base for view of the branch hierarchy in the logical view.
A very neat feature which I had not seen earlier is branch comparison. We can select any branch in the team project and compare it with any other branch in the same team project. Option is available to select branch in the local folder or server item. It is also possible to select any version of the branch depending upon date, label, changeset etc. and compare it with the other branch.
The view shows statistics of how many branches were compared and how many of them are same and how many are different. It also shows the files which are different with a red color.

Summary: In this article we have seen various new features related to branching in TFS 2010. We have seen the new objects to access the branches in Team Foundation Version Control APIs which can be used in other applications. We have also covered branching hierarchy and its view. Finally we have seen how to compare two branches or versions of branch through branch compare tool. 

If you liked the article,  Subscribe to the RSS Feed or Subscribe Via Email 
Subodh Sohoni is MCTS - Microsoft Team Foundation Server - Configuration and Development and also is a Microsoft Certified Trainer(MCT) since 2004. Subodh works as VP, Technology with SEED Infotech Ltd 

This article has been editorially reviewed by Suprotim Agarwal.

Absolutely Awesome Book on C# and .NET

C# and .NET have been around for a very long time, but their constant growth means there’s always more to learn.

We at DotNetCurry are very excited to announce The Absolutely Awesome Book on C# and .NET. This is a 500 pages concise technical eBook available in PDF, ePub (iPad), and Mobi (Kindle).

Organized around concepts, this Book aims to provide a concise, yet solid foundation in C# and .NET, covering C# 6.0, C# 7.0 and .NET Core, with chapters on the latest .NET Core 3.0, .NET Standard and C# 8.0 (final release) too. Use these concepts to deepen your existing knowledge of C# and .NET, to have a solid grasp of the latest in C# and .NET OR to crack your next .NET Interview.

Click here to Explore the Table of Contents or Download Sample Chapters!

What Others Are Reading!
Was this article worth reading? Share it with fellow developers too. Thanks!
Share on LinkedIn
Share on Google+

Subodh is a consultant and corporate trainer. He has overall 28+ years of experience. His specialization is Application Lifecycle Management and Team Foundation Server. He is Microsoft MVP – VS ALM, MCSD – ALM and MCT. He has conducted more than 300 corporate trainings and consulting assignments. He is also a Professional SCRUM Master. He guides teams to become Agile and implement SCRUM. Subodh is authorized by Microsoft to do ALM Assessments on behalf of Microsoft. Follow him on twitter @subodhsohoni

Page copy protected against web site content infringement 	by Copyscape

Feedback - Leave us some adulation, criticism and everything in between!
Comment posted by Greg Billour on Monday, June 22, 2009 1:51 AM
I didn't know this feature existed. 5 Stars.





C# Book for Building Concepts and Interviews



jQuery CookBook