Pow
ered
By
ATCSource
Control 101
Pow
ered
By
ATC
What are we doing?IntroductionLab 1 The file sharing way ReviewLab 2 Create repo, check in &
check out ReviewLab 3 Sync & Rollback ReviewLab 4 Conflict management Review
Lab 5 Locks & Revert ReviewLab 6 Branching ReviewLab 7 Merging ReviewAlternatives to SVNOther TortoiseSVN ToolsIDE IntegrationProven Practises
Pow
ered
By
ATC
Disclaimer
The names and scenarios presented here are purely fictional. Any similarity to real people or scenarios is purely a coincidence.
No animals were harmed during the making of this bootcamp.
Pow
ered
By
ATC
Time to get a little crazyYou need to be three people today
Jim, the junior software dev.Just out of his local computer school and hired by BB&D. Wrote code at school and home – by himself.
Simon, the “seasoned” software dev.Ran his own software company for a few
years - that created iPhone apps. Company size of 1.
Joined BB&D when Palm Pre killed the iPhone market.
Mike, the grizzly IT Pro. Wears shirts that say things like “There are 10 types of people, those who know binary and those who don’t.”
Pow
ered
By
ATC
Supporting castThe wizard – fly’s in and does magic!(used for stuff you need, but don’t care about)
The customer, is all about giving:Gives you requirements.
Gives you headaches.Gives you money.
Pow
ered
By
ATC
LAB Create a file share and do
some changes.
Time: 5min
Pow
ered
By
ATC
Now...
The customer needs a bug fixed in version 1
Pow
ered
By
ATC
What’s in a Name?
Revision
Control
•G
eneric term for assigning a version w
ith a change.
Source
Control
•Revision control but w
ith specific focus on source code. Branching is alm
ost unique here.
Version
Control
•M
ore general term than source control.
Pow
ered
By
ATC
What is source control?An agreed way to share development
resources that gives us:
Source Control
BackupsSynchronisation
Short term undo
Long term undoTrack
changes
Track ownership
Sandboxing
Branching or merging
Pow
ered
By
ATC
TerminologyRepo •Short for repository – where the files and their history are stored.
Server •The machine running one or more repo’s.
Client •The machine connecting to the repo.
Working set •The local copy of the resources you are working on.
Pow
ered
By
ATC
Branching TerminologyBranch •A separate instance of code in a repository.
Trunk/Main •In a repo, this is the main or current version of code.
Merge •Act of combining branches together.
Sandbox •A branch for an individual meant for a short period of time – such as overnight.
Pow
ered
By
ATC
Basic Action TerminologyAdd •Put a file into the repo for the first time.
Revision •What version the file is on.
Check Out •Download a file from the repo.
Check In •Upload a file to the repository.
Pow
ered
By
ATC
Basic Action TerminologyCheck In Message •Message describing what has changed.
Changelog •A list of changes made since the file was created.
Update/Sync •Synchronise your files with latest from the repo.
Revert •Throw away your local changes
Pow
ered
By
ATC
LAB Mike: Create a repo
Simon: Check in a fileJim: Get a file
Time: 5min
Pow
ered
By
ATC
Lab 2 - Review
Repo
DAL.txtv1
DAL.txtv1
Add
Get
Pow
ered
By
ATC
Lab 2 - Review
Is this how you should do your repo?No, use the TCP/IP or SVN protocol.
What is TortoiseSVN?The SVN client is a command line tool.TortoiseSVN is a wrapper for that.
Pow
ered
By
ATC
LAB Jim: Update the file & check it
in.Simon: Sync and rollback.
Time: 5min
Pow
ered
By
ATC
Lab 3 - Review
Repo
DAL.txtv2
DAL.txtv2 Update
Sync
Again
Issue RollbackDAL.txtv1
Pow
ered
By
ATC
Lab 3 - Review
Why did we have to commit again?Because there was a change
What revision are we now on?Revision 3
Can we get back to the code Jim put in, if we needed to?Yes
Pow
ered
By
ATC
LAB Jim: Change the file
Simon: Change the fileCONFLICT!!
Time: 10min
Pow
ered
By
ATC
Lab 4 - Review
DAL.txtv3
Repo
DAL.txtv3
Sync Sync
DAL.txtv4
Update
DAL.txtv4b
Update
DAL.txtv5
Update
Pow
ered
By
ATC
Lab 4 - Review
Why did we have a .r3 and .r4 file?revision 3 & revision 4
What would happen if this was the changes and we tried to commit?It would auto merge
Jim
Simon
Pow
ered
By
ATC
LAB Simon: wants to do a major
code change and make sure Jim doesn’t mess with him
Time: 5min
Pow
ered
By
ATC
Lock
Lab 5 - Review
DAL.txtDAL.txtv5
Repo
Sync Sync
Pow
ered
By
ATC
Lab 5 - Review
Who locked the file?Developer, the user logged into Windows
What happens if the person who locked the file goes on holiday?You can break the lock if needed.
Pow
ered
By
ATC
LAB Simon: As they are releasing
version 1 they want to make sure they can fix issues while working on v2.
Time: 10min
Pow
ered
By
ATC
Lab 6 - Review
Repo
Trunk
Bran
ch
Trunk V1 Branch
Pow
ered
By
ATC
Lab 6 - Review
Do we need to switch?No, but it helps keep focus and prevent issues across branches.
Pow
ered
By
ATC
Lab 6 - Review
What is shelving?Shelving is branching to a personal temporary branch.
Why shelve?1. Interruptions: Pending changes that are not
ready for check in.2. Integration/Handoff: Sharing code with
someone else, without a check in.3. Review: Code for review4. Backup: Personal backup
Pow
ered
By
ATC
Lab 6 - Review
How to shelve?Create a new root folder named shelve, as we
did for branches.In that a folder for each user.Branching as normal.
Pow
ered
By
ATC
Lab 6 - Review
DEV
Bra
nch
RELEASE
Bra
nch
V1.1 (start)
V1.0Production
Release 1.01
RI
V1,0 Hotfix 1 FI R
I
V1.1
FI
DEV
Bra
nch
FI
V1.1 (start) V1.1 FT3
RI
V1.1 (bug fix)
FI
V1.1
FI
V1.2
RI
V1.2
V1.0Production
1 2
3 4 5
6 7
8
Which is correct?
Pow
ered
By
ATC
Scenario #1: Single Team Branching Model
DEV
MAIN
Bra
nch
FI
V1.1 (start) V1.1 FT3
RI
V1.1 (bug fix)
FI
V1.1
FI
V1.2
RI
V1.2
CI / Nightly Builds(Early validation)
Nightly Build(Early Validation)
V1.0Production
1 2
3 4 5
6 7
8
Main should be very stable
All dev done on branch
Pow
ered
By
ATC
Scenario #2: Concurrent Hot Fix, Service Pack, and v.Next
Bra
nch
DEV-1
DEV …
MAIN
R1 (SP)
RTM
Bra
nch
Bra
nch
Bra
nch
When MAIN is ready to release, create the
SERVICE PACK, HOT FIX, and RELEASE
branches at the same time.
The RTM branch is a read-only copy of
what was released
Bra
nch
Bra
nch
Bra
nch
Bra
nch
Bra
nch
SERVICE PACK
R2 (SP)
HOT FIX
R1 (SP0) R1 (SP1)
R1 (SP0) R1 (SP1)
R2 (SP0)
R2 (SP0)
FI
1
2
2
3
4
5
6
7
8
The two DEV branches are
created as sequential tasks, but as one unit of
work.
All dev done on branches
These should be read only
Pow
ered
By
ATC
Scenario #3: Branching and Labeling
DEV-1
DEV …
MAIN
Bra
nch
1
2
2
V1.1
3
V1.2
4
TEST-1 5
Bra
nch
TEST … 6
Bra
nch
The two DEV branches are
created as sequential tasks, but as one unit of
work.
Release labels in branch
Main is just the latest
Pow
ered
By
ATC
LAB Simon: Needs to make sure v2
gets the same bug fix as v1 had.
Time: 5min
Pow
ered
By
ATC
Lab 7 - Review
Trunk
Branch v1
Mer
ge Conflict
No cartoons, cause this is too hard to show with cartoons.
Pow
ered
By
ATC
Other TortoiseSVN tools
Pow
ered
By
ATC
WARNING
The tools to be presented next are based on some personal use and discussion.
They could break or not work – please consultant us and test prior to adoption.
Pow
ered
By
ATC
IDE Integration
http://ankhsvn.open.collab.net/Free & Open Source
http://www.pushok.com/soft_svn.phpCosts ($27) & Proprietary
& about a billion other SVN clients ;)
Pow
ered
By
ATC
Alternatives to SVN
SourceSafe
Microsoft
File System Based
CVS
Previous OSS choice
TFS
Microsoft
More than source control
Enterprise
Git
Created by Linus Tourvalds
Distributed Source Control
Pow
ered
By
ATC
Proven Practises
Use source control
Don’t break the build
Keep up to date
Automerge is a for sync ONLY
Don’t check in binaries
Separate repo for separate things
Pow
ered
By
ATC
Proven Practises
Don’t delete from the repo
Working folders should be disposable
Use non-working folders when needed
Useful & meaningful messages
Don’t use the audit trail to assign blame
Use undo/revert sparingly
Pow
ered
By
ATC
Proven Practises
Use labels but avoid label promotion
Be light and quick with checkouts
Try concurrent
Use Shelving
Pow
ered
By
ATC
Branching Proven Practises
Don’t be afraid of branching
Plan your branching strategy
Don’t branch UNLESS you will look after it
Take responsibility for the merge