Moving individual changes between different branches isn’t difficult but can quickly become a headache to keep track of when dealing with many branches and changesets. Fortunately Visual Studio 2010 has some great tools to track the path of changes across a set of TFS branches.
To begin we can look at the branch structure to get an idea of how everything is related. This view can be accessed from Source Control Explorer by clicking on a branch (MAIN here) and selecting Branching and Merging->View Hierarchy. From this we can see that there is a MAIN branch with Dev and Release branches off of it, each with their own sub-branches.
Now if I want to see the state of a changeset across branches I can right click it in the History and select Track Changeset. I can choose which branches I want to look at and get a mini-preview of the above diagram to make them easier to identify:
I’m going to start by tracking my initial project check-in and looking at it across all of my branches. Notice that the changeset numbers are included on each branch node.
To get an alternate view I can click the Timeline Tracking button up top. This makes it easier to see the order of migration of the changeset across the different branches as well as giving a time context.
For more complex scenarios, there will probably be times when only parts of a changeset get merged, or multiple changesets get merged at once. In these cases you get some new details in the visualizations. Here the partially colored nodes indicate that content of the final changeset 39 is slightly different than the files in the 33, 34 and 35 check-ins, probably due to some merging of edit conflicts. Also note that here I’ve selected the Release node which has highlighted the arrows for the path of the merges in green.
The timeline view also becomes more interesting as we can see multiple changesets per branch and the same coloring as in the hierarchy view.
Where this really comes in handy is in making sure code has made it into the right branches. Here’s a check-in that was made in preparation for a release. I can see that both 40 and 41 made it into MAIN and will be included when I merge over to Release. I could get similar information by tracking 40 or 41.
But I have another late change that I made in changeset 43 and may not know if that made it into a merge. According to the tracking, it didn’t get merged yet so I need to make sure to get it over to MAIN before the release goes forward.
Aside from looking at individual changesets I can also get an overall view of how different branches are different or how a single branch has changed over time using the Compare function. I use Compare frequently with individual files, but there’s a separate mechanism that works with whole folders. It can be accessed in a few different places, including the right-click menu in Source Control Explorer. Here’s the window with all the options, filled out to do a comparison of the server versions of two different Releases which I have labeled v1.0 and v3.0.
And the resulting comparison gives me a list of added, removed, and changed files across the entire Release branch folder structure. I can also right-click on any changed files to get a side by side comparison of the file contents.