Version Control Using Subversion Tom Hilinski Natural Resource Ecology Laboratory Colorado State University October “Software”, “Knowledge Base”, “Software Development Notes”
Version Control - Contents What is it? Why use it? Repository structure About Subversion Repository URLs Creating a repository Work cycle Deleting repository Exporting Using Tags Using Branches Other Topics Subversion Tools Additional Information
What is Version Control?
Why Use Version Control? Concurrent editing with conflict resolution Synchronize files on different computers Versions for different audiences Version with different algorithms History and justification Backup Source control
Repository Structure Make a directory to hold your repositories. Repository subdirectories: trunk = main set of files branches = new development (temporary) or different algorithms (permanent) tags = labeled trunk points-in-time /data/ojima/svn-repos/IRC_Century5/ trunk/ Ecosystem/ Numerical/... branches/... tags/...
About Subversion Commands: svn, svnadmin, svnlook Open-source project - Apache/BSD-style license Successor to CVS (“a better CVS”) Safe “atomic” commits Standalone or networked client/server Tracks file contents; directories; copy, rename, move actions; metadata Binary file version control Multiplatform
Repository URLs Directory: /data/ojima/svn-repos/respos-name URL from NREL: file:///data/ojima/svn-repos/respos-name/ URL from outside CSU: /data/ojima/svn-repos/respos-name/
Creating a Repository Example 1. Create a directory to hold repositories: mkdir ~/dev/svn-repos cd ~/dev/svn-repos 2. Create the repository: mkdir myproject svnadmin create myproject svn mkdir URL/trunk URL/branches URL/tags 3. View the directory tree: svnlook tree myproject 4. Add ( svn add ) or import ( svn import ) files.
Work Cycle with Subversion First step - checkout files: svn co Modify files What's changed? svn status, svn diff Add file/directory: svn add Delete file/directory: svn delete Rename/Move: svn move Merge changes Add other's changes: svn update Conflicts resolved: svn resolve Add your changes: svn commit Next day first thing: svn update Continue modifying files.
Deleting Repository & CO'd Files Delete a repository: From the OS rm -Rf ~/dev/svn-repos/myproject/* Delete all checked-out files: From the OS rm -R ~/dev/myproject/*
Exporting From Repository Exporting copies directories and files from a Subversion repository. Exported files are not under version control. Exported directories do not have hidden Subversion subdirectory “.svn” Useful for sending a “clean” package of files, or archiving elsewhere. svn export file://repos-path/trunk/ ~/myproject/archive/ /
Using Tags Tags are a read-only copy of trunk or a branch. Act as a label for release, bug-fix, algorithmic change, etc. Using svn copy, stores only pointers to trunk. Create: svn copy file://repos-path/trunk file://repos-path/tags/release Export from a tag: svn export file://repos-path/tags/release ~/release/ /
Using Branches Branches begin as a copy of trunk at a point in time. Useful for: Make modifications w/out affecting trunk. Add algorithms/documents for a special version. Begin a new release with its own bug fixes. Disadvantages: Increased complexity – risk of spaghetti-azation. Merging bug-fix branch requires more effort. Using svn copy, stores only pointers to trunk.
Other Topics Editing conflict resolution Reverting to a previous version Merging branches Sharing files between repositories Incorporating third-party files Repository backup Configuring Subversion Comparison to CVS, RCS, SCS, etc. Repository mirrors
Subversion Tools svn, svnadmin, svnlook Cygwin for Microsoft Windows: cygwin.com TortoiseSVN integrates with Microsoft Windows RapidSVN client is multiplatform Ksvn for Linux/KDE Subclipse plug-in for Eclipse Framework
Additional Information Subversion web site: subversion.tigris.org The Subversion Book: svnbook.red-bean.com TortoiseSVN: tortoisesvn.tigris.org IRC and Century5: Subversion Quick Guide public/Documents/ KnowledgeBase/SubversionQuickGuide.htm