Saturday, November 7, 2009

Updating Subversion's (SVN's) Repository Version

Sometimes it's necessary to manually upgrade Subversion's repository after upgrading Subversion (SVN) itself, such as to take advantage of a new feature. For example, I recently upgraded Subversion from 1.4 to 1.5, but did not upgrade my repository. This worked fine until I (inadvertently) tried to use a 1.5 feature. Using TortoiseSVN, I tried to merge a branch into the trunk using the 1.5 "merge tracking" feature, but because of the older repository version, I got an error something like "Error: Retrieval of mergeinfo unsupported by 'http://svnserver/myrepo'". Following are the steps I used to upgrade my repository.
  • Check the Subversion server software version:
    • Logon to the computer on which the repository server software is running. From the command line, execute svnadmin --version to get the server software version.
    • Execute svn --version to check the client software.
  • The server software version may be different from the repository version. To check the actual repository (layout) version number:
    • Navigate to <repository_dir>/db and open the file format. For SVN 1.5 compatibility, it should read something like:
        layout shared 1000

      The key number here is 3. For SVN 1.4, this number is 2 and for SVN 1.6, 4.

  • To upgrade the repository, the server command svnadmin upgrade <repos_dir> is often sufficient (as is the case going from SVN 1.4 to 1.5). Here's the help documentation for this command:
      Upgrade the repository located at REPOS_PATH to the latest supported
      schema version.
      This functionality is provided as a convenience for repository
      administrators who wish to make use of new Subversion functionality
      without having to undertake a potentially costly full repository dump
      and load operation.  As such, the upgrade performs only the minimum
      amount of work needed to accomplish this while still maintaining the
      integrity of the repository.  It does not guarantee the most optimized
      repository state as a dump and subsequent load would.
  • Depending on which user did the update, it might be necessary to update the owner of the repository files. On Ubuntu Linux I had to issue the command sudo chmod -R www-data myrepo to change the owner of files from root back to www-data (the Apache user). Otherwise, trying to commit (remotely) to the repository will result in an error something like Can't open file '/path/to/repo/db/txn-current-lock': Permission denied

    Here's what others recommend:

    # chown -R www-data:www-data /var/svn/*
    # chmod -R 770 /var/svn/*
    assume that /var/svn/ is where are all your repositories

    (from svnform) and:

    $ sudo chown -R www-data:subversion myproject
    $ sudo chmod -R g+rws myproject

    (from ubuntu help).