User Tools

Site Tools


svn

This is an old revision of the document!


Subversion

Subversion is an open-source control version system that is a compelling replacement for CVS. At least the client version is installed by default on all our Linux machines, and can be easily installed on Macs via fink or macports. The basic idea is to keep a master copy of your source files in a repository where the subversion also keeps track of all the (committed) modifications to the files. For editing a file, one have to check it out (e.g. get a local copy) from the repository. Once the editing is done, the modifications are committed back to the server. This allows more than one person (or the same person on many computers) to work on the same set of files because they are actually working on their local copy of the files. When a user commits his changes, the files he has been editing might have been changed (and committed) by another user in the mean while. In this case, subversion merges the changes automatically unless it detects a conflict (e.g. two user having changed the same line of code). Everyone can create his own subversion repository in his homedirectory with the following command:

svnadmin create --fs-type fsfs DIRECTORY_NAME

where DIRECTORY_NAME name could be for example /home/cangiani/SVN

Standard connection methods for our central repositories

For group projects, it is better to use the common repository which is

  • for algo: svn+ssh://USERNAME@clusteralgo.epfl.ch/SVN/trunk
  • for licos: svn+ssh://USERNAME@lth.epfl.ch/svnlicos/
  • for lth: svn+ssh://USERNAME@lth.epfl.ch/svnlth/
  • for lcm: svn+ssh://USERNAME@lth.epfl.ch/svnlcm
  • for arni: svn+ssh://USERNAME@lth.epfl.ch/svnarni

Quick User Guide

Almost everything is done with the svn command. In fact it is a super command as it accepts many internal commands. Note that in this section, all the lines starting with xxxx> are commands that I typed in as an example. By URL , I mean a repository address as, for example svn+ssh: USERNAME@licos.epfl.ch/SVN/trunk. Arguments in square brackets are optionals. All commands that do not need an URL are going to be used from withing a local copy under version control. <note> For a guide of CVS to SVN command follow this link. </note>
The most common svn commands are:

svn help [command name]

I think you've guessed what it is for. Use it !

svn list URL

to list the content of the [remote] repository. For example:

licos>svn list svn+ssh://cangiani@licos.epfl.ch/SVN/trunk
web/
licos>svn list svn+ssh://cangiani@licos.epfl.ch/SVN/trunk/web
.htaccess.wait
BioReadingGroup/
Papers/
TODO
courses/
css/
error/
img_base/
inc/
index.php
licos/
proj/
pubs/
research/

svn checkout URL [localdir]

to get a local copy of [part of] the repository. For example, with

licos> cd public_html
licos> svn checkout svn+ssh://cangiani@licos.epfl.ch/SVN/trunk/web licos

I would get a copy of the licos web site in my public_html/licos directory so that it can be seen from http://licos.epfl.ch/~cangiani/licos. The licos directory name above is not mandatory. If omitted svn will just use the name of the last directory in the repository (in this case “web”). Now that I have my local copy under version control I can run all the following commands.

svn status [-u]

