Using a revision control system that tracks changes in source code with ways to manage your code in separate branches and tag revisions as releases is a bare minimum for developers.
This presentation highlights the importance of using a version control system Subversion.
4. About this presentation
ā¢ Concepts of version control
ā¢ Management with subversion
ā¢ Life cycle of a project in subversion
ā¢ Parts and structures within subversion
ā¢ Advanced subversion tools
ā¢ New in release 1.5
5. What is version control ?
āRevision control (also known as version control ...) is
the management of multiple revisions of the same unit
of information.ā
(source: Wikipedia:RevisionControl)
6. Versioning for developers
ā¢- version control provides
management of versions of information
ā¢ code/tests
ā¢ conļ¬guration ļ¬les
-
ā¢ documentation
in a structured, standardized way
- with repositories
ā¢ centralized (SVN, CVS)
ā¢ decentralized (GIT)
7. Why need versioning ?
ā¢ enables collaboration between developers
ā¢ centralized āmain codeā (trunk)
ā¢ custom code alongside main code (branching)
ā¢ eases release management (tags)
ā¢ rollback to previous revisions
ā¢ integration with other tools
8. Subversion (SVN)
ā¢ Subversion (http://subversion.tigris.org)
ā¢ more advanced than CVS
ā¢ less complex than GIT
ā¢ integrates well with other tools
(trac, gforge, jira, ...)
ā¢ supported by many tools
(Zend Studio, TortoiseSVN, Subversion CLI)
11. Code managing with SVN
ā¢ many developers create much code
ā¢- code is committed to a central repository
conļ¬icts trigger warnings
ā¢ user and groups can be deļ¬ned
ā¢ different versions can co-exist
ā¢ access management for named and anonymous
access rights
12. Subversion authentication
ā¢ svnserve server
$ svn svn://server/project/trunk
ā¢ svnserve server over SSH
$ svn svn+ssh://server/project/trunk
ā¢ Apache webserver
http://svn.server/project/trunk
13. Version management
ā¢ all code resides in ātrunkā
ā¢ code revisions are detached in ābranchesā
ā¢ snapshots for releases are ātaggedā
15. Putting a project into SVN
Say youāve started project FooBar with following ļ¬les:
/FooBar
/Foo.php
/Bar.php
To put it on a Subversion repository:
$ svn import -m ānew projectā FooBar http://svn.server/
FooBar/trunk
16. Getting code from SVN
A new team member needs to work on the FooBar project
He needs to get the project from Subversion
To get it from a Subversion repository:
$ svn checkout http://svn.server/FooBar/trunk FooBar
This will fetch the latest revision (HEAD) from the TRUNK
and creates a local FooBar directory
17. Updating code in SVN
After a well deserved holiday, you need to continue working
on the FooBar project
You need to get updates of the project from Subversion
To update your working copy from Subversion repository:
$ svn update /FooBar
This will update your working copy with the latest revision
(HEAD) from the TRUNK
18. Committing back to SVN
Youāre working hard on FooBar and you need to commit
your changes back to Subversion.
To commit changes back to Subversion repository:
$ svn commit -m āAdded some cool stuffā
This will commit changes in your code to the TRUNK.
19. Best practice
Update before committing
Update after committing
Commit small development chunks
Commit often
20. Release management
ā¢ a release is a snapshot of a version branch
ā¢ are being deployed to server environments
(DEV, TEST, ACC, PROD, ...)
ā¢- 2 common methods to release code
symlink deployment
- subversion export
21. Symlink Deployment
ā¢- On production server(s):
use release folders
svn co svn://server/myproj/tags/rel-1.0 /web/
myproj-rel-1.0
- create symlink to it
ln -s /web/myproj-rel-1.0 /web/myproj
ā¢ Pro:
- simple
ā¢ Contra:
- renaming folders on server
- enabling FollowSymlinks
22. Subversion Export
ā¢ Exporting a release from subversion
svn export http://svn.server/project/tags/
release-1.0.2
ā¢ Pro:
- scheduled (automated) upgrades possible
- no further modiļ¬cations necessary
ā¢ Contra:
- takes longer to switch back to previous release
26. Feature Branches
ā¢ code that changes many things in trunk
ā¢ are best put in a separate branch
ā¢ maintained by their developer(s)
ā¢- and merged back into trunk
after the merge, the branch is removed
ā¢ when changes are done and tested
27. Release Branches
ā¢ are maintained in branches
ā¢ have a long lifetime cycle (several years)
ā¢- differ from each other
because of new code base, framework, language
ā¢ have a common base = trunk
ā¢ ļ¬xes from versions go into trunk
ā¢ back port ļ¬xes go from trunk into version
28. Tags
ā¢ tags are snapshots
ā¢ usually made on version branches
ā¢ can also be made on ātrunkā
ā¢ are deployed to server environments
ā¢ are used to keep track whatās happened between
releases (change log)
29. More than just versioning
ā¢- Subversion provides more features
File portability
- Keyword substitution
- Locking
- Externals
- Peg and Operative revisions
- Network model
- Hooks
30. File portability
ā¢- Line endings differ on different OSās
are ignored when checking modiļ¬cations
ā¢- Mime-types differ from their extensions
binary and non-binary ļ¬les are tested on content
31. Keyword substitution
ā¢- Only a few keywords are substituted
$Date:$ āŗ $Date: 2008-10-22 20:00:00 +0100
(Wed, 22 Oct 2008) $
- $Revision:$ āŗ $Revision: 144 $
- $Author:$ āŗ $Author: svnusername $
- $HeadUrl:$ āŗ $HeadUrl: http://svn.test.be/trunk $
- $Id:$ āŗ $Id: ļ¬le.php 148 2008-10-22 20:00:00Z
svnusername $
32. Locking
ā¢- working copy locks
exclusive right to a working copy
- clears with āsvn cleanupā
ā¢ database locks
- ensures database integrity
- only admins can remove this lock
ā¢ conļ¬icts with the purpose of revision control
33. Externals
ā¢- Externals provide an easy way to
include other internal or external projects
- without having to care about their revisions
ā¢ Examples:
- Zend Framework as svn:externals on library path
- project that includes many smaller projects
34. Peg & Operative revisions
ā¢- automated handling of
moving ļ¬les
- deleting and creating new ļ¬les with same name
ā¢ Using speciļ¬c syntax
- $ svn command -r OPERATIVE-REV item@PEG-
REV
35. Network model
ā¢- Can run its own svnserve
pros: no dependencies, works with ssh for extra
security
- contras: need svnclient to connect
ā¢ Or in combination with Apache webserver
- pros: works with any http-client
- contras: overkill for small projects, requires
mod_dav_svn, more difļ¬cult to set up
36. Hooks
ā¢- Hooks facilitate actions to be taken
before a commit starts (validate rights)
- after a commit (send e-mail, update tracker, ...)
- before or after a revision change (notiļ¬cations)
ā¢ Can easily be incorporated with tools
- tracking tools
- integration tools (Lorna Janeās Nabaztag)
- mailing and logging systems
37. Hooks execute moments
ā¢- basic commit moments:
start-commit:
ā¢ runs before commit transaction started
- pre-commit:
ā¢ runs right before commit transaction is
promoted
- post-commit:
-
ā¢ runs after the commit transaction is ļ¬nished
...
38. Cool things w/ SVN hooks
Lorna Janeās Nabaztag
Responding on SVN commits
http://www.ļ¬ickr.com/photos/lornajane/2592602734/
39. Automated builds
ā¢- With SVN and Phing (PHP Build tool)
nightly checkout of code base
- running tools to enhance code
ā¢ PHPDocumentator (automated API docs)
ā¢ PHP_CodeSniffer (checks code for standards)
ā¢ PHPLint (checks code for syntax errors)
ā¢ PHPUnit (unit testing for PHP)
-
ā¢ ā¦
creating a package (including docs, tests, reports)
40. New features in SVN v1.5
ā¢ Merge tracking (foundational)
ā¢ Sparse checkouts (via new --depth option)
ā¢ Interactive conļ¬ict resolution
ā¢ Changelist support
ā¢ Relative URLs, peg revisions in svn:externals
ā¢ Cyrus SASL support for ra_svn and svnserve
ā¢ ... (more on http://subversion.tigris.org/
svn_1.5_releasenotes.html)
41. Summary
ā¢ manageable ļ¬le change history
ā¢ better collaboration between developers
ā¢ clearer release management
ā¢ more than one version of same code base
ā¢ easier to rollback in case of emergency
42. Recommended Reading
Version Control with Subversion, 2nd Edition
(OāReilley Media, Inc)
by C. Michael Pilato; Ben Collins-Sussman; Brian W. Fitzpatrick
also online: http://svnbook.red-bean.com
Managing Software Development with Trac and Subversion
(Packt Publishing)
by David J Murphy
43. Recommended Reading
Subversion Version Control:
Using the Subversion Version Control System in Development Projects
(Bruce Perens' Open Source Series)
by William Nagel
44. Credits
Wikipedia Logo
http://commons.wikimedia.org/wiki/File:Wikipedia-logo.png
45. Thank you !
Slides on Slideshare
http://www.slideshare.net/group/macqel
Give feedback on Joind.in
http://joind.in/1260