Subversion notes

Alexander Wintermans

I have yet to decide under which license this document can be redistributed.


Table of Contents

1. Assumptions
2. Tasks
2.1. Creating a repository
2.2. Import (initial) structure/data
2.3. Checking out
2.4. Deleting a directory
2.5. Listing properties (and values)
2.6. Creating a tag
3. Modules
4. TortoiseSVN
5. Other notes
5.1. Risk mitigation

1. Assumptions

Joe (username joe) is using host jjj.joe.org (attached to the internet) to host a private repository of his source code.

Multi-user access will not be discussed here.

2. Tasks

2.1. Creating a repository

  $ svnadmin create svn/rep1

2.2. Import (initial) structure/data

  $ cd importRoot
  $ svn import . file:///home/joe/svn/rep1 --message 'Initial version'

2.3. Checking out

Locally:

  $ svn checkout file:///home/joe/svn/rep1/projectPath/trunk checkoutDestination

Remotely:

  $ svn co svn+ssh://jjj.joe.org/home/joe/svn/rep1/projectPath/trunk    \
      checkoutDestination

2.4. Deleting a directory

  $ svn rm myDir
  $ svn commit -m 'Deleted myDir'

2.5. Listing properties (and values)

  $ svn proplist --verbose .
or
  $ svn proplist --verbose file:///home/joe/svn/rep1/path

2.6. Creating a tag

  $ svn copy file:///home/joe/svn/rep1/projectPath/trunk                 \
      file:///home/joe/svn/rep1/projectPath/tags/1 -m "First version"

3. Modules

In CVS there is a facility to group a number of directories into a module that can be checked out in one go. A similar effect can be achieved in subversion using the svn:externals property.

Here follow instructions for creating a module myModule that will check out directories A, B and C. Directory A will be checked out into ./root. Directory B will be checked out into ./root/sub. Directory C will be checked out into ./tools.

  1. First create a module directory in the repository and check it out:

      $ svn mkdir file:///home/joe/svn/rep1/modules/myModule
      $ svn co file:///home/joe/svn/rep1/modules/myModule latest_myModule
      $ cd latest_myModule

  2. Then edit the svn:externals property for this directory:

      $ svn propedit svn:externals .
    Enter the following lines:
      root          file:///home/joe/svn/rep1/A/trunk
      root/subdir   file:///home/joe/svn/rep1/B/trunk
      tools         file:///home/joe/svn/rep1/C/trunk

  3. Check the result by updating.

      $ svn update
    Your directory should now populate.

  4. Check in the new property value.

      $ svn commit

4. TortoiseSVN

TortoiseSVN is a graphical subversion client for Microsoft operating systems. It uses a modified version of Putty to enable SSH tunneling.

One of the problems using subversion with SSH is having to enter your password every time you run a subversion command. This can be fixed by using a private key to establish the SSH connection (instead of a password). Having generated a private key on the repository host and set up SSH in the normal way, the following procedure shows how to configure TortoiseSVN to use that key for accessing the repository.

  1. Ensure that the Putty suite of tools is installed (TortoiseSVN only includes a hacked version of plink.exe).

  2. Use puttygen.exe to convert the id.rsa private key file to a *.ppk putty-compatible file (e.g. joeOnJjj.ppk).

  3. Add a line to the C:\Documents and Settings\joe\Application Data\Subversion\config file (also accessible throught the explorer context menu TortoiseSVN->Settings+Main+Edit). The line must be added to the [tunnels] section:

      jjj = C:\\Program Files\\TortoiseSVN\\TortoisePlink.exe -batch    \
              -i C:\\home\joe\\joeOnJjj.ppk -l joe

  4. Now you can checkout without entering a password by entering a URL like:

      svn+jjj://jjj.joe.org/home/joe/svn/rep1/projectPath/trunk

5. Other notes

5.1. Risk mitigation

Using a private key for SSH connections is potentially risky if the client machine is not entirely secure. To limit damage to the repository host in case of compromise of your private key you can restrict that key's use to subversion. See the SSH notes' section on 'Restricting private-key-connections'.