Team Foundation Server - Source Control

38
Team Foundation Server Source Control Dhirendra Singh Principal Software Engineer Zenevo Technologies

description

This presentation focusses on : -TFS- an Overview -Managing Branches -Merging -Code Integration

Transcript of Team Foundation Server - Source Control

Page 1: Team Foundation Server - Source Control

Team Foundation Server Source Control

Dhirendra SinghPrincipal Software Engineer

Zenevo Technologies

Page 2: Team Foundation Server - Source Control

Agenda

• TFS- an Overview• Managing Branches• Merging• Code Integration

Page 3: Team Foundation Server - Source Control

What is Team Foundation Server?

• It is the “Glue” that connects our team– What am I supposed to do?– What’s my progress?– What’s broken?

• Helps manage project artifacts– Source Control

Page 4: Team Foundation Server - Source Control

Visual Studio Team System

Page 5: Team Foundation Server - Source Control

How it is helping us?

• Helps our team communicate • Centralized place to manage our project• Data is captured automatically• Everyone looks at the same data• It is Customizable• Artifacts version/source control• Minimize / eliminate lost work• Reproducible builds & product state

Page 6: Team Foundation Server - Source Control

Team Foundation Server

Team Foundation ServerVersion Control

Work Item Tracking

Reporting and BI

Team Portal

Team Build

Page 7: Team Foundation Server - Source Control

Team Foundation ServerDev Team (Local)

Dev Team (Remote)Business User

Build Agent

Version Control Proxy

(Remote)

Active Directory

TCP/IPHTTP / S

Windows 2003 ServerSQL Server 2005IIS 6.0

Team Foundation Server

Page 8: Team Foundation Server - Source Control

TFS Source Control: Terminology• Workspaces

– Area on local disk where you edit files• Check in / check out

– Check out marks the beginning of your edits– Check in commits your changes to the repository– TFS allows shared check out

• Changesets– Group of changes that happen when you check in– It works similarly as Label

• Shelving– Similar to check in – Changes get stored on the server – Not visible as part of the main project source tree– For the purpose of Park your changes & go ahead

• Branching– Used to manage multiple versions of a product– Helps in Release Process (Bug Fixes, Developing new features, Service Packs)

8

Page 9: Team Foundation Server - Source Control

TFS does more than just check-in and check-out

• Branching and merging– Facilitates simultaneous development of multiple

versions of an application• Applying Labels• Cloaking• Shelve & Unshelve

Page 10: Team Foundation Server - Source Control

What should go into source control?

• Solution files -- *.sln• Project files -- *.csproj, *.vbproj• Source Control Project Metadata (*.vspscc)

– Project bindings– Source control configuration

• Application config files (*.config)• Source files • Project Binaries dependency references (e.g.

Third Party dlls, Components)

10

Page 11: Team Foundation Server - Source Control

What should not go in source control?

• Solution user option files (*.suo)– Local user customizations

• Project user option files (*.user)– Local user customizations

• WebInfo files (*.webinfo)• Build outputs

– /bin/debug– /bin/release– /obj

11

Page 12: Team Foundation Server - Source Control

Client-side vs Server-side Structure• Directory structure should be the same

– Client-side structure should match server• Simplifies “Get Latest”• Everyone has the same directory layout• This doesn’t mean that everyone has to put

their source in the same place on disk– The relative paths should match– Root path of source tree can be different

12

Page 13: Team Foundation Server - Source Control

Plan your Repository

Recommended file structure for Version Control.

Page 14: Team Foundation Server - Source Control

Recommended File Structure

Page 15: Team Foundation Server - Source Control

Don’t Branch... until

• You have a good reason• Life only gets more complex with branching• Favor Labels over Branches• You can always branch from a Label later

15

Page 16: Team Foundation Server - Source Control

When to branch…The Signs…• Regular broken builds• Features in parallel development that need to edit one

another– Branch so that each feature can develop in isolation– Merge changes later

• Avoid source tree being polluted with experimental code.• Allow work on different versions of product at same time• Support maintenance releases etc• Allow parallel Development• Ask yourself if the productivity gained by the branch is

balanced against the pain (anti-productivity) of merging changes back

16

Page 17: Team Foundation Server - Source Control

SO…IF YOU REALLY MUST BRANCH…

17

Page 18: Team Foundation Server - Source Control

Branching Scenarios• No Branching

