Department of Computer Science University of San Francisco


Computer Science 110-03
Setting Up and Using Subversion
Lab 1, Part B
Fall 2011

Subversion is an open source ``revision control system.'' It's used primarily for keeping a record of a software development project. In CS 220 we'll use it as a way for you to store your programs and lab assignments in a place where they can be graded. Note that you must use the directory structure outlined here for your programs and labs.

Subversion consists of three main components: a server computer, the Subversion server software, and the subversion client software. The basic idea is you do your work (e.g., programming) on whatever computer is convenient. A special CS department server stores a copy of your work. When you modify an assignment, you use the client software to tell the server software to update the copy stored on the server. In addition to storing the latest version of the assignment, the server will store all earlier versions of the assignment. So if, for example, you decide that the changes you just made to your assignment were a bad idea, you can retrieve an earlier version from the server.

All of the CS Department computers have the Subversion client software installed in the Linux partition. However, if you're using your own computer, you may need to install a copy. Source and binary versions for most common architectures can be downloaded from

   http://subversion.apache.org/packages.html

Each USF CS student has a directory on the Subversion server. It can be accessed over the internet. As an example, if your CS user id is peter, your CS subversion directory is accessible at

   https://www.cs.usfca.edu/svn/peter
So once you are logged on to a machine with the Subversion client software installed, the first thing you should do is create a subdirectory for cs110
   $ svn mkdir https://www.cs.usfca.edu/svn/peter/cs110 -m 'add cs110 dir'
   Authentication realm:  test
   Password for 'test': 
   
   -----------------------------------------------------------------------
   ATTENTION!  Your password for authentication realm:
   
       test
   
   can only be stored to disk unencrypted!  You are advised to configure
   your system so that Subversion can store passwords encrypted, if
   possible.  See the documentation for details.
   
   You can avoid future appearances of this warning by setting the value
   of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
   '/home/test/.subversion/servers'.
   -----------------------------------------------------------------------
   Store password unencrypted (yes/no)?

Go ahead and type ``yes''.

Note: In this document the dollar sign ($) denotes the shell-prompt. You shouldn't type it in. Of course, you need to replace "peter" with your actual CS user id.

Note: On CS department machines "www.cs.usfca.edu" can be abbreviated to "www".

Subversion is somewhat fussy about documentation: pretty much every time you execute a subversion command that updates the subversion repository, Subversion wants to know what you've done. You can deal with this by adding a string after '-m'. Alternatively, you can get Subversion to prompt you for the documentation string by throwing you into an editor. Before this will work, you'll need to tell Subversion which editor you use. For example, if you use gedit you would add the following line to your .bash_profile file:

   export SVN_EDITOR=gedit

You can see a record of the Subversion commands you've executed by typing

   $ svn log https://www.cs.usfca.edu/svn/peter
   ------------------------------------------------------------------------
   r1 | peter | 2011-08-24 12:44:48 -0800 (Wed, 24 Aug 2011) | 1 line

   add cs110 dir
   ------------------------------------------------------------------------

Now change to the subdirectory of your home directory where you want your CS 220 programs to reside. For example,

   $ cd ~
and check out your CS 220 subversion repository
   $ svn co https://www.cs.usfca.edu/svn/peter/cs110
   Checked out revision 1.
This will create a cs110 subdirectory in your home directory (or wherever you changed to), and you can create subdirectories of it for each of your programs:
   $ cd cs110
   $ mkdir p1 p2 p3 p4 p5
   $ mkdir l1 l2 l3 l4 l5 l6 l7 l8 l9 l10 l11 l12
   $ svn add *
   A         l1
   A         l10
   A         l11
   A         l12
   A         l2
     . . . 
   A         p1 
   A         p2 
   A         p3 
   A         p4 
   A         p5 
   $ svn commit -m "create program and lab directories"
   Adding         l1
   Adding         l10
   Adding         l11
   Adding         l12
   Adding         l2
     . . . 
   Adding         p1
   Adding         p2
   Adding         p3
   Adding         p4
   Adding         p5

   Committed revision 2.
   $ svn ls https://www.cs.usfca.edu/svn/peter/cs110
   l1/
   l10/
   l11/
   l12/
   l2/
   . . .
   p4/
   p5/

Now just to be sure everything's fine, create a lab 1b file lab1b.py in the l1 directory, add it and commit it.

   $ cd l1
   $ cat > lab1b.py
   print "hello, world"
   ^D
   $ svn add lab1b.py
   A         lab1b.py
   $ svn commit -m "create lab1b"
   Adding         l1/lab1b.py
   Transmitting file data .
   Committed revision 3.
   $ svn ls https://www.cs.usfca.edu/svn/peter/cs110/l1
   lab1b.py

You're set. Each time you finish an edit session, you should "commit" your changes, and each time you want to create a new file or directory, you should "add" the new file.

There's a lot more that you can do with Subversion. If you're interested check out the Subversion home

   http://subversion.apache.org/
and the Subversion book
   http://svnbook.red-bean.com/



Peter Pacheco 2011-08-29