MSDN Magazine Launch Issue - February 15, 2008 - (Page 125) Check-In Notes and Policies BRIAN A. RANDELL B ack in the January 2007 installment of this column, I started a discussion on using the Team Foundation Server (TFS) version control APIs from a Microsoft® Word 2003 add-in. Here I am, more than a year later, with the fifth and final part dedicated to the version control APIs and the Word add-in. (I really didn’t think it would take this many installments.) You may recall from earlier columns that the add-in currently supports check-in, check-out, undo pending changes, and the ability to associate work items with a check-in. In my most recent column, I examined check-in notes and check-in policies. This month, I will show you how to add check-in notes and check-in policy support to the Word add-in. In addition, you’ll learn about how to deal with check-in conflicts. And if you haven’t read the rest of this series (listed in the “First Four Parts of This Series” sidebar), be sure to check them out. Figure 1 Results from Calling GetCheckinNoteDefinitions Check-In Note Name Code Reviewer Code Reviewer Performance Reviewer Performance Reviewer Security Reviewer Security Reviewer Team Project MSF-Agile MSF-CMMI MSF-Agile MSF-CMMI MSF-Agile MSF-CMMI Check-In Notes Check-in notes are free-form text fields that you can associate with a check-in. You can mark check-in notes as mandatory and control the order in which they appear in the Visual Studio® checkin dialog. In order to mimic this behavior in the Word add-in, you should get the list of check-in notes for the active team project, sort the list, and display a label and textbox for each check-in note. The VersionControlServer object exposes the GetCheckinNoteDefinitions method, which accepts an array of team project names and returns an array of CheckinNoteFieldDefinition objects. Each CheckinNoteFieldDefinition instance exposes properties for checkin note name, display order, whether it’s required, and a server item string. GetCheckinNoteDefinitions returns the list of items in what appears to be a seemingly random order. In my tests, I found that notes are returned sorted by check-in note name and grouped by team project name no matter what order the team project references are passed into the method. Thus, assuming there are two team projects defined, one called MSF-Agile and one called MSFCMMI with the default set of notes, the results would appear as shown in Figure 1. And if you created a new check-in note called Build Master and added it to the MSF-CMMI team project, it would appear first in the list. The tfsVCUtil class, created for the Word add-in, has two new shared methods that you can use to retrieve check-in notes: GetAllCheckInNotesByTeamProjectName and GetAllCheckInNotesByItemLocalPath. Using either of these methods, you can get the unmodified list of CheckinNoteFieldDefinitions, if any, for the team project. Supporting check-in notes on the check-in dialog requires that you add an extra toggle button under the existing work items button, an extra panel to act as a container, and a label and textbox for each check-in note. (The code download provides a simple implementation.) However, adding support for check-in notes to the check-in dialog is just one piece of the puzzle. You also need to add code to enforce required notes. Check-in policies and conflict detection require that you make additional changes to how the check-in dialog and supporting code in the tfsVCUtil class work. Check-In Policies Just as with check-in notes, the first order of business for supporting check-in policies is figuring out what policies are enabled for the active team project. The second order of business is deciding how to process check-in policies. Because Microsoft designed check-in policies primarily for developers checking in code from Visual Studio, two of the three built-in policies that ship with TFS 2005 don’t work correctly when used to a validate a check-in for First Four Parts of This Series Team Foundation Server Version Control (January 2007) msdn.microsoft.com/msdnmag/issues/07/01/TeamSystem Work Item Tracking (April 2007) msdn.microsoft.com/msdnmag/issues/07/04/TeamSystem Work Items and Undo Support (September 2007) msdn.microsoft.com/msdnmag/issues/07/09/TeamSystem Custom Check-in Policies (November 2007) msdn.microsoft.com/msdnmag/issues/07/11/TeamSystem launch2008 125 http://msdn.microsoft.com/msdnmag/issues/07/01/TeamSystem http://msdn.microsoft.com/msdnmag/issues/07/04/TeamSystem http://msdn.microsoft.com/msdnmag/issues/07/09/TeamSystem http://msdn.microsoft.com/msdnmag/issues/07/11/TeamSystem
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.