Subversion 

From http://lena.franken.de/linux/subversion.html By Bavaria.

Edited by xpt on 2007-09-21.

Subversion is a file revision control system for developers.

Create a new repository 

Repository is the place where the versioned data lives in a database. Go to the computer where the repository lives. Be the user who is repsonsible for the repository.

$ svnadmin create /data/subversion

Initial import 

Import to a local repository 

develop$ svn import findus4 file:///data/subversion/findus4

Import to a webdav-repository 

develop$ svn import findus4 http://svn.rosi13.de/svn/findus4

Creating a trunk-directory, initial import, checkout:

develop$ svn mkdir http://svn.rosi13.de/svn/findus4/trunk
develop$ cd findus4
develop$ svn import -m "initial import" http://svn.rosi13.de/svn/findus4/trunk
develop$ mv findus4 findus4.old
develop$ mkdir findus4
develop$ svn checkout http://svn.rosi13.de/svn/findus4/trunk findus4
develop$ rm rf findus4.old

Other things 

Checkout 

Checkout, getting out files from repository

svn checkout file:///data/subversion/findus4
svn checkout http://subversion.rosi13.de/subversion/test

Checkout behind the proxy-server 

Checkout, getting out files from repository when you are *behind a proxy-server*

So, you are behind a proxyserver and want to access the repository through this proxyserver.

  • Configure svn to use a proxy in the file ~/.subversion/servers which then should look like this:

    [global]
    http-proxy-host = 127.0.0.1
    http-proxy-port = 3128
    http-proxy-compression = no
  • Configure your Squidserver to allow some commands with this line in /etc/squid.conf:

    extension_methods REPORT MERGE MKACTIVITY CHECKOUT
  • Do you initial checkout:

    svn checkout http://subversion.rosi13.de/subversion/test test

svn commit 

Putting changed file to repository

You don't need the place of the repository anymore, svn remembers it.

svn commit

svn status 

Which files have changed? Are there new files?

svn status

svn diff 

What has changed?

svn diff

svn add 

New file in tree

svn add MyNewFile.pm (schedules file to next update)
svn commit (puts diffs and this new file to repos)

svn:ignore 

Ignore files in a directory

  1. Before this do an 'svn commit'
  2. Do

    svn propedit svn:ignore .
  3. Every file to be ignored in a new line
  4. Do

    svn commit -m "ignoring this and that"

split repository 

Moving projects from a common used repository to several single repositories

  1. Dump complete subversion-repository to a file:

    $ svnadmin dump /data/subversion >complete.svn.dump
    Create an extract from your first project:
    $ cat complete.svn.dump | svndumpfilter \
    --drop-empty-revs \
    --renumber-revs \
    include project007 \
    >project007.svn.dump
  2. Create new repository:

    $ svnadmin create /data/subversion/project007
  3. Import complete history to new repository

    $svnadmin load /data/subversion/project007 <project007.svn.dump

svn:keywords 

Activate creating keywords

svn propset svn:keywords "Revision Date Id HeadURL Author" myfile.pm

Sending Mails when commiting files 

Install these package in debian-linux on your subversion-server: libsvn-notify-perl - Subversion activity notification.

% apt-get install libsvn-notify-perl

Check:

% svnnotify
Missing required "--repos-path" parameter

If you get this error-message then you are ready to run this script when commiting code. To do this write a command into the shell-script post-commit, which is already there in your repository-directory:

cd /data/svn/findus/hooks/
ls -l
cat > post-commit
#!/bin/sh
svnnotify --repos-path "$1" --revision "$2" \
     --to one@dontcare.com,two@dontcare.com \
     --reply-to responsible-for-everything@somewhere.com \
     --language de

You get a mail like this after commit code:

 Revision: 329
 Author:   horshack
 Date:     2006-01-31 22:27:05 +0100 (Tue, 31 Jan 2006)

 Log Message:
 -----------
 this is the commit-message bla bla

 Modified Paths:
 --------------
     trunk/findus_mini.ini

Restrict ssh-login to subversion only 

Your ~/.ssh/authorized_keys file has to look like this (everything must be in a single line):

command="/usr/bin/svnserve --tunnel --root=/var/svn",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-dss AAAAB3N...

This makes that whatever program the user tries to run via ssh, he will always run

/usr/bin/svnserver --tunnel...

The user can only access svn-repositories in /var/svn.

When you have a repository /data/svn/findus/trunk he has to do this:

svn checkout svn+ssh://username@svn.juhei.org/data/svn/findus/trunk findus

Books 

Subversion by O'Reilly
http://svnbook.red-bean.com/
it's a free book

documented on: 2007-09-21