There's a great but lengthy article named 'Team Foundation Server Branching Guidance' at http://www.codeplex.com/BranchingGuidance. I'm going to summarize the article here, to help myself and others quickly get up to speed on branching in TFS.
Definition of branching: a branch is a self-contained snapshot of the code that has access to all of the required sources, tools, dependencies, and process automation. Branching is synonymous with isolation. Two branches are created when branching: the parent and the child. The parent is the original source code, while the child is the copy of the source code. After changes have been made, the source code copy (child branch) can be merged or integrated back into the parent branch.
There are multiple levels of isolation in TFS:
- Isolation on an individual level
- Implemented in Visual Studio 2005 using source control workspaces
- Workspaces are mapped to and managed by TFS
- Allows the developer to shelve their code
- Isolation for collaboration
- Managed on the server
- Allows teams of developers to work on a child branch of source code
Branching occurs in a TFS "path space", which is like copying a folder in Windows Explorer. The benefit that TFS provides, though, is it maintains the history of the child branch to the parent branch. This allows TFS to merge changes that are made in both branches.
New branches appear in the Source Control Explorer just like other source code. When you need to work on another branch, just get that folder in the Source Control Explorer.
Creating a Branch
- Open the Source Control Explorer in VS 2005
- Right-click the folder you would like to branch in the folders treeview
- Click Branch...
- Type a name for the branch in the Target textbox
- Choose to branch by date, label, or the latest server version
- Click OK to create the branch
More info on branching: http://msdn2.microsoft.com/en-us/library/ms181423(VS.80).aspx
Merging
Merging combines the source code of the child and parent branches. In files where changes were made to only the child or to only the parent, TFS will combine the changes automatically. When source code is modified in the same files, a version conflict will be filed, and the changes will need to be merged by the developer using TFS's merge tool.
To Merge:
- Open the Source Control Explorer in VS 2005
- Right-click the folder you would like to branch in the folders treeview
- Click Merge...
- Browse to a Source branch
- Choose 'All changes up to a specific version' or 'Selected changesets'
- Choose an item in the Target branch dropdown
- Click Next for more options or Finish to begin the merge process
Branching Scenarios
- Release Isolation
- Allows the developers to work on multiple releases in parallel
- Feature Isolation
- Used when new functionality may introduce risk
- Allows developers working on new functionality to collaborate without exposing the rest of the application to instability
- Team Isolation
- Used to shield one team from being subjected to another team's breaking changes
- Integration Isolation
- A new "integration branch" is created that serves as a staging area for merges
- The "integration branch" is not used for development
- Changes from other branches can be merged into the integration branch and then stabilized
- Once the integration branch is stable, the changes can be merged back into other branches
What is your experience with branching in TFS? Please post in the comments below.
Update (6/15/2007):
I have now successfully branched my first piece of code. We have a project at work that has a production release (version 2.4.9.1) that has been in use for a while on the floor. Since version 2.4.9.1 was released to production, we have added a large number of features, and the testing version is up to version 2.4.15.1. We found a major bug in version 2.4.9.1, and, instead of attempting to fix the bug in version 2.4.15.1 and releasing an untested version with a couple of month's worth of code changes, we branched 2.4.9.1 and created 2.4.9.2. The branched version quickly passed tests by the quality assurance department, and was released to production. A few days later, we talked to the business users, and they reported no issues with version 2.4.9.2.
No comments:
Post a Comment