Transcript
Page 1: Version control with Subversion how to set it up, use it, and save your sanity
Page 2: Version control with Subversion how to set it up, use it, and save your sanity

Version control with Subversion

how to set it up, use it, and save

your sanity

Page 3: Version control with Subversion how to set it up, use it, and save your sanity

Introduction

Page 4: Version control with Subversion how to set it up, use it, and save your sanity

My life reduced to bullets

• Designing / developing sites since 1996

• Independent consultant

• Using ColdFusion since version 5

• Using Fusebox since version 2

• Using XHTML/CSS since 2003

• Using Subversion off/on October 2006– More off than on…

Page 5: Version control with Subversion how to set it up, use it, and save your sanity

Version control in a nutshell

• Central Repository of all code and changes made to it by anyone over time

• Developers get the latest copy, edit, and “check it back in” to the repository

• Changes made to the same file by different developers are merged

• If need be, you can go back to a previous version of the code

Page 6: Version control with Subversion how to set it up, use it, and save your sanity

Why version control at all?

• A “Time Machine” for code

• Accounts for all changes

• Makes multi-version management easier

• The ultimate “CYA” tool

Page 7: Version control with Subversion how to set it up, use it, and save your sanity

Source control vs. version control

• Source Code Management

– More of a “total solution” that includes things

like bug tracking, Wiki

• Version Control / Revision Control

– This is what Subversion does

Page 8: Version control with Subversion how to set it up, use it, and save your sanity

Not just for code, by the way…

• Design comps

• Project documentation

• Recipes

• Drafts of memos, letters, novels

• Anything you want to revise over time

Page 9: Version control with Subversion how to set it up, use it, and save your sanity

Not just for teams, by the way

• I use it for my own stuff

• Revert to the previous version if I screw up

• Not that I screw up

• Yep.

• What, what are you looking at?

Page 10: Version control with Subversion how to set it up, use it, and save your sanity

Version Control Concepts

The “steps” of version control

Page 11: Version control with Subversion how to set it up, use it, and save your sanity

Version Control Steps

• Create a repository

of project files (code)

• CHECKOUT a

working copy of the

code to working

directory

• Edit code

Page 12: Version control with Subversion how to set it up, use it, and save your sanity

Version Control Steps

• COMMIT your changes back into the repository

• If someone else changed the same file as you, resolve differences to the changed files as needed (MERGE)

• UPDATE your working copy before continuing work the next time

Page 13: Version control with Subversion how to set it up, use it, and save your sanity

Version control models

Page 14: Version control with Subversion how to set it up, use it, and save your sanity

File sharing: the problem to avoid

Page 15: Version control with Subversion how to set it up, use it, and save your sanity

Lock-Modify-Unlock

Page 16: Version control with Subversion how to set it up, use it, and save your sanity

Copy-Modify-Merge

Page 17: Version control with Subversion how to set it up, use it, and save your sanity

Copy-Modify-Merge (cont’d)

Page 18: Version control with Subversion how to set it up, use it, and save your sanity

Options

A quick look at what else is out

there…

Page 19: Version control with Subversion how to set it up, use it, and save your sanity

Microsoft Visual Source Safe

• Microsoft doesn’t use this

• Can cause files to become

lost, corrupted

• Slow, not designed to work

over internet

• $500/developer (?)

Page 20: Version control with Subversion how to set it up, use it, and save your sanity

Concurrent Versioning System (CVS)

• Released in 1986

• Free, open source

• Relatively easy to use

• Designed for a team environment

Page 21: Version control with Subversion how to set it up, use it, and save your sanity

CVS Limitations

• Cannot move/rename files in CVS

• Directory move/changes aren’t versioned

• Poor unicode support

– Doesn’t support non-ASCII characters well

• No versioning of symbolic links

• Binary files are saved in their entirety

Page 22: Version control with Subversion how to set it up, use it, and save your sanity

Other commercial VCS’s

• Perforce

– Free for up to 2 users; OSS

– $800 per developer seat

• SourceHaven

– $295/developer seat

Page 23: Version control with Subversion how to set it up, use it, and save your sanity

Subversion

Page 24: Version control with Subversion how to set it up, use it, and save your sanity

About Subversion

• Designed to replace CVS

• Began in 2000

• Self-hosting in 2001

• 1.0 in Feb 2004

• Current version: 1.4.5

Page 25: Version control with Subversion how to set it up, use it, and save your sanity

Subversion benefits

• Directory versioning

• Filename versioning

• Atomic commits – all succeed or all fail

• Metadata – keywords/comment

• Networking support

Page 26: Version control with Subversion how to set it up, use it, and save your sanity

Subversion benefits (cont’d)

• Delta compression

– Saves differences between files (even binary)

• Branching / Tagging

• Well-defined API (e.g., Trac, TortoiseSVN,

SCPlugin)

• Free!

Page 27: Version control with Subversion how to set it up, use it, and save your sanity

Installation

Setting it up…

Page 28: Version control with Subversion how to set it up, use it, and save your sanity

Access options

Page 29: Version control with Subversion how to set it up, use it, and save your sanity

SVNServe Daemon

• Easy, quick install

– 1-click setup (ok, it takes more than 1 click)

• All projects under one repository

– You can create sub projects under this main

repository, but it’s less elegant than separate

repositories

• Listens on nonstandard port (3690)

– Across internet, there could be a firewall issue

Page 30: Version control with Subversion how to set it up, use it, and save your sanity

SVNServe Daemon / 1-click setup

• Ideal if you want to get up and running

quick to play with Subversion