– Everyone works from the same code• Branch for Release

– Stabilization in order to prepare for a release• Branch for Maintenance

– Maintenance of a previous build/release– Service pack development

• Branch for Feature– Branch from the Trunk to develop a new feature (such as a new module in

isolation)– Merge back into the Trunk when feature is done

• Branch for Multiple Teams– Branches for multiple teams working on a set of features

18

Page 19: Team Foundation Server - Source Control

Branch For Release : Process• \Main\

– Source\• \Release 1\

– Source\• \Release 2\

– Source\

19

Page 20: Team Foundation Server - Source Control

Branch For Maintenance

• Similar to Branch For Release• \Main\

– Source\• \Maintenance\

– Release 1\•Source\

– Release 2\•Source\

20

Page 21: Team Foundation Server - Source Control

Branch For Feature

• Branching for development isolation

• \Main\– Source\

• \Development\– Feature 1\

•Source\

– Feature 2\•Source\

– Feature 3\•Source\

21

Page 22: Team Foundation Server - Source Control

Branch For Feature: The Process

22

Page 23: Team Foundation Server - Source Control

Branch For Teams

• \Main\– Source\

• \Development\– Team 1\

• Feature 1\– Source\

• Feature 2\– Source \

– Team 2\• Feature 1\

– Source\

• Feature 2\– Source \

23

Page 24: Team Foundation Server - Source Control

Branching Overkill

• Minimize the number of branches• Watch out for branching problems

– Missed deadlines because the merge is too difficult, long, intricate, etc

– Releases take forever because fixes have to go through multiple layers of merge

– You’re simply spending too much time doing merges

24

Page 25: Team Foundation Server - Source Control

Branching and Merging

Source: http://downloads.seapine.com/pub/papers/SCMBranchingModels.pdf

Page 26: Team Foundation Server - Source Control

Demo

• Create a branch• Merge changes• Create/resolve a check-in conflict• Discussion about Baseless Merge

Page 27: Team Foundation Server - Source Control

Some News…

• Bad news– Some features are command-line only

• Good news– There’s a lot you can do from the command-line– Scriptable

Page 28: Team Foundation Server - Source Control

Beyond the GUI

TF.exe is your Friend

The most powerful for Team Foundation Source Control is the

command line.

Page 29: Team Foundation Server - Source Control

TF.exe

• Command-line interface to TFS source control• 30+ sub commands

– Kind of like “net” command in Windows• Why would you want to use the command

line version?1. It’s cool2. Some things aren’t available through the UI3. Good for automated operations (builds, etc)

Page 30: Team Foundation Server - Source Control

The Commands• Add• Branch / Branches• Changeset• Checkin / Checkout• Configure• Delete / Undelete• Dir• Get• History• Label / Labels / Unlabel• Lock• Merge / Merges

• Move• Permission• Properties• Rename• Resolve• Shelve / Unshelve• Status• Undo• View• Workfold• Workspace / Workspaces

Page 31: Team Foundation Server - Source Control

Things you (probably) can’t do through the GUI

• Find files in TFS by name/wildcard– tf dir

• Get particular version of a file(s) by wildcard– tf get

• Find checked out / pending change files– tf status

• What will be changed by a “get latest”?– tf get /preview

• Baseless merges– tf merge /baseless

• Eliminating a changeset from a merge– tf merge /discard

Page 32: Team Foundation Server - Source Control

And Last but not the Least…

Page 33: Team Foundation Server - Source Control

Baby Come Back

Accessing Deleted FilesTools, Options, Source Control, Show deleted items in Source Control Explorer.Undelete file. Remember to add to solution…

Page 34: Team Foundation Server - Source Control

Extending TFS

Use the .NET object model to extend Team Foundation Server

Page 35: Team Foundation Server - Source Control

Check out != Get Latest

and Also

Check-in != Get Latest

Page 36: Team Foundation Server - Source Control

Change != Bad

TFS is new and different – you folks will need time to adjust.

Page 37: Team Foundation Server - Source Control

Best Practices- References• http://www.codeplex.com/TFSGu

ide

• Lots of great info• Free• Released Aug 2007

37

Page 38: Team Foundation Server - Source Control

Question and Answer

Dhirendra SinghPrincipal Software EngineerZenevo Technologies Pvt. Ltd.

[email protected]@gmail.com www.zenevo.com