Security Conscious,
High Availability Unix Hosting
Subversion access with svn+ssh

The easiest way to access a subversion repository involves use of the svn+ssh protocol, which is simply the tunnelling of subversion commands through ssh. The subversion client must be given an URL of the form svn+ssh://user@server.csoft.net/path. The two other methods for subversion access are svnserve and HTTP/DAV.

Unlike the other methods, svn+ssh requires the use of real unix accounts and unix file permissions. Extra unix accounts that are restricted to svn+ssh access can be configured with csoftadm (and assigned SSH public keys for passwordless authentication). Additional unix groups are also configurable from csoftadm. Users can be granted read-only or read-write access on whole repositories with chmod and chgrp.

Installing client software

We assume that you want to access subversion repositories on the server from a remote client, such as your workstation. If you do not have a subversion client installed on your workstation, see the subversion download page. For Windows users, TortoiseSVN (a windows shell explorer extension) is freely available.

Initializing the repository

On the server, use the svnadmin tool to create a new repository:

  $ svnadmin create $HOME/my-repo

This command would create a new repository structure under ~/my-repo.

Generating a working copy

On your workstation, use the svn import command to create a working copy of the repository:

  $ mkdir my-files
  $ svn import -m "My files" my-files \
        svn+ssh://my-username@my-server/my-home/my-repo
  $ rm -rf my-files
  $ svn checkout svn+ssh://my-username@my-server/my-home/my-repo/my-files

TortoiseSVN users can generate a working copy by right-clicking on an empty directory, selecting the SVN Checkout... command and entering the URL of the repository in the dialog.

Importing unversioned files

The svn import command is useful for recursively adding the contents of a directory to a repository:

  $ export SVNROOT="svn+ssh://my-username@my-server/my-home/my-repo"
  $ svn import -m "My website" www $SVNROOT
  $ mv www www.orig
  $ svn checkout $SVNROOT/my-website www
Importing files from CVS

If you have an existing CVS repository that you want to convert to subversion, the cvs2svn tool can be used. It is available on your server, but you can also run it on your local computer. Please note that cvs2svn is very resource-intensive and is designed for one-time only conversions, not repeated synchronizations.

Creating a read-only mirror of a remote repository

It is possible to create a read-only mirror for a remote repository thanks to the svnsync command (simply copying the subversion database files over is not a safe way to do this). See the svnsync guide for more information.

Relocating an existing Subversion repository

To move an existing repository from a different server, it is best to use the svnsync method in order to preserve all attributes. Existing working copies do not need to be regenerated after the repository has been moved to the new server. Instead, the following command can be used:

  $ svn switch --relocate old-url new-url
Miscellaneous examples
  $ cd my-website
  # See the local modifications to text files since the last commit.
  $ svn diff |more
  $ svn diff |vim -
  # Merge changes committed to the repository since last update/checkout.
  $ svn up
  # Add an existing directory and all the files it contains.
  $ svn add old-images/
  
  # Create an empty directory.
  $ svn mkdir new-images/
  
  # Remove a file or directory.
  $ svn remove foo.txt
  
  # Rename a file or directory on the repository.
  $ svn move file1 file2
  $ svn move dir1/ dir2/
  # Display the history information for a file or directory.
  $ svn log images
  #
  # Commit changes to the working copy into the repository. Unless the
  # commit message is given on the command line with "-m", it will bring
  # up your text editor ($EDITOR).
  #
  $ svn commit
  $ svn commit -m 'Summary of changes'

Links


  End Software Patents!