Sections
In this section
Computational Science and Engineering

174 Geology/Physics
UC Davis
One Shields Avenue
Davis, CA 95616

(530) 752-6298 phone
(530) 752-8894 fax

 
Personal tools

Use Subversion at CSE

How to use Subversion at CSE

Purpose

This document is designed for anyone using the Subversion server at CSE.

What is Subversion?

The Subversion project is a version control system aimed at replacing CVS in the open source community. It is a very useful tool and we encourage anyone writing source code to use Subversion or its equivalent.

Why should I use version control system?

Do you maintain backups of your source code? If you make a change to your code that causes a regression can you revert back to previous versions? Can you get to your code from any computer that has access to the internet? Can you visualize your project in a web browser? Can other people contribute code or documentation to your project? If you answered no to any of these questions you should consider using a version control system.

Why should I use CSE's Subversion server?

Of course there are many reasons to use our server but here are a few that might not be apparent.

Security

Our server is very secure. Exactly two people have physical and root-level access to the machine. There are exactly zero users that have shell-level access to the machine. The operating system is virtualized using Xen and running the latest patches. Your login information is never sent to our server so even if someone were to compromise our server they still would not be able to control your account.

High Availability

We do not currently offer a redundant high available setup for this server but we do have the machine on a battery UPS and since we are using Xen if the hardware fails we will be able to migrate the server onto new hardware within a considerably shorter time than non-virtualized machines. The server is designed to be always on and uptimes of more than 6 months is common.

Backups

The source code repositories and trac databases are backed up nightly to a different machine in the same room. We hope to backup this data to a different machine in a different building as soon as possible. We keep two full backups of this data.

Campus Integration

The server is completely integrated into the campus authentication. We use CAS for web browser authentication. We use Kerberos for SVN authentication. This means that you can use your campus account for access to this resource.

Step by step

This section describes how to use Subversion and Trac at CSE.

Create a New Project

If you would like to start using the CSE subversion server all you need to do is send the following information to technical support and we will create your project.

  • Your project name (please be detailed and include any preferred short name where the short name contains no spaces or special characters)
  • Who should be modifying the documents stored in subversion (CSE affiliates only, campus affiliates only, or anyone in the world)
  • Who should be modifying the wiki and or tickets in trac (CSE affiliates only, campus affiliates only, or anyone in the world)
  • Should anonymous internet users be allowed to read source code?

Authenticating with Kerberos

Assuming your repository is tied to campus Kerberos you may need to make a few changes to your set up to get things working.

Install Kerberos

Installing Kerberos is mostly outside the scope of this document but in the case of Ubuntu all you'll have to do is apt-get install krb5-user.

Installing the Configuration

After you have kerberos installed you just need to point your configuration to the campus servers. Make sure you have the following in your krb5.conf

[libdefaults]
default_realm = UCDAVIS.EDU
...
[realms]
UCDAVIS.EDU = {
kdc = auth1.ucdavis.edu
kdc = auth2.ucdavis.edu
admin_server = auth1.ucdavis.edu
}
...
[domain_realm]
.ucdavis.edu = UCDAVIS.EDU
ucdavis.edu = UCDAVIS.EDU

Logging in

Once you have your configuration installed you can login. To login just type kinit <username>. Here is an example:

sbeards@shell:~$ kinit sbeards
Password for sbeards@UCDAVIS.EDU:
sbeards@shell:~$ klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: sbeards@UCDAVIS.EDU

Valid starting Expires Service principal
11/16/07 09:41:51 11/17/07 09:41:51 krbtgt/UCDAVIS.EDU@UCDAVIS.EDU


Kerberos 4 ticket cache: /tmp/tkt0
klist: You have no tickets cached
sbeards@shell:~$

Logging out

Once you are done you can logout of kerberos using the kdestroy command. Here is an example:

sbeards@shell:~$ klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: sbeards@UCDAVIS.EDU

Valid starting Expires Service principal
11/16/07 09:41:51 11/17/07 09:41:51 krbtgt/UCDAVIS.EDU@UCDAVIS.EDU


Kerberos 4 ticket cache: /tmp/tkt0
klist: You have no tickets cached
sbeards@shell:~$ kdestroy
sbeards@shell:~$ klist
klist: No credentials cache found (ticket cache FILE:/tmp/krb5cc_0)


Kerberos 4 ticket cache: /tmp/tkt0
klist: You have no tickets cached
sbeards@shell:~$

Repository Organization

You can organize your project in any way you wish, but we have some recommendations in this area. We recommend using a base directory for the trunk, tags and branches. Once you know your project's short name (aka project_shortname) you can execute the following commands to set up your repository.

    $ svn co https://svn.cse.ucdavis.edu/repo/project_shortname # check out the project
$ cd project_shortname
$ svn mkdir trunk
$ svn mkdir tags
$ svn mkdir branches

Trunk

The trunk should be used for importing your code for the first time. This is where the main stream of development (also know as the HEAD) is located. To check something out of the trunk use the following command.

    $ svn co https://svn.cse.ucdavis.edu/repo/project_shortname/trunk project_shortname

Tags

Tags are a great way to make snapshots of an entire source tree. You are essentially copying a tree to another directory. Many find that it is helpful to name versions using tags (ie release-1.0.2) or to name feature bases with tags (ie pre-loop-optimization). To tag the trunk use something similar to the following command.

    $ svn copy https://svn.cse.ucdavis.edu/repo/project_shortname/trunk \
https://svn.cse.ucdavis.edu/repo/project_shortname/tags/release-1.0.2 \
-m "Tagging the 1.0.2 release"

Branches

You can use branches to keep track of major forks in the code. Imagine you are planning to implement a particular module in a new way but you don't want to stop development on the old code. You can branch the code, test your changes and once it is stable you can merge the changes back into the trunk. To branch the trunk use something similar to the following command.

    $ svn copy https://svn.cse.ucdavis.edu/repo/project_shortname/trunk \
https://svn.cse.ucdavis.edu/repo/project_shortname/branches/with-assembly \
-m "Branching the trunk. Investigating performance improvements using inline assembly code."

Using Subversion

Although there are a lot of more valuable resources available on the web here are a few shortcuts.

The Initial Import

Once the project has been added, and you have determined the repository organization you are ready to import your code. Run the following to import the code in your current directory into the trunk.

    $ svn import . https://svn.cse.ucdavis.edu/repo/project_shortname/trunk -m "Initial Import"

Checking Out

If you want to change the source code you have to first check it out. You checkout code before you work on it to make sure you are working with the latest version. Run the following to checkout the trunk of project project_shortname into a directory called abc.

    $ svn co https://svn.cse.ucdavis.edu/repo/project_shortname/trunk abc

Checking In or Commiting

So you have changed the source code and you want to submit the changes to the Subversion server. This process is called checkin code in (aka committing code). Run the following to check in the your code. This command assumes you have first checked the code out. The argument to -m is a message describing the changes you have made.

    $ svn ci -m "updated module a to use inline assembly"

Using trac

trac is an enhanced wiki and issue tracking system for software development projects. Trac uses a minimalistic approach to web-based software project management. It's mission is to help developers write great software while staying out of the way. By default we have a trac installation for each project we host. The base URL for trac is https://svn.cse.ucdavis.edu/trac/. Append your project_shortname to get to your project's trac installation.

Further Help

Here are a few websites offering more help on the topic of version control, subversion and trac.