3. Working with Subversion

The usage of Subversion from the command line is very similar to that of CVS. The access to the repository is like following:


  $ svn co svn+ssh://your-afs-username@savannah.psi.ch/afs/psi.ch/project/meg/svn/meg/trunk/megmc megmc
  $ svn co file:///afs/psi.ch/project/meg/svn/meg/trunk/megmc megmc

To get started you need to have read/write access to an AFS directory at PSI. Access to the repository at PSI is supported via direct access and via a Subversion gateway. Direct access to the repository is possible from anywhere in the world provided that as AFS client is running on the client system. The gateway allow to access the repository using either an AFS account or an anonymous account. The Subversion gateway is hosted as savannah.psi.ch. Currently only svn+ssh protocol is supported for access via savannah.psi.ch. In this section shown are brief usage of svn commands: checkout, update, commit, status and resolved. Please refer The Subversion Book for details.

3.1 Checkout the Repository

The first step to work with a Subversion repository is to get a working copy of the repository. It is an ordinary directory tree on your local system, containing a collection of files. Your working copy is your own private work area. You can edit these files or compile them as usual way. To get a working copy, you need check out the repository or its subtree. Checking out a repository with direct access will look like:

  $ svn co file:///afs/psi.ch/project/meg/svn/meg/trunk/megmc megmc

You will have a megmc directory, which is the working copy of the repository, with additional directory -- .svn which holds the extra information needed by Subversion. Checking out a repository via the gateway will look like:

  $ svn co svn+ssh://your-afs-username@savannah.psi.ch/afs/psi.ch/project/meg/svn/meg/trunk/megmc megmc

where your-afs-username is your AFS account name. You may asked for the AFS password as much as three times. There is a
workaround for this.

An anonymous Subversion checkout via the gateway will look like


  $ svn co svn+ssh://svn@savannah.psi.ch/afs/psi.ch/project/meg/svn/meg/trunk/megmc megmc

where svn is the anonymous account, whose password is svn.

3.2 Web Interface to the Repository

There are two web interface to the Subversion repository. What you can do via the web interface is: download a tar-ball of a sub-tree of a repository, browse each file, make a diff of two revisions, and more.

One is called ViewCVS. You can browse the meg repository from http://savannah.psi.ch/viewcvs/?root=meg, while its access is restricted from outside of PSI for the meantime.

The other is WebSVN, which will be installed sooner (I hope) to the gateway.

3.3 Update Your Working Copy

To bring your working copy up to date, you can ask Subversion to update. This will merge changes done by others into your working copy.

  $ svn update megmc

You're probably used to using cvs update to see what changes you've make to your working copy. In Subversion, svn status will give you al the information needed regarding what has changed in you working copy, without any access to the repository. svn update does just that. It updates your working copy but does not show you the status you need.

3.4 Commit Your Changes

Suppose you make changes to megmc/gem/xecal/src/xechit.F. Since the .svn directory remembers the file's modification date and original contents Subversion can tell that you've changed the file. You will need to commit to publish your change to others:

  $ svn commit megmc/gem/xecal/src/xechit.F

or

  $ cd megmc/gem/xecal/src
  $ svn commit xechit.F

If you have changed more than one file, you can commit directory like following:

  $ svn commit megmc/gem/xecal/src/

3.5 Revisions and Histories

An svn commit operation reflects on the repository your changes to any number of files and directories as a single transaction. Each time the repository accepts a commits, this creates a new state of file-system tree, called a revision. In subversion, a revision number applies to the whole repository, while in CVS, each file has a revision number. Thanks to its atomic commit in Subversion, you can easily trace back the history like file have been modified, added or removed in a commit as following:

  $ svn log -v megmc

while is CVS it is not that easy. One of the easiest way was to list up the modified, added and removed files in the log, which is no longer needed in Subversion.

3.6 Resolving Conflicts

Suppose you make changes to filename and you're going to update. When somebody other than you are also changing the same file as you, sometimes those two changes cannot be merged by subversion. Such a conflict needs to be resolved by a human (i.e. you). At this point Subversion will not allow you to commit the file filename until the conflict is resolved. You need to do one of three things: Once you have resolved the conflict, you need to let Subversion know by running

  $ svn resolved filename

This removes three temporary files and Subversion no longer considers the file to be in a state of conflict.
Prev
Installing Subversion
Up
Table of Contents
Next
Guidelines