Merge / Branch Only Check in Policy
At my workplace, we have two main branches in TFS, Production (our trunk
branch), and QA (our testing / release branch). One or more development branches
are taken from QA, and users code against these development branches. When it
comes to testing time before a release, we lock down the development branch to
everyone except senior developers, who can check changes in on other people's
behalf (for last minute important fixes), and users begin merging their changes
into the QA branch.
The problem is, there is a tendency for people to 'sneak' changes directly
into the QA branch, and merge them back to development after the code freeze.
This is potentially dangerous, as the changes will not have been tested properly
or built against all other code. Considering the QA branch had to allow check in
and out permissions to allow people to merge their changes, and in the absence
of some way of stopping people directly checking in to the Production and QA
branches, I wrote a custom check in policy to block check ins that are not part
of either a branch or merge operation
The policy can be downloaded below, and needs to be installed on the TFS
server and all developer client machines.
Merge / Branch Only Check in Policy (TFS 2005)
Merge / Branch Only Check in Policy (TFS 2010)
Merge / Branch Only Check in Policy (TFS 2012)
The policy can be limited to particular branches in source control using
version 1.2 of the Team
Foundation Server PowerTools. As above, the PowerTools need to be installed
on the TFS server and all client machines.
To set up the Merge Only policy limited to a path:
- In Team Explorer, right click the project you want to work with and
select 'Security Settings / Source Control':
- In the Checkin Policies tab, click Add, and select the 'Branch and Merge
Only' policy. Click add, highlight the new policy, and click the disable
- Click OK to save the settings, and then reopen the source control
security dialog as in step 1
- Click add again, and add the 'Custom Path Policy'
- A new dialog will appear prompting you for settings for the custom path
policy. In the drop down menu, select the Branch and Merge Only policy, and
then add regular expressions to denote which path(s) you would like the
policy to apply to.
- Click OK, and then OK again to save the settings
Now, if a user attempts to check changes in directly to the path you have
specified, they will be confronted with a policy failure warning dialog. What
you do to people who override the policy is up to you!
Should you need to play around with the source code, the .vb file can be
downloaded below. Note that you need to create a VB.NET class library project
and import this file, and you need to add a reference to
Microsoft.TeamFoundation.VersionControl.Client.dll to your project.
Download Source Code
© Leon Mayne 2007