concept check - in policy in category system administration

This is an excerpt from Manning's book Team Foundation Server 2008 in Action.
TFVC supports check-in policies that help protect the integrity of the codebase. Check-in policies help ensure that the code being checked in meets appropriate quality criteria. The quality criteria may include passing static code analysis, associating check-ins with work items, and so on. You can also create custom check-in policies and implement your own change control criteria. If a developer checks in code by overriding a policy, TFVC can send out an email alert containing the reason. The policy override information is also recorded in the data warehouse, allowing the creation of reports to track the action.
In this chapter, you’ll learn about access control policies and check-in policies. Access control policies determine who can access a branch and what kinds of actions they can perform. Check-in policies specify the preconditions that must be satisfied before code can be committed in a branch. Most of this chapter is devoted to check-in policies, since there’s a lot to learn about how they’re created and enforced.
Listing 5.4. Source code for the Edit dialog box (private methods only)
/// Initializes the branch list when /// the form is loaded. private void pInitBranchList() { foreach (BranchPolicies branchPolicies in _clonedBranchPoliciesCollection) { lstBranchList.Items.Add(branchPolicies.BranchName); } } /// Searches through all branch policies in the List. /// If a match is found with the name of the branch, /// returns the corresponding branch policy. private BranchPolicies pSearchBranchInCollection( IList<BranchPolicies> branchList, string branchName) { BranchPolicies returnedPolicies = null; foreach (BranchPolicies branchPolicies in branchList) { if (branchPolicies.BranchName == branchName) { returnedPolicies = branchPolicies; break; } } return returnedPolicies; } /// Searches a check-in policy in a specified branch. /// If found, returns the index of the /// policy in the branch, otherwise returns -1. The search /// is conducted based on the input policy name. private int pSearchPolicyInBranch( BranchPolicies branchPolicies, string policyName) { int index = -1; if (branchPolicies == null) return index; for (int i = 0; i < branchPolicies. AssociatedPolicies.Count; i++) { if (branchPolicies.AssociatedPolicies[i].Type == policyName) { index = i; break; } } return index; } /// Sets policies associated with a specific branch. private void pSetAssociatedPoliciesInList (string branchName) { lstBoxInstalledPolicies.Items.Clear(); BranchPolicies branchPolicies = pSearchBranchInCollection( _clonedBranchPoliciesCollection, branchName); if (branchPolicies != null) { foreach (IPolicyDefinition policyDef in branchPolicies.AssociatedPolicies) { lstBoxInstalledPolicies.Items.Add( policyDef.Type); } } } /// Enables or disables the controls for adding a branch. private void pEnableAddBranchControls(bool enable) { panel3.Enabled = enable; panel1.Enabled = !enable; panel2.Enabled = !enable; } /// Validates the branch path specified by the user. private bool pValidateBranchPath(string path) { VersionControlServer vcServer = _teamProject.VersionControlServer; try { Item item = vcServer.GetItem(path); if (item != null && item.ItemType == ItemType.Folder) return true; else return false; } catch (Exception ex) { return false; } } /// Clones branch policies from a collection of policies. /// This is done to keep the original collection unchanged. private void pCloneOriginalToClonedCollection() { foreach (BranchPolicies branchPolicies in _originalBranchPoliciesCollection) { _clonedBranchPoliciesCollection.Add( branchPolicies.Clone() as BranchPolicies); } } private void CustomCheckinPolicyEditDialog_Load( object sender, EventArgs e) { } }