checks the status of my local copy. Without the -u option it only works locally so it does not tell if some of the file was modified in the repository. Still very useful to see what files I have modified. The command output something only if there is something interesting to say. No output means that there are no changes. For each changed file flag letters appears on the left (see svn help status for a full list). The most common letters are M for locally modified, A for locally added, D for locally deleted, * if a newer version exists in the repository, ? if the file is not under version control (either it is a generated file such as a .o or .dvi file, or you just forgot to add it to the repository), C if there are conflicts (and that's bad). For example (this is the algo web site):

algo>svn status
M      intro.php

algo>svn status -u
      *     1552   contents/output/diplomapr/baldanza_2005.pdf
      *     1552   contents/output/diplomapr
      *     1552   contents/output/diplomapr.html
      *     1552   contents/group/members.html
      *            contents/proj/y5/06-01.html
      *     1552   contents/proj/y5
      *     1552   contents/proj/diploma.html
      *     1552   contents/proj/y3.html
      *     1552   contents/proj/y5.html
      *     1552   contents/proj/mathsem.html
M            1552   intro.php

This tells me that I've modified (M) the file intro.php and that various other files are newer (*) on the repository.

svn update [filename]

take new version of the file (of of all files if no filename is given) from the repository. It can happens that a file was modified on the repository, but also in your local copy. In this case, subversion tries to merge the two version. If it cannot, then a conflict is generated and you'll have multiple copies of the same file. You will need to resolve the conflict by choosing the correct version of the file, and running svn resolved [filename].

svn commit -m "mandatory comment about your modifications" [filename]

commit your changes: send a copy of the files that you've modified back to the server. In case, there are files in the repository that are newer than those being committed, the commit will fail and you will have to first update your copy (and eventually resolve the conflicts).

svn add filename

schedule a local file for being added to the repository. The file will be actually added only when you commit your changes.

svn delete filename

schedule a file for “deletion” in the repository. The file is also immediately removed from your local copy. Note that under subversion file are never deleted from the repository. They are only deleted from the current version of the repository. You can always checkout an older version and have your file back.

svn rename old_filename new_filename
svn rename -m "mandatory message" old_URL new_URL

rename a file or a directory either locally (that is schedule the change for the next commit) or directly on the repository.

svn log filename

prints the history of a file. Each time the file was modified and committed a new version number (rXXXX) and a the -m “comment” is attached to it. Example:

algo>svn log tunnel.cpp
------------------------------------------------------------------------
r1548 | cangiani | 2006-08-25 14:57:10 +0200 (Fri, 25 Aug 2006) | 1 line

minor bug fixes
------------------------------------------------------------------------
r1544 | cangiani | 2006-08-24 13:58:17 +0200 (Thu, 24 Aug 2006) | 1 line

Implemented multiple file streaming in sserver
------------------------------------------------------------------------
r1515 | cangiani | 2006-08-02 15:17:16 +0200 (Wed, 02 Aug 2006) | 1 line

Nicer output again (removed useless debug messages)
------------------------------------------------------------------------
r1397 | cangiani | 2006-06-15 10:45:57 +0200 (Thu, 15 Jun 2006) | 1 line

changed loss rate log
------------------------------------------------------------------------
r1376 | cangiani | 2006-06-13 11:06:10 +0200 (Tue, 13 Jun 2006) | 1 line

Trying to fix the sserver 15 minutes crash bug. Now sclient seems to be
more robust against sserver restart
------------------------------------------------------------------------
r1357 | cangiani | 2006-06-12 11:18:43 +0200 (Mon, 12 Jun 2006) | 1 line

Added option for skipping to the end of the input file (good for live
buffers, in particular, when sserver crashes). Added control for
resetting internal block index if the block index in the incoming packet
is much smaller (ib-ibcheck>5) than internal block index. This can
happen if sserver has crashed and was relaunched
------------------------------------------------------------------------

Personal Repositories

you can always create a personal repository in your homedir by doing:

  1. ssh into server:
    ssh lth.epfl.ch
  2. create an empty repository:
    svnadmin create <name_of_repository>
  3. use the standard svn subcommands to checkout, list or commit to the repository

General Repositories

General repositories, that needs to be available under

ssh+svn://lth.epfl.ch/svn<LABNAME>/<REPOSITORY>

can be created only by the System Administrators.
To create a general repository you need to send an email with these informations:

  1. name of the repository
  2. list of users that need access to it
  3. visibility:
    1. Private: The repository can be private (the only way to access it is through the svn commands)
    2. Public: The repository can be accessed through the web interface

Few general recommendations

  1. try to import into subversion ONLY the SOURCES and not the files that are generated from the sources; use Makefiles for automatically generating dependent files from sources.
  2. try to keep the repository as clean as possible. If the repository is shared among various users, it is better to meet once and agree on a common strategy for file/directories naming schemes;
  3. Unless you have a good reason, do not commit incomplete or buggy files;
  4. Important: filesystem compatibility. Like any other file synchronizer, SVN gets into troubles when you try to synchronize (i.e., checkout or update) a directory where you you make explicit use of case sensitiveness for file names. While filesystems on linux (and most unix variants) are case sensitive, all filesystems on Windog and the default one on Mac OsX are case insensitive. This means, for example, that file fig1.eps and file Fig1.eps are two distinct files under Linux, but they are mapped to the same physical file, and therefore they cannot co-exist under OsX.

Various Tips & Tricks

Global Configuration

Every user has a personal global SVN configuration file which resides in ~/.subversion/config. This file defines options that are valid for all repositories that the user works with.

The two most useful options are probably global-ignores and autoprops. global-ignores defines a list of filename patterns that Subversion will ignore. For example, you can set it to

global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store \
 .*.swp *.dvi *.aux *.log *.bbl *.blg *.idx *.ind *.ilgglobal-ignores = *.o *.lo *.la #*# 

to ignore the specified files. The command svn status will then no longer display these types of files preceded with a question mark if they are not in a repository. One should be careful with *.log as its possible there are files other than LaTeX processing files which end in .log. To see which files are being ignored in a given directory, type

svn st --no-ignore

The option autoprops causes Subversion to automatically set pre-defined properties for files whose names satisfy a given pattern. For example,

[auto-props]
*.m = svn:keywords=Id
*.tex = svn:keyword=Id

makes Subversion to automatically set the Id keyword for all .m and .tex files that are added to a repository. (The Id keyword tells Subversion that the string $Id$ in a file should be expanded to something like

$Id: sufficiency.tex 372 2008-02-11 16:10:53Z kleiner $

Per-Directory Ignore List

While the global-ignores option explained above already covers a lot of cases, there are situations where you want Subversion to ignore a file that you cannot put in the global ignore list. For example, in a directory that contains a tex file, you'll want Subversion to ignore the corresponding ps or pdf files. Since you don't want Subversion to ignore all ps and pdf files everywhere, you cannot use global-ignores. However, each directory in a Subversion repository has its own ignore list. You can edit a directory's ignore list by typing

svn propedit svn:ignore .

(the . is part of the command; it indicates the current directory). This will fire up an editor (the one defined in the $EDITOR environment variable), in which you can then edit and save the directory's ignore list.

svn.1273135814.txt.gz · Last modified: 2010/05/06 08:50 by damir