Skip to content

CSWIM

Sections
Personal tools
You are here: Home » Guides » Subversion Howto

Subversion Howto

Document Actions
A brief introduction to the Subversion revision control system, with links to deeper resources.

Basic Subversion for SWIM

Subversion (svn) is essentially the next generation of the Concurrent Version System (cvs), and CVS users will find it works very similarly. This documentation assumes that you understand the basic concepts of version control, as embodied, for example, in CVS. For more details, consult the Subversion book (URL below) or Google for other resources.

In the examples below, we will refer to the IPS code repository on the SWIM web site.

Getting Subversion

Linux
Most relatively new installations probably have it installed. Check for the "svn" binary. If not, you can download the latest version from the Subversion web site, below.
Mac
Sorry, no experience.
Windows
The TortoiseSVN client is generally recommended. See URL below.

Checking Out a Repository

svn checkout repositoryURL path

Example: svn co https://cswim.org/svn/cswim/ips/trunk ips

Note: "co" is a synonym for "checkout".

Subversion always refers to a repository using a URL. It may be to a web server (http or https protocols), a local file (file protocol), or Subversion's own internal protocol (svn protocol).

You will be prompted for a username and password for authentication (it is also possible to use ssh in conjunction with the svn protocol, as many CVS users are accustomed to doing). For repositories under https://cswim.org/svn/cswim you should authenticate with the same username and password you use for the SWIM web site.

Note that if the username you use to authenticate on the Subversion server is different from the one you're using on the client system, you may have to put that into the URL, such as https://username@cswim.org/svn/cswim/.

Note that when using the https protocol, the connection is secured with SSL, and you may see messages about the server's certificate. These are the same as you would see in a browser when connecting to the site, and should be treated the same way.

The example URL can be broken down as follows:

https://cswim.org/svn/cswim/
This is the location of the SWIM project repository on our server.
ips/
This is the subproject.
trunk
This means we're going to work with the main branch of development, which is also known as the trunk. By convention, Subversion projects have trunk, branches, and tags directories at this level. More advanced uses of version control include using branches to allow parallel development while minimizing conflicts, and tagging specific configurations of code for later reference, such as specific releases which might be posted to a web site. The branches and tags directories are conventional locations to store such versions of the repository.

The final "path" argument is optional, and is used to set the directory name for your working copy. The default is to use the last element in the URL. However if you follow the conventions noted above, you'll end up with a lot of directories called "trunk", which isn't very meaningful.

Basic Subversion Commands and Workflow

Here are brief descriptions of some of the most commonly used Subversion commands. For more details try svn *command* --help or the Subversion book (URL below).

svn status
Shows current status of files in working directory relative to the repository. Similar to cvs update -n.
svn update
Updates the working directory from the repository. Similar to cvs update.
svn commit --message <message> [files]
Commits local changes into the repository. Note: "ci" is a synonym for "commit". Files must be up to date with respect to the repository.
svn revert file
Abandon local changes by reverting to a pristine version from the last checkout/update. Can also be used to abandon operations like file addition/removal before they are committed to the repository.
svn add, svn delete, svn mkdir, svn move
Do what you would expect from their names. Note that in Subversion, directories are version controlled and renaming operations of files or directories can be done with move to preserve history. These are not features found in CVS.
svn import
Recursive addition of a tree of files to a repository.

Key Differences between CVS and Subversion

  • Versions are global. Whereas in CVS, each file had an individual version number, in Subversion, the entire repository has a single version number. The version number is a simple integer, and is incremented with every svn commit operation. Thus, it is common to see references to version numbers like "5263" for Subversion-managed codes.
  • Subversion has atomic changesets. This is a corollary to the fact that version numbers are global. All of the changes made in a single commit operation are treated as a single revision to the repository.
  • Subversion manages directories as well as files
  • Subversion understands renaming of files and directories

Resources

Subversion project web site
http://subversion.tigris.org/
TortoiseSVN (Subversion client for Windows)
http://tortoisesvn.tigris.org/
Version Control with Subversion (online version of book)
http://svnbook.red-bean.com/
Subversion for CVS Users
http://svnbook.red-bean.com/nightly/en/svn.forcvs.html

http://svn.collab.net/repos/svn/trunk/doc/user/cvs-crossover-guide.html

Subversion Best Practices
http://svn.collab.net/repos/svn/trunk/doc/user/svn-best-practices.html
SVN for NIMROD Users
http://fusion.txcorp.com/~kruger/seattle06/SVNnotes.html
Created by bernhold
Last modified 2010-10-28 13:39