Microsoft Developer’s Guide to Team Foundation Version Control Ed Hintz and Buck Hodges.
-
Upload
allen-green -
Category
Documents
-
view
222 -
download
0
Transcript of Microsoft Developer’s Guide to Team Foundation Version Control Ed Hintz and Buck Hodges.
Microsoft Developer’s Microsoft Developer’s Guide to Guide to
Team Foundation Version Team Foundation Version ControlControl
Ed Hintz and Buck HodgesEd Hintz and Buck Hodges
AgendaAgenda
IntroductionIntroduction
Dogfood and Performance StatisticsDogfood and Performance Statistics
Feature overviewFeature overview
ScenariosScenariosVisual Studio Visual Studio
Command lineCommand line
SDK and ExtensibilitySDK and Extensibility
What is VS Team What is VS Team Foundation?Foundation?Integrated Platform for Collaborating on Software Integrated Platform for Collaborating on Software
Development Projects.Development Projects.
Version Version ControlControl
Work Item Work Item TrackingTracking
Build Build AutomationAutomation
Team Team CommunicationsCommunications
ReportingReporting
Microsoft VSTS Dogfooding Microsoft VSTS Dogfooding Version ControlVersion Control
Redmond, WARedmond, WA368 Users368 Users
Fargo, NDFargo, ND4 Users4 Users
Research Research Triangle, NCTriangle, NC42 Users42 Users
Copenhagen, Copenhagen, DenmarkDenmark6 Users6 Users
Hyderabad, IndiaHyderabad, India14 Users14 Users
Version Control Users:Version Control Users: 864 864Number of Files/Folders: 1,507,247/178,953Number of Files/Folders: 1,507,247/178,953Compressed File Size:Compressed File Size: 95.2 GB 95.2 GBWorkspaces:Workspaces: 1,770 1,770Workspace File Versions: 48.9 MillionWorkspace File Versions: 48.9 MillionChangesets:Changesets: 32,573 32,573Pending Changes:Pending Changes: 57,278 57,278Shelvesets:Shelvesets: 2,458 2,458
Source: Source: http://blogs.msdn.com/johnlawr/archive/2006/02/16/533362.aspxLatest: http://tfsserver:8080/VersionControl/v1.0/administration.asmx/QueryRepositoryInformationLatest: http://tfsserver:8080/VersionControl/v1.0/administration.asmx/QueryRepositoryInformation
Source Control Feature SupportSource Control Feature Support
Atomic CheckinAtomic Checkin
Integrated with Visual StudioIntegrated with Visual Studio
Work Item IntegrationWork Item Integration
Customizable Checkin ExperienceCustomizable Checkin ExperienceCheckin PoliciesCheckin Policies
Checkin NotesCheckin Notes
ShelvingShelving
Delta File StorageDelta File Storage
Large File Support (>4GB)Large File Support (>4GB)
Source Control Feature SupportSource Control Feature Support
Distributed Team SupportDistributed Team Support
E-mail Checkin NotificationE-mail Checkin Notification
Merge and Diff Tool Configurable Merge and Diff Tool Configurable (see (see http://blogs.msdn.com/jmanning/artihttp://blogs.msdn.com/jmanning/articles/535573.aspxcles/535573.aspx for common tool settings) for common tool settings)
SDK and VS Extensibility SDK and VS Extensibility
MSSCCI Plugin as Powertoy – MSSCCI Plugin as Powertoy – (VS2003, VB and VC6)(VS2003, VB and VC6)
Visual Studio DemoVisual Studio Demo
ArchitectureArchitecture
ArchitectureArchitecture
App TierApp TierStandbyStandby
ServerServer
Team Foundation Data Tier
Team Foundation App Tier
Build MachineVersion ControlProxy
Report Client
MDACMDAC
Team Foundation Client Tier
TFS Concepts: WorkspaceTFS Concepts: WorkspaceLocal copy of files under SCCLocal copy of files under SCC
Isolates developer from other changesIsolates developer from other changes
Maps repository paths to local pathsMaps repository paths to local pathsMappings can be scattered around local Mappings can be scattered around local machinemachineAllows for cloaked pathsAllows for cloaked paths
Server maintains inventoryServer maintains inventoryTracks file versions and local pathsTracks file versions and local paths
TFS Concepts: ChangesetTFS Concepts: Changeset
Set of committed modificationsSet of committed modificationsAdd, rename, delete, etc.Add, rename, delete, etc.
Atomically applied to repositoryAtomically applied to repository
Associated with work items at Associated with work items at checkincheckin
Convenient unit for change Convenient unit for change managementmanagement
Visual Visual Studio Studio
CheckinCheckin
ValidateValidatePoliciesPolicies
11
Checkin PolicyCheckin PolicyEngineEngine
Checkin PolicyCheckin PolicyEngineEngine
Unit
Test
ing
Unit
Test
ing
WI A
ssoci
ati
on
WI A
ssoci
ati
on
Sta
tic
An
aly
sis
Sta
tic
An
aly
sis
Cust
om
Polic
yC
ust
om
Polic
y
CommitCommitChangesChanges
22
V1V1V1V1V5V5V5V5V4V4V4V4V5V5V5V5
V2V2V2V2V3V3V3V3
Change Set 727012Change Set 727012Change Set 727012Change Set 727012Change Set 727012Change Set 727012Change Set 727012Change Set 727012
Change Set 727012Change Set 727012Change Set 727012Change Set 727012Change Set 727012Change Set 727012Change Set 727012Change Set 727012
Change Set 727011Change Set 727011Change Set 727011Change Set 727011Changeset 727012Changeset 727012Changeset 727012Changeset 727012
WorkItem 33231WorkItem 33231WorkItem 33231WorkItem 33231
UpdateUpdateWork ItemsWork Items
33
Events Raised forEvents Raised for33rdrd party sync purposes party sync purposes
ArtifactArtifactLinkLink
Check E-mailCheck E-mailNotificationNotification
44
Checkin - Under the HoodCheckin - Under the Hood
WorkspaceWorkspace
Integration Integration InfrastructureInfrastructure
Version Version ControlControl
Work Item Work Item TrackingTracking
Getting startedGetting startedCreate a workspace, set mappingsCreate a workspace, set mappings
For example, use /template to start with For example, use /template to start with working folder mappings.working folder mappings.tf workspace tf workspace /template:/template:WorkspaceNameWorkspaceName;;usernameusername WS1 WS1 /s:http://tfsserver:8080/s:http://tfsserver:8080
Configure diff and merge toolsConfigure diff and merge toolstf diff /configuretf diff /configure
Get the files from the serverGet the files from the servertf gettf get
Edit a fileEdit a filetf edit foo.cstf edit foo.cs
Check inCheck intf checkintf checkin
Command line dialogsCommand line dialogs
We provide dialogs for commands We provide dialogs for commands involving complex input or data display involving complex input or data display (use /i to suppress)(use /i to suppress)
ChangesetChangeset
CheckinCheckin
Difference (external diff viewer)Difference (external diff viewer)
Get (conflict resolution)Get (conflict resolution)
HistoryHistory
ResolveResolve
ShelveShelve
UnshelveUnshelve
View (associated editor)View (associated editor)
WorkspaceWorkspace
ShelvesetsShelvesetsShelvesets are collections of pending Shelvesets are collections of pending changes, comments, and associated changes, comments, and associated work itemswork itemsScenariosScenarios
BackupBackuptf shelve /i MyWorktf shelve /i MyWorkTemporarily move changes to work on a Temporarily move changes to work on a different issuedifferent issuetf shelve /i MyWork /movetf shelve /i MyWork /moveRemote code reviewsRemote code reviewstf unshelve CoolStuff;joetf unshelve CoolStuff;joeBuddy builds or coordinate changesBuddy builds or coordinate changestf unshelve CoolStuff;joetf unshelve CoolStuff;joe
ShelvesetsShelvesets
List shelvesetsList shelvesetstf shelvesetstf shelvesetstf shelvesets /owner:joetf shelvesets /owner:joe
Delete a shelvesetDelete a shelvesettf shelve /delete MyShelvesettf shelve /delete MyShelveset
List the pending changes in a List the pending changes in a shelvesetshelvesettf status /shelveset:MyWork;joetf status /shelveset:MyWork;joe
Diff the changes in a shelvesetDiff the changes in a shelvesettf diff /shelveset:MyWork;joetf diff /shelveset:MyWork;joe
NotesNotesTo move your workspace, change To move your workspace, change your mappings (tf workspace) and your mappings (tf workspace) and then run getthen run getTo handle changing computer names:To handle changing computer names:tf workspaces tf workspaces /updateComputerName:oldName /updateComputerName:oldName /s:http://tfsserver:8080/s:http://tfsserver:8080
To handle changing user names:To handle changing user names:tf workspaces tf workspaces /updateUserName:oldUserName /updateUserName:oldUserName /s:http://tfsserver:8080/s:http://tfsserver:8080
Renaming filesRenaming filesDon’t overdo it, or your branch merges Don’t overdo it, or your branch merges will be more tedious (for example, will be more tedious (for example, renames in both the source and target)renames in both the source and target)
Performance TweaksPerformance TweaksUse a version control caching proxy Use a version control caching proxy server in remote officesserver in remote officesCommand lineCommand line
Set the BypassProxyOnLocal registry Set the BypassProxyOnLocal registry entry (see entry (see http://blogs.msdn.com/buckh/archive/20http://blogs.msdn.com/buckh/archive/2005/12/12/503015.aspx for details)05/12/12/503015.aspx for details)
On my laptop today, ByPassProxyOnLocal On my laptop today, ByPassProxyOnLocal saved 2 seconds (my IE settings are saved 2 seconds (my IE settings are Automatically Detect)Automatically Detect)
Visual StudioVisual StudioChange the registry setting not to Change the registry setting not to automatically get missing files (see automatically get missing files (see http://blogs.msdn.com/hippietim/archive/http://blogs.msdn.com/hippietim/archive/2006/03/14/551320.aspx2006/03/14/551320.aspx for details) for details)
CommandsCommands
Command line reference: Command line reference: http://msdn2.microsoft.com/en-us/library/http://msdn2.microsoft.com/en-us/library/cc31bk2e(vs.80).aspxcc31bk2e(vs.80).aspx
Command line command and option Command line command and option summary: summary: http://blogs.msdn.com/buckh/articles/Comhttp://blogs.msdn.com/buckh/articles/CommandLineSummary.aspxmandLineSummary.aspx
Client APIClient API
The Team Foundation Server client The Team Foundation Server client object model is a set of .NET 2.0 object model is a set of .NET 2.0 assembliesassemblies
There are public APIs for version There are public APIs for version control, work item tracking, build, control, work item tracking, build, reporting, and morereporting, and more
TeamTeamFoundationFoundation
ServerServer
TeamTeamFoundation Foundation CoreCoreServicesServices
How It Happens:How It Happens:Team Foundation Core ServicesTeam Foundation Core Services
LinkingLinkingServiceService
UserUserGroupsGroupsServiceService
NotificationNotificationServiceService
RegistrationRegistrationServiceService
CommonCommonStructureStructureServiceService
Team Foundation Object ModelTeam Foundation Object Model
Visual Visual Studio Studio IDEIDE
External toolExternal tool(Partner or MS)(Partner or MS)
VersionVersionControlControl
Inte
gra
tio
nIn
teg
rati
on
Inte
rfa
ce
Inte
rfa
ce
WorkWorkItemsItems
Inte
gra
tio
nIn
teg
rati
on
Inte
rfa
ce
Inte
rfa
ce
TeamTeamBuild Build
Inte
gra
tio
nIn
teg
rati
on
Inte
rfa
ce
Inte
rfa
ce
Version Control Client APIVersion Control Client API
The primary objects areThe primary objects areTeamFoundationServerTeamFoundationServer – this is the root – this is the root object from which you obtain a service, such object from which you obtain a service, such as version control or work item trackingas version control or work item trackingVersionControlServerVersionControlServer – this is the primary – this is the primary interface to the version control server for interface to the version control server for operations and queries that are not specific to operations and queries that are not specific to a workspacea workspaceWorkspaceWorkspace – this object represents a – this object represents a workspace and is used to pend changes, check workspace and is used to pend changes, check in changes, and perform queries specific to a in changes, and perform queries specific to a workspaceworkspaceWorkstationWorkstation – this object represents the – this object represents the current computer and manages the workspace current computer and manages the workspace cache, which contains the list of local paths in cache, which contains the list of local paths in each workspaceeach workspace
Code SampleCode Sample
TeamFoundationServer tfs = new TeamFoundationServer tfs = new TeamFoundationServer(TeamFoundationServer("http://tfsserver:8080""http://tfsserver:8080"););
// Get a reference to Version Control.// Get a reference to Version Control.
VersionControlServer versionControl = VersionControlServer versionControl = (VersionControlServer) (VersionControlServer) tfs.GetService(typeof(VersionControlServer));tfs.GetService(typeof(VersionControlServer));
Code SampleCode Sample// Determine the server and workspace based on the local path mapping.// Determine the server and workspace based on the local path mapping.WorkspaceInfo wsInfo =WorkspaceInfo wsInfo =
Workstation.Current.GetLocalWorkspaceInfo(Environment.CurrentDirectorWorkstation.Current.GetLocalWorkspaceInfo(Environment.CurrentDirectory);y);
// Stop if we couldn't figure out the // Stop if we couldn't figure out the workspaceworkspace..if (wsInfo == null)if (wsInfo == null){{ Console.Error.WriteLine("Unable to determine the Console.Error.WriteLine("Unable to determine the workspaceworkspace.");."); Environment.Exit(1);Environment.Exit(1);}}
// Get a reference to our Team Foundation Server. // Get a reference to our Team Foundation Server. TeamFoundationServer tfs = new TeamFoundationServer tfs = new
TeamFoundationServer(wsInfo.ServerUri.AbsoluteUri);TeamFoundationServer(wsInfo.ServerUri.AbsoluteUri);// Get a reference to the workspace.// Get a reference to the workspace.Workspace workspace = wsInfo.GetWorkspace(tfs);Workspace workspace = wsInfo.GetWorkspace(tfs);
// Update this workspace.// Update this workspace.workspace.Get(); workspace.Get();
API Code SamplesAPI Code SamplesBasic Team Foundation Version Control client API exampleBasic Team Foundation Version Control client API examplehttp://blogs.msdn.com/buckh/archive/2006/03/15/552288.aspxhttp://blogs.msdn.com/buckh/archive/2006/03/15/552288.aspx
Displaying the labels on a file, including label commentsDisplaying the labels on a file, including label commentshttp://blogs.msdn.com/buckh/archive/2005/10/25/484854.aspxhttp://blogs.msdn.com/buckh/archive/2005/10/25/484854.aspx
Displaying the sizes and dates of files in the serverDisplaying the sizes and dates of files in the serverhttp://blogs.msdn.com/buckh/archive/2005/10/26/485458.aspxhttp://blogs.msdn.com/buckh/archive/2005/10/26/485458.aspx
Sample checkin policy: make sure the comment isn't emptySample checkin policy: make sure the comment isn't emptyhttp://blogs.msdn.com/jmanning/archive/2006/01/21/515858.aspxhttp://blogs.msdn.com/jmanning/archive/2006/01/21/515858.aspx
Show all pending changes on the Team Foundation server older Show all pending changes on the Team Foundation server older than a given agethan a given agehttp://blogs.msdn.com/jmanning/archive/2005/12/01/499033.aspxhttp://blogs.msdn.com/jmanning/archive/2005/12/01/499033.aspx
Scanning history for the changesets that had policy override - Scanning history for the changesets that had policy override - simple usage of QueryHistorysimple usage of QueryHistoryhttp://blogs.msdn.com/jmanning/archive/2005/11/04/489193.aspxhttp://blogs.msdn.com/jmanning/archive/2005/11/04/489193.aspx
VS ExtensibilityVS ExtensibilityAllows customers to extend the Allows customers to extend the functionality of TF SCC in Visual functionality of TF SCC in Visual Studio via add-ins and packagesStudio via add-ins and packages
Provides access to the following:Provides access to the following:Source Control Explorer selection and Source Control Explorer selection and eventsevents
Pending Changes selection and eventsPending Changes selection and events
Solution Explorer and SCC Explorer Solution Explorer and SCC Explorer workspaceworkspace
History selectionHistory selection
Changeset details dialogChangeset details dialog
Shelveset details dialogShelveset details dialog
VS ExtensibilityVS Extensibility
All class names start with All class names start with Microsoft.VisualStudio.TeamFoundation.VersionCoMicrosoft.VisualStudio.TeamFoundation.VersionControl ntrol
Use the VersionControlExt object to Use the VersionControlExt object to get to the others:get to the others:
vce = vce = _applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.V_applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt; ersionControl.VersionControlExt") as VersionControlExt;
VS Extensibility - VS Extensibility - VersionControlExtVersionControlExt
Method/Property Description
Explorer Access the Source Control Explorer. Useful for add-ins that need to scope an operation. The class is VersionControlExplorerExt.
FindChangeSet Find and display a specific changeset from your add-in
History Access the History Toolwindow from your add-in. The class is HistoryExt
PendingChanges Access the collection of pending changes (as displayed in the Pending Changes Toolwindow) from your add-in. The class is PendingChangesExt.
SolutionWorkspace Get the Workspace object that contains the currently opened solution. If there is no solution opened or the solution is not under version control this will be null.
ViewChangeSetDetails Display detailed information about a changeset
ViewShelveSetDetails Display detailed information about a shelveset
VS Extensibility DemoVS Extensibility DemoHow to Write a Team Foundation Version Control Add-in for Visual How to Write a Team Foundation Version Control Add-in for Visual
StudioStudio http://blogs.msdn.com/edhintz/archive/2006/02/03/524312.aspxhttp://blogs.msdn.com/edhintz/archive/2006/02/03/524312.aspx
Tfpt.exe: Team Foundation Power Tfpt.exe: Team Foundation Power ToyToyFills some of the gaps in v1Fills some of the gaps in v1
Some of the command names (getcs, uu) Some of the command names (getcs, uu) may change in the futuremay change in the future
Work item tracking commands will be Work item tracking commands will be available soonavailable soon
Executing queriesExecuting queries
Updating work items in bulkUpdating work items in bulk
Downloading and uploading attachmentsDownloading and uploading attachments
Additional documentation: Additional documentation: http://blogs.msdn.com/buckh/articles/tfpt_http://blogs.msdn.com/buckh/articles/tfpt_documentation.aspxdocumentation.aspx
Currently part of the Visual Studio 2005 Currently part of the Visual Studio 2005 SDK:SDK:http://msdn.microsoft.com/vstudio/extendhttp://msdn.microsoft.com/vstudio/extend
AnnotateAnnotate
Downloads all versions of the specified file and Downloads all versions of the specified file and shows information about when and who last shows information about when and who last changed each line in the filechanged each line in the filetfpt annotate example.cstfpt annotate example.cs
GetCSGetCS
Gets only the changes in a particular Gets only the changes in a particular changesetchangeset
““tfpt getcs 123”tfpt getcs 123”
HistoryHistory
Copies the functionality of the regular Copies the functionality of the regular history command with the addition of history command with the addition of /followBranches/followBranches
FollowBranches option results in the output FollowBranches option results in the output including the history of the file’s branch including the history of the file’s branch ancestorsancestors
Requires a single item argument (no Requires a single item argument (no wildcards or recursion)wildcards or recursion)
tfpt history /followBranches mycode.cstfpt history /followBranches mycode.cs
OnlineOnline
Pends edits on writable files that do not have Pends edits on writable files that do not have pending editspending edits
Optionally includes adds of files not in version Optionally includes adds of files not in version control and deletes of files missing from diskcontrol and deletes of files missing from disk
Supports exclusion masksSupports exclusion masks
““tfpt online . /r”tfpt online . /r”
ReviewReview
Optimized for a code review rather Optimized for a code review rather than checking in or shelvingthan checking in or shelving
RollbackRollbackUsed to roll back changes that have already Used to roll back changes that have already been committedbeen committed
If you have existing pending changes in your If you have existing pending changes in your workspace, use shelve /move to move them out workspace, use shelve /move to move them out while rolling back changeswhile rolling back changes
““tfpt rollback /changeset:3”tfpt rollback /changeset:3”
UnshelveUnshelveUnshelve and merge changes with the changes Unshelve and merge changes with the changes currently in the workspacecurrently in the workspaceCreates a backup shelveset with your changes Creates a backup shelveset with your changes before unshelvingbefore unshelving
UUUU
Undoes unchanged files, including adds, Undoes unchanged files, including adds, edits, and deletesedits, and deletes
By default, gets the latest files in your By default, gets the latest files in your workspace (runs get)workspace (runs get)
Specify a particular changeset with /changeset Specify a particular changeset with /changeset if you only want to check against a particular if you only want to check against a particular set of changesset of changes
Designed to help with a Gauntlet workflowDesigned to help with a Gauntlet workflow““tfpt uu /changeset:123”tfpt uu /changeset:123”
QuestionsQuestions