390 likes | 1.03k Views
Microsoft Developer’s Guide to Team Foundation Version Control. Ed Hintz and Buck Hodges. Agenda. Introduction Dogfood and Performance Statistics Feature overview Scenarios Visual Studio Command line SDK and Extensibility. Work Item Tracking. Version Control. Reporting.
E N D
Microsoft Developer’s Guide to Team Foundation Version Control Ed Hintz and Buck Hodges
Agenda • Introduction • Dogfood and Performance Statistics • Feature overview • Scenarios • Visual Studio • Command line • SDK and Extensibility
Work Item Tracking Version Control Reporting Team Communications Build Automation What is VS Team Foundation? Integrated Platform for Collaborating on Software Development Projects.
Microsoft VSTS Dogfooding Version Control Version Control Users: 864 Number of Files/Folders: 1,507,247/178,953 Compressed File Size: 95.2 GB Workspaces: 1,770 Workspace File Versions: 48.9 Million Changesets: 32,573 Pending Changes: 57,278 Shelvesets: 2,458 Source: http://blogs.msdn.com/johnlawr/archive/2006/02/16/533362.aspx Latest: http://tfsserver:8080/VersionControl/v1.0/administration.asmx/QueryRepositoryInformation Copenhagen, Denmark6 Users Fargo, ND4 Users Redmond, WA368 Users Research Triangle, NC42 Users Hyderabad, India14 Users
Source Control Feature Support • Atomic Checkin • Integrated with Visual Studio • Work Item Integration • Customizable Checkin Experience • Checkin Policies • Checkin Notes • Shelving • Delta File Storage • Large File Support (>4GB)
Source Control Feature Support • Distributed Team Support • E-mail Checkin Notification • Merge and Diff Tool Configurable (see http://blogs.msdn.com/jmanning/articles/535573.aspx for common tool settings) • SDK and VS Extensibility • MSSCCI Plugin as Powertoy – (VS2003, VB and VC6)
Team Foundation Client Tier Version Control Proxy Build Machine Report Client App Tier Standby Server Team Foundation App Tier Team Foundation Data Tier Architecture MDAC
TFS Concepts: Workspace • Local copy of files under SCC • Isolates developer from other changes • Maps repository paths to local paths • Mappings can be scattered around local machine • Allows for cloaked paths • Server maintains inventory • Tracks file versions and local paths
TFS Concepts: Changeset • Set of committed modifications • Add, rename, delete, etc. • Atomically applied to repository • Associated with work items at checkin • Convenient unit for change management
Checkin 3 Update Work Items Artifact Link 2 1 Validate Policies Commit Changes Checkin Policy Engine Changeset 727012 WI Association Unit Testing Static Analysis Custom Policy 4 Check E-mail Notification Events Raised for 3rd party sync purposes Checkin - Under the Hood Visual Studio WorkItem 33231 Work Item Tracking Workspace Change Set 727012 Change Set 727012 Change Set 727012 Change Set 727012 Change Set 727011 V2 V1 V5 V3 V4 V5 Version Control Integration Infrastructure
Getting started • Create a workspace, set mappings • For example, use /template to start with working folder mappings.tf workspace /template:WorkspaceName;username WS1 /s:http://tfsserver:8080 • Configure diff and merge toolstf diff /configure • Get the files from the servertf get • Edit a filetf edit foo.cs • Check intf checkin
Command line dialogs • We provide dialogs for commands involving complex input or data display (use /i to suppress) • Changeset • Checkin • Difference (external diff viewer) • Get (conflict resolution) • History • Resolve • Shelve • Unshelve • View (associated editor) • Workspace
Shelvesets • Shelvesets are collections of pending changes, comments, and associated work items • Scenarios • Backuptf shelve /i MyWork • Temporarily move changes to work on a different issuetf shelve /i MyWork /move • Remote code reviewstf unshelve CoolStuff;joe • Buddy builds or coordinate changestf unshelve CoolStuff;joe
Shelvesets • List shelvesetstf shelvesetstf shelvesets /owner:joe • Delete a shelvesettf shelve /delete MyShelveset • List the pending changes in a shelvesettf status /shelveset:MyWork;joe • Diff the changes in a shelvesettf diff /shelveset:MyWork;joe
Notes • To move your workspace, change your mappings (tf workspace) and then run get • To handle changing computer names:tf workspaces /updateComputerName:oldName /s:http://tfsserver:8080 • To handle changing user names:tf workspaces /updateUserName:oldUserName /s:http://tfsserver:8080 • Renaming files • Don’t overdo it, or your branch merges will be more tedious (for example, renames in both the source and target)
Performance Tweaks • Use a version control caching proxy server in remote offices • Command line • Set the BypassProxyOnLocal registry entry (see http://blogs.msdn.com/buckh/archive/2005/12/12/503015.aspx for details) • On my laptop today, ByPassProxyOnLocal saved 2 seconds (my IE settings are Automatically Detect) • Visual Studio • Change the registry setting not to automatically get missing files (see http://blogs.msdn.com/hippietim/archive/2006/03/14/551320.aspx for details)
Commands • Command line reference: http://msdn2.microsoft.com/en-us/library/cc31bk2e(vs.80).aspx • Command line command and option summary: http://blogs.msdn.com/buckh/articles/CommandLineSummary.aspx
Client API • The Team Foundation Server client object model is a set of .NET 2.0 assemblies • There are public APIs for version control, work item tracking, build, reporting, and more
Visual Studio IDE External tool (Partner or MS) Team Foundation Object Model Work Items Version Control TeamBuild Integration Interface Integration Interface Integration Interface Registration Service Notification Service Linking Service User Groups Service Common Structure Service How It Happens:Team Foundation Core Services Team Foundation Core Services Team Foundation Server
Version Control Client API • The primary objects are • TeamFoundationServer – this is the root object from which you obtain a service, such as version control or work item tracking • VersionControlServer – this is the primary interface to the version control server for operations and queries that are not specific to a workspace • Workspace – this object represents a workspace and is used to pend changes, check in changes, and perform queries specific to a workspace • Workstation – this object represents the current computer and manages the workspace cache, which contains the list of local paths in each workspace
Code Sample TeamFoundationServer tfs = new TeamFoundationServer("http://tfsserver:8080"); // Get a reference to Version Control. VersionControlServer versionControl = (VersionControlServer) tfs.GetService(typeof(VersionControlServer));
Code Sample // Determine the server and workspace based on the local path mapping. WorkspaceInfo wsInfo =Workstation.Current.GetLocalWorkspaceInfo(Environment.CurrentDirectory); // Stop if we couldn't figure out the workspace. if (wsInfo == null) { Console.Error.WriteLine("Unable to determine the workspace."); Environment.Exit(1); } // Get a reference to our Team Foundation Server. TeamFoundationServer tfs = new TeamFoundationServer(wsInfo.ServerUri.AbsoluteUri); // Get a reference to the workspace. Workspace workspace = wsInfo.GetWorkspace(tfs); // Update this workspace. workspace.Get();
API Code Samples • Basic Team Foundation Version Control client API examplehttp://blogs.msdn.com/buckh/archive/2006/03/15/552288.aspx • Displaying the labels on a file, including label commentshttp://blogs.msdn.com/buckh/archive/2005/10/25/484854.aspx • Displaying the sizes and dates of files in the serverhttp://blogs.msdn.com/buckh/archive/2005/10/26/485458.aspx • Sample checkin policy: make sure the comment isn't emptyhttp://blogs.msdn.com/jmanning/archive/2006/01/21/515858.aspx • Show all pending changes on the Team Foundation server older than a given agehttp://blogs.msdn.com/jmanning/archive/2005/12/01/499033.aspx • Scanning history for the changesets that had policy override - simple usage of QueryHistoryhttp://blogs.msdn.com/jmanning/archive/2005/11/04/489193.aspx
VS Extensibility • Allows customers to extend the functionality of TF SCC in Visual Studio via add-ins and packages • Provides access to the following: • Source Control Explorer selection and events • Pending Changes selection and events • Solution Explorer and SCC Explorer workspace • History selection • Changeset details dialog • Shelveset details dialog
VS Extensibility • All class names start with Microsoft.VisualStudio.TeamFoundation.VersionControl • Use the VersionControlExt object to get to the others: • vce = _applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;
VS Extensibility Demo How to Write a Team Foundation Version Control Add-in for Visual Studio http://blogs.msdn.com/edhintz/archive/2006/02/03/524312.aspx
Tfpt.exe: Team Foundation Power Toy • Fills some of the gaps in v1 • Some of the command names (getcs, uu) may change in the future • Work item tracking commands will be available soon • Executing queries • Updating work items in bulk • Downloading and uploading attachments • Additional documentation: http://blogs.msdn.com/buckh/articles/tfpt_documentation.aspx • Currently part of the Visual Studio 2005 SDK:http://msdn.microsoft.com/vstudio/extend
Annotate • Downloads all versions of the specified file and shows information about when and who last changed each line in the file • tfpt annotate example.cs
GetCS • Gets only the changes in a particular changeset • “tfpt getcs 123”
History • Copies the functionality of the regular history command with the addition of /followBranches • FollowBranches option results in the output including the history of the file’s branch ancestors • Requires a single item argument (no wildcards or recursion) • tfpt history /followBranches mycode.cs
Online • Pends edits on writable files that do not have pending edits • Optionally includes adds of files not in version control and deletes of files missing from disk • Supports exclusion masks • “tfpt online . /r”
Review • Optimized for a code review rather than checking in or shelving
Rollback • Used to roll back changes that have already been committed • If you have existing pending changes in your workspace, use shelve /move to move them out while rolling back changes • “tfpt rollback /changeset:3”
Unshelve • Unshelve and merge changes with the changes currently in the workspace • Creates a backup shelveset with your changes before unshelving
UU • Undoes unchanged files, including adds, edits, and deletes • By default, gets the latest files in your workspace (runs get) • Specify a particular changeset with /changeset if you only want to check against a particular set of changes • Designed to help with a Gauntlet workflow • “tfpt uu /changeset:123”