Subversion - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Subversion

Description:

Resolving conflicts ... your last update and now your working copy is conflicted with the repository ... this working copy, and you won't have any conflicts ... – PowerPoint PPT presentation

Number of Views:43
Avg rating:3.0/5.0
Slides: 17
Provided by: steve1258
Category:

less

Transcript and Presenter's Notes

Title: Subversion


1
Subversion
  • Or, how I learned to stop worrying and love
    making changes
  • http//svnbook.red-bean.com/

2
The basics
  • What it is
  • Why youd want to use it
  • Key features

3
The Basics What it is
  • A version control system for text and binary
    files, designed as a replacement for CVS
  • Uses client-server model
  • A filesystem based repository that stores the
    revisions of all files and metadata in your
    project is the server
  • The program svn that manages your working copy is
    the client
  • Allows multiple clients to work on the same
    datastore without overwriting data

4
File sharing issues
Overwriting
Lock dependecy
5
The fix Copy-Modify-Merge
Working copies
Merge Changes
6
The Basics why use it?
  • Teams centralize files and documents
    eliminate data overwriting
  • Individuals simple granular backups
    complete file history is always
    available
  • To err is human, to forgive is divine. If youre
    not using some sort of automated version control
    on your projects, get started. It WILL be helpful.

7
The Basics Key Features
  • Stores directory based version history
  • Changes to a repository (commits) are atomic no
    partial commits
  • Good network support
  • Stand-alone svnserve (can be tunneled through
    ssh)
  • Plugin for Apache 2
  • Cheap, fast copying and repository reorganization
  • Compared to other packages http//better-scm.ber
    lios.de/comparison/comparison.html

8
Getting started
  • Initial Configuration
  • Setting up a repository
  • Importing your source files
  • Checking out a working copy
  • Basic Workflow
  • Updating your working copy
  • Committing changes
  • Resolving conflicts

9
Getting Started Initial Configuration
  • Setting up a repository
  • Choice of filesystem (FSFS) or database
    (Berekeley DB) for persistence use FSFS unless
    you know you shouldnt
  • svnadmin create /path/to/repos
  • Importing files
  • Recommended repository structure (trunk, branches
    and tags)
  • Existing files svn import /path/to/files
    protocol//path/to/repos
  • No files yet? No biggie.
  • Checking out a working copy
  • The working copy is the set of files you modify,
    independent of any other user
  • svn checkout protocol//path/to/repos
    /path/to/wc

10
Getting started Basic Workflow
  • Updating your working copy
  • Merge changes made to any files in the repository
    with your working copy
  • svn update
  • Committing changes
  • Make some changes to your codebase
  • svn commit m your log message
  • Resolving conflicts
  • Another developer was working on the same lines
    of code and committed changes between your last
    update and now your working copy is conflicted
    with the repository
  • 3 new temp files are created file.mine,
    file.rBASE, file.rHEAD
  • Either merge the files by hand, use one of the
    three temp files or revert your changes (replace
    your edited file with file.rBASE)
  • svn resolved filename

11
Getting started Branches
  • A good way to explore different approaches to a
    problem
  • Branches are copies of a set of files in the
    repository the new copies retain a revision
    history
  • svn copy protocol//path/to/repos/trunk/weirdProj
    protocol//path/to/repos/branch/weirdProj
  • Now you can checkout a working copy of the
    branch, and commit freely without breaking code
    for other users in the trunk
  • Use svn merge protocol//path/to/repos/dir1protoc
    ol//path/to/repos/dir2my-working-copyto move
    code changes from a branch to a working copy of
    the trunk or vice versa

12
Hosting your repository
  • Locally
  • Working copy and repository are located on the
    same machine
  • Accessible via file// protocol
  • Good choice for lone developers
  • No need for network access
  • Repositories can be moved, if your needs change
  • Can work for teams with a development server too
  • Remotely
  • Working copy and repository are located on
    different machines
  • Accessible via svnserve (svn//, svnssh//)
  • Accessible via Apache 2.0 using mod_dav and
    mod_dav_svn (http//, https//)
  • Hosted
  • Let someone else do it for you!
  • Many options, some free, detailed here
    http//www.snook.ca/archives/servers/hosted_subver
    sion/

13
Extending subversion
  • Use subversion to manage deploying to the web
  • Add custom functionality with hook scripts
  • Tools to simplify your experience

14
Extending deploy for the web
  • You have a production site that needs to be
    updated every now and then. Sound familiar?
  • Make the site a working copy!
  • When updates need to be pushed to production, run
    svn update
  • Stop worrying about missing dependencies
  • Never edit this working copy, and you wont have
    any conflicts
  • Simple to roll back to earlier file versions with
    svn revert (though this does not scale well, if
    youre reverting individual files)

15
Extending hooks
  • Provides a number of hooks (think of them as
    events) which can execute arbitrary code when
    triggered
  • Hook scripts can be written in any scripting
    language the server supports, including PHP
    (using the CLI executable)
  • Scripts live in /path/to/repo/hooks and are
    eponymous (i.e. an executable file named
    post-commit)
  • svnlook can be executed via PHP to get data about
    the repository
  • exec(/usr/bin/svnlook author /path/to/repos r
    100) returns steve
  • Examples
  • Send an email after a successful commit
    (post-commit hook)
  • Run svn update on a working copy after a
    successful commit (post-commit hook)
  • Ensure log messages are properly formatted before
    a commit (pre-commit hook)
  • Rebuild your phpdocs after a successful commit
    (post-commit hook)

16
Extending tools
  • Web
  • WebSVN (http//websvn.tigris.org/) - PHP
  • SVNWeb (http//freshmeat.net/projects/svnweb/)
    - Perl
  • Trac (http//trac.edgewall.org/) - Python
  • Hook Scripts
  • Crank HTML/RSS from log messages
    (http//www.svn2rss.com/)
  • Commits as Basecamp Messages (http//simongate.com
    /2007/6/5/basecamp-post-commit-hook)
  • GUI
  • RapidSVN (http//rapidsvn.tigris.org/)
  • TortoiseSVN (Windows http//tortoisesvn.net/)
  • Kdesvn (Linux http//www.alwins-world.de/programs
    /kdesvn/)
Write a Comment
User Comments (0)
About PowerShow.com