Inside VSTS
Branching in Visual Studio 2010
The new branch visualization feature brings order to the chaos of branching and merging.
- By Jeff Levinson
- 12/01/2008
Every once in a while, I like to talk about upcoming features in Visual Studio 2010. Even though it's a ways off, it's good to know where the tool is heading and how it can make your life easier.
Take branching and merging; this is already difficult enough. One limitation in Team System today is that you can't easily visualize your branching structure so it's difficult to understand the movement of code from branch to branch. Fear not -- branch visualization is here!
Before we go any further, note that this is based on pre-release software (October CTP) and, as such, is subject to change.
Now, the problem with branching in TFS is that you can't "see" what you're doing. If you're like me (I'm a very visual person), pictures can communicate ideas much more succinctly than explanations. That's where VS 2010's branch visualization comes in.
Let's take the following scenario: I want to know the history of changeset 24. Looking at a list of information, I could see that changeset 24 included code from changeset 9 and that code from changeset 24 was included in changeset 29. Changeset 9 was on the integration branch and it moved the main branch which created changeset 24. Likewise, changeset 29 was the result of a merge from the main branch to the test branch. (Have I lost you yet? Because I'm confused and I wrote it!)
Now, take a look at Figure 1, which shows the visualization view of changeset 24. Much easier to understand, isn't it? It also tracks changes to changeset 9 because that code was also involved in changeset 24.
To get to the branch visualization, you need to view the history of a given item. Branch visualization is designed to allow you to trace changesets across branches. In order to get to the point where you can visualize the changeset, you need to view the history of the given item. Figure 2 shows the new history dialog (note also that you can easily see the labels in which the file participates). As a side note, the history view now shows you the history across branches -- a view you don't get in TFS 2008 unless you use the history power tool.
Let's take a more expansive look and check out the details of changeset 29 (Figure 3). You can see how this would be incredibly difficult to put into words. This view allows you to communicate the movement of code with very few words but still get a clear understanding of what went where. But that's not where visualization stops -- it's merely the beginning. You can also get a view of the overall branching hierarchy in your application (Figure 4).
But wait...in true Ginsu commercial fashion, there's more! You can actually work with this diagram. Through it, you can perform comparisons between changeset versions on different branches, create new branches (another cool feature of 2010 is server-based branching, which is incredibly fast because you don't have to have the files on your local machine), merge two branches together, set branch permission, or view the changeset files in Source Control Explorer.
Part of this is made possible because branches are now what are called "first-class citizens" in TFS. That is, they're treated as special entities. In TFS 2005 and 2008, you'll note that branches are denoted by a folder icon and you can't perform any specific branch-related commands on just those items (it's also time-consuming to determine what's a branch and what's a folder). In 2010, you need to specify what the root branch is (and when you create new branches, they're automatically marked as such).
About the Author
Jeff Levinson is the Application Lifecycle Management practice lead for Northwest Cadence specializing in process and methodology. He is the co-author of "Pro Visual Studio Team System with Database Professionals" (Apress 2007), the author of "Building Client/Server Applications with VB.NET" (Apress 2003) and has written numerous articles. He is an MCAD, MCSD, MCDBA, MCT and is a Team System MVP. He has a Masters in Software Engineering from Carnegie Mellon University and is a former Solutions Design and Integration Architect for The Boeing Company. You can reach him at [email protected].