| Department of Computer Science | University of San Francisco |
|---|
Subversion is an open source ``revision control system.'' It's used primarily for keeping a record of a software development project. It's main purpose in CS 220 is to provide a convenient location in which you can store your programs and homework assignments. Note that you must use the directory structure outlined here for your projects.
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/peterSo 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 cs220
$ svn mkdir https://www.cs.usfca.edu/svn/peter/cs220 -m 'add cs220 dir'
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. I prefer vi. So I've added the following line to my .bash_profile file:
export SVN_EDITOR=vi
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-23 12:44:48 -0800 (Wed, 23 Aug 2011) | 1 line add cs220 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/cs220This will create a cs220 subdirectory in your home directory (or wherever you changed to), and you can create subdirectories of it for each of your programs:
$ cd cs220
$ mkdir p1 p2 p3 p4 p5
$ mkdir h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12
$ svn add *
A h1
A h10
A h11
A h12
A h2
. . .
A p1
A p2
A p3
A p4
A p5
$ svn commit -m "create program and homework directories"
Adding h1
Adding h10
Adding h11
Adding h12
Adding h2
. . .
Adding p1
Adding p2
Adding p3
Adding p4
Adding p5
Committed revision 2.
$ svn ls https://www.cs.usfca.edu/svn/peter/cs220
h1/
h10/
h11/
h12/
h2/
. . .
p4/
p5/
Now just to be sure everything's fine, create a bogus prog1.c in the p1 directory, add it and commit it.
$ cd p1
$ cat > prog1.c
#include <stdio.h>
int main(void) {
printf("hello, world\n");
return 0;
}
Ctrl-D
$ svn add prog1.c
A prog1.c
$ svn commit -m "create bogus prog1"
Adding p1/prog1.c
Transmitting file data .
Committed revision 3.
$ svn ls https://www.cs.usfca.edu/svn/peter/cs220/p1
prog1.c
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/