Finn Lindgren, SVN help

This document assumes that you are working in GNU/Linux. The procedures in Win/Cygwin are essentially the same. In Windows, the TortoiseSVN provides the same functionality through the right-mouse-button-menu in the file explorer.

SVN help

Documentation for every command is available via svn help, which lists all available commands. svn help command provides help for a specific command.

Retrieving a project for your workplace

Subversion (SVN) stores the entire revision history in a repository on the server Each author has a local copy of the files, and uses the svn client communicates with the server, which synchronizes the changes made by the different authors, via the central reposiory.

Before you start working, place the file config in the directory ~/.subversion/. If the directory does not already exist, run the svn once, to create it. This config file sets default values for file properties and date handling.

Every SVN command that interacts with the server needs to log in; if you want to avoid having to type your password multiple times, ask finn about configuring your SSH client to use SSH-keys instead.

Decide where to put your working copy of the project, here fms051 from the mc repository. Here, I'll assume ~/svn/mc/fms051/.
cd ~/svn/mc/
svn checkout svn+ssh:// fms051/
This will create a directory named ~/svn/mc/fms051/, which will be your local work copy of the project.

The update/edit/commit-cycle

To incorporate your co-authors changes into your local copy, run
svn update
which retrieves the latest versions from the repository, as well as any new directories.

Pay attention to the messages printed by the svn command; There may be conflicts between your local changes, and the versions in the repository, which have to be resolved before you enter your own changes into the repository. These are marked with the letter "C" in the listing of files affected by the update.

When you want to add your own changes to the repository, run
svn commit -m 'Brief modification description'

Always do an update before commit, to incorporate the modifications of others. svn will not accept a commit on a file with conflicting changes, until you have explicity told it that the conflict has been fixed, by running svn resolved filename

The basic work cycle is as follows:

  1. svn update
  2. Modify/Add new text to the files
  3. svn update
  4. svn commit -m 'This is what I did.'

Adding/removing files and directories

When you add or remove a file, SVN must be told about it.

Use svn add filename.ext to add a file filename.ext to the SVN system. SVN makes an effort to identify binary files, which must be treated differently from text files. Usually its guess is correct. The file must exist before adding it.

For directories, the command svn mkdir dirname creates a new directory, and tells SVN about it.

Use svn delete filename.ext to remove the file filename.ext. This will delete the files both from your local working copy and from SVN. The file and all its previous versions are kept in the repostitory, so it can be resurrected at a later time. This commands also works for directories.

The addition/deletion will not be visible to outher authors until you have committed the change.

Files and directories can also be copied, moved, and renamed (equivalent to a move).
svn copy filename.ext nameofcopy.ext
svn move filename.ext newname.ext
This copies/moves the file, in the same manner as the shell commands cp and mv.

File and directory properties

[TODO: How and why to use properties.]

Course management with "make"

Some Mat.Stat. courses are handled with SVN. To simplify and semi-automating the tasks of synchronising the repository with the central web and matlab directories, one (or more) Makefile:s are available.

Accessing the version information

Every commit to the SVN repository is identified with an autoincremented number. (This is different from CVS which assigned different version numbers to each file).

To see the commit messages for the entire history of a file, use
svn log filename.ext

svn diff filename.ext displays the difference between the latest seen repository version, and your local work copy. You can access the differences to a specific revision with the option -r:
svn diff -r1374 filename.ext

To see a list of the status of your working copy:
svn status
This shows modified files ("M") and files not under SVN control ("?") that you have not told it to ignore via the svn:ignore property. The config file above sets global ignores for your svn client, but since this is based on the client, other authors are helped by naming patterns such as *.aux *.dvi explicity in the svn:ignore property for directories with LaTeX files.

Creating a repository

CVS stores the entire revision history in a repository.

[TODO: How to create a repository.]

Creating a new project

[TODO: How to create a new project from existing files.]