• Not ideal if you want to version more than

one project and/or work across a network

Page 31: Version control with Subversion how to set it up, use it, and save your sanity

Apache, WebDAV/DeltaV

• Allows you to work with an SVN repository

anywhere in the world

• Uses http:// or https:// on port 80 – no

firewall issues!

• Use authentication to restrict to

username/password holders

Page 32: Version control with Subversion how to set it up, use it, and save your sanity

Subversion Repository

Page 33: Version control with Subversion how to set it up, use it, and save your sanity

My Repository

Page 34: Version control with Subversion how to set it up, use it, and save your sanity

Physical repository

Page 35: Version control with Subversion how to set it up, use it, and save your sanity

Virtual repository

Page 36: Version control with Subversion how to set it up, use it, and save your sanity

Revision history

Page 37: Version control with Subversion how to set it up, use it, and save your sanity

One repository, multiple projects

index.cfm

dsp_header.cfm

dsp_footer.cfm

index.cfm

dsp_header.cfm

dsp_footer.cfm

Page 38: Version control with Subversion how to set it up, use it, and save your sanity

One repository for each project

index.cfm

dsp_header.cfm

dsp_footer.cfm

index.cfm

dsp_header.cfm

dsp_footer.cfm

Page 39: Version control with Subversion how to set it up, use it, and save your sanity

Interacting with Subversion

Some approaches…

Page 40: Version control with Subversion how to set it up, use it, and save your sanity

Command line interface

• General client command line

svn [command ] [arguments ]• Read or update your working copy

svn checkout

svn update• Make changes

svn add

svn delete

svn copy

svn move• Commit your changes

svn commit

Page 41: Version control with Subversion how to set it up, use it, and save your sanity

TortoiseSVN client

Page 42: Version control with Subversion how to set it up, use it, and save your sanity

SCPlugin client

Page 43: Version control with Subversion how to set it up, use it, and save your sanity

Subclipse

Page 44: Version control with Subversion how to set it up, use it, and save your sanity

Using Subversion

Simple steps to save your sanity

Page 45: Version control with Subversion how to set it up, use it, and save your sanity

Using Subversion

• Create the repository

• Import files into repository

• Checkout files as a working copy

• Change, commit, update

• Resolve conflicts (if needed)

Page 46: Version control with Subversion how to set it up, use it, and save your sanity

Using Subversion

Demo

Page 47: Version control with Subversion how to set it up, use it, and save your sanity

Branching

Page 48: Version control with Subversion how to set it up, use it, and save your sanity

Branching notes

• Branches are for the minority– Use for trying out new features, etc.

• You may branch from trunk or from branch– But don’t unless you really need to

• Can merge changes from the branch to trunk or vice-versa

• Don’t be scared!

Page 49: Version control with Subversion how to set it up, use it, and save your sanity

Using Subversion and CF

• Old Way

– We all update files on a “dev server”

• New Way

– Check out code to a local working directory

– Develop locally

– Commit changes back

– Deploy “build” from SVN to dev server

Page 50: Version control with Subversion how to set it up, use it, and save your sanity

Tips and Best Practices

• Use version control

• Don’t break the tree

– Don’t commit broken code or code that is not finished

• Don’t lock files unless you have a durned good

reason to

• Explain commits completely and in plain

language (use diff!)

Page 51: Version control with Subversion how to set it up, use it, and save your sanity

Tips and Best Practices (cont’d)

• Update early and often• Commit early and often

– without breaking build

• When in doubt, resolve conflicts with fellow team members

• Version the stuff you control, not the stuff your code produces

• Use one repository per project• Subversion != Backup

Page 52: Version control with Subversion how to set it up, use it, and save your sanity

Thank You!

[email protected]

http://christianready.com

410-382-8070

Page 53: Version control with Subversion how to set it up, use it, and save your sanity

Copyright Info

All Diagrams from Version Control with Subversion available from http://svnbook.red-bean.com

• Copyright (c) 2002-2004 Ben Collins-Sussman, Brian W. Fitzpatrick, C. Michael Pilato. This work is licensed under the Creative Commons Attribution License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305,USA.

Page 54: Version control with Subversion how to set it up, use it, and save your sanity

Resources

Page 55: Version control with Subversion how to set it up, use it, and save your sanity

Sites

• SVN Project

– http://subversion.tigris.org/

• SVN Forum

– http://www.svnforum.org/

Page 56: Version control with Subversion how to set it up, use it, and save your sanity

Utilities

• SVN 1-click setup

– http://svn1clicksetup.tigris.org/

• Tortoise SVN

– http://tortoisesvn.tigris.org/

• Subclipse

– http://subclipse.tigris.org/

• CVS Dude

– http://cvsdude.com/

Page 57: Version control with Subversion how to set it up, use it, and save your sanity

Books

• Version Control with Subversion

– http://svnbook.red-bean.com/

• Pragmatic Version Control with

Subversion

– http://pragmaticprogrammer.com/titles/svn/

Page 58: Version control with Subversion how to set it up, use it, and save your sanity

Articles on version control/branching

• Subversion for Windows & Apache

– http://svn.spears.at/

• Setting up a Subversion Server under Windows

– http://blogs.vertigosoftware.com/teamsystem/archive/

2006/01/16/

Setting_up_a_Subversion_Server_under_Windows.aspx

• Subversion branching quick start

– http://www.nedbatchelder.com/text/quicksvnbranch.html

• http://www.cmcrossroads.com/bradapp/acme/branching/

• Source Control HOWTO

– http://www.ericsink.com/scm/source_control.html


Top Related