User Tools

Site Tools


subversion

Introduction

Subversion is a source code repository. It was designed to replace CVS as the standard. Subversion has many advantages over CVS:

  • Versioning directories
  • Transactional commits
  • Overwrite deleted files without losing the history
  • Web-DAV support

Client

This section gives you an overview of some of the features the subversion command line client has in store. If you prefer graphical clients there are a lot of tools:

Step 1: Creating directories remotely

First step in preparing your repositories is usually creating the three top level directories trunk, tags and branches.

svn -m 'Creating top level dirs.' mkdir http://your-server-url/your-repository/trunk

Step 2: Initial import

You usually start by importing a non-versioned working directory as trunk of the development.

cd your-working-dir
svn -m 'Initial import.' import . http://your-server-url/your-repository/trunk

Step 3: Check out the working copy

Now check out what you just imported so that you have a proper working copy:

mv your-working-dir your-working-dir.old
svn co http://your-server-url/your-repository/trunk your-working-dir

If you check with

ls -alt

You sould see a hidden .svn directory. That indicates you have a proper working copy.

Step 4: Keeping result files from beeing checked in

As a rule of thumb only sources should be checked in, not generated results. You can use the SVN property svn:ignore to speficy patterns of files and directories that you don't want to check in.

Example for setting a single ignore:

svn propset -R svn:ignore '*.pdf' .

tells subversion to not check in any PDF file from the current location in the working copy. The -R switch makes this setting recursively.

In most cases you want more than one file type to be ignored. In this case use the property editor to provide a list:

svn propedit svn:ignore .

The editor set in the environment variable EDITOR opens and you can provide a list of patterns that should be ignored. Put each pattern into a separate line.

Examples of results you should not check in depending on your project type:

  • LaTeX - .pdf, .aux, .toc, .idx, .gz, .ilg, .ind, .log, .out
  • C - .o, .a, .lib

Check which properties are set with

svn proplist -v .

Don't forget to check in your svn:ignore patterns. This way you make sure that other users have the same settings.

svn -m 'Added svn:ignore patterns.' ci .

Server

Installation

On Debian you install subversion like this:

aptitude install subversion libapache2-svn

The second package makes subversion accessible via Web-DAV and an Apache HTTP server. Dependent packages will be installed automatically

Now you need to activate the user authentication and the DAV support of the Apache server:

a2enmod authz_user dav dav_svn

Configuration

Prepare a repository directory. If you want to conform to the LSB the use /var/lib/svn. I prefer to have everything that needs to backed up regularly unter /data.

  1. Create a repository directory
  2. Initialize the repository
  3. Change the ownership to the Apache user
mkdir --parents /data/svn/MyProject
svnadmin create /data/svn/MyProject
chown -R www-data /data/svn/MyProject

If the password file does not yet exist create the first user with

htpasswd -cs /data/svn /etc/apache2/dav_svn.htpasswd <first user>

All users after the first one are created like

htpasswd -s /etc/apache2/dav_svn.htpasswd <user>

Start the Subversion daemon on the repository:

svnserve -d -r /data/svn/MyProject

Edit /etc/apache2/mods-available/dav_svn.conf:

<Location /svn/MyProject>
  Dav svn
  SVNPath /data/svn/MyProject
 
  AuthType Basic
  AuthName "Subversion repository: MyProject"
  AuthUserFile "/etc/apache2/dav_svn.htpasswd"
 
  Require valid-user
  Require group subversion
 
  SSLRequireSSL
</Location>

Migration to Git

Preparation

In case you have a running SVN server from which to migrate, you can skip this step.

Since you probably do not want to pollute your workstation with something that should not run there I recommend creating a virtual machine with a Debian Linux on it and install the Apache server inside as described above.

In the software selection choose

  • web server
  • SSH server
  • standard system utilities

to save installation time.

Migration

<code bash> apt-get install git-svn <code>

Follow this guide: http://john.albin.net/git/convert-subversion-to-git

subversion.txt · Last modified: 2016/05/01 18:47 by sebastian