Subversion Tips

Introduction

This document refers to usage of Subversion version 1.4.

Installation

Debian 4.0 (Etch) packages for SVN are:

  • subversion
  • subversion-tools
  • cvs2svn
  • libapache2-svn
  • websvn

Note: The system user that Apache runs under needs write access to the ./svn/dav/ and ./svn/db/ directories.

Keyword Substitution

SVN supports the following keywords:

  • Date or LastChangedDate
  • Revision
  • Author
  • HeadURL
  • Id

To enable keyword substitution on a keyword:

  • svn propset svn:keywords "Date Revision Author HeadURL Id" myfile

Ignoring Items

Setting ignore property for a single file

Ignores build.tmp in the current working directory. Note the space and dot at the end of the command.

  • svn propset svn:ignore -F build.tmp .

Editing ignore list for a directory

  • svn propedit svn:ignore /path/to/dir

Deleting a Tag or Branch

To remove a tag or branch that has become redundant

  • svn delete http://myserver/svn/project/tags/tagtodelete

Enabling Automatic Property Setting

When using Eclipse see EclipseTips.

For the command line version, modify ~/.subversion/config

  1. Set enable-auto-props = yes
  2. Add automatic properties under the [auto-props] section

e.g.

enable-auto-props = yes

[auto-props]
*.java = svn:keywords=Author Date Id Revision HeadURL

To apply this to all users, make the same change in the repository's config file. This is /etc/subversion/config in a Debian 4.0 (Etch) install.

Administration

Backup

There are a number of options for backup. Consult the Subversion book for more information. Listed here are a couple.

Full Backup

Adding the 'deltas' option takes longer, but produces a smaller backup

# svnadmin dump --deltas /path/to/svn/repository > dumpfile

Incremental Backup

# svnadmin dump --deltas -r 0:1000 /path/to/svn/repository > dumpfile1
# svnadmin dump --deltas -r 1001:2000 --incremental /path/to/svn/repository > dumpfile2
# svnadmin dump --deltas -r 2001:HEAD --incremental /path/to/svn/repository > dumpfile3

Restore

Create a new repository, e.g.

# svnadmin create /path/to/svn/repository

then:

# svnadmin load -q /path/to/new/repository < dumpfile1
# svnadmin load -q /path/to/new/repository < dumpfile2
# svnadmin load -q /path/to/new/repository < dumpfile3

Enabling Amendment of Log Messages

Make a copy of the two template scripts in the repository 'hooks' subdirectory, dropping the '.tmpl' extension

  • pre-revprop-change
  • post-revprop-change

Modify pre-revprop-change as necessary. The template version probably has a command to send an email containing changes.

Resources

-- Frank Dean - 16 Feb 2007