Subversion

From wiki.sixohthree.com
Jump to: navigation, search
File:Trex head.jpg

This article is outdated.

This article concerns old products, obsolete practices, or otherwise outdated subject matter. Deletion or revision is required. Please discuss possible changes on the talk page, or wait for Adam to complete the update.

I've starting experimenting with Subversion, since the deficiencies of CVS have become an annoyance. (Notably, the inability to rename files.)

Contents

[edit] Installation

I've installed the Subversion DAV server on Slackware 10.0. I had to install Berkeley DB (db4) before compiling the other software. (There is a db4 package for Slackware 10.0.)

My source tarballs are already downloaded:

adam@shed[3]:~$ cd /tmp/svn
adam@shed[3]:/tmp/svn$ ls
httpd-2.0.50.tar.gz  subversion-1.1.0.tar.bz2
adam@shed[3]:/tmp/svn$

[edit] Apache 2 Installation

Slackware 10.0 does not use Apache 2, so I had to compile & install it. I use Apache 1.3, but the default Apache 2 configuration is pretty well segmented.

adam@shed[3]:/tmp/svn$ tar xzf httpd-2.0.50.tar.gz
adam@shed[3]:/tmp/svn$ cd httpd-2.0.50
adam@shed[3]:/tmp/svn/httpd-2.0.50$ ./configure --enable-dav --enable-so \
    --with-berkeley-db --enable-mods-shared=most
adam@shed[3]:/tmp/svn/httpd-2.0.50$ make
root@shed[3]:/tmp/svn/httpd-2.0.50# make install
root@shed[3]:/tmp/svn/httpd-2.0.50# chown -R root:root /usr/local/apache2
root@shed[3]:/tmp/svn/httpd-2.0.50# chgrp -R bin /usr/local/apache2/bin
root@shed[3]:/tmp/svn/httpd-2.0.50# strip /usr/local/apache2/bin/*
adam@shed[3]:/tmp/svn/httpd-2.0.50$

I modified /usr/local/apache2/conf/httpd.conf to fit my needs. I changed Listen 80 to Listen 8080. I disabled UserDir, since I don't want that to be part of the Subversion port. I also decided to change the User and Group to svn, which required the addition of a new user to the system. UID and GID 51 were unused, so I ran the following commands:

root@shed[3]:/tmp/svn/httpd-2.0.50# groupadd -g 51 svn
root@shed[3]:/tmp/svn/httpd-2.0.50# useradd -u 51 -g svn -s /bin/false -d / svn

I then set up the DAV access using the VCS Server Configuration chapter. My <Location> directive looks like this:

<Location /svn>
    DAV svn
    SVNParentPath /mnt/extra/svn

    AuthType Digest
    AuthName "SVN"
    AuthDigestFile /etc/svn/auth-digest
    Require valid-user
</Location>

I decided to go with SVNParentPath, with repositories stored in /mnt/extra/svn.

[edit] Subversion Installation (Server)

There wasn't much to the Subversion build process.

adam@shed[3]:/tmp/svn/httpd-2.0.50$ cd ../subversion-1.1.0
adam@shed[3]:/tmp/svn/subversion-1.1.0$ ./configure --with-zlib \
     --with-apxs=/usr/local/apache2/bin/apxs --with-ssl
adam@shed[3]:/tmp/svn/subversion-1.1.0$ make
root@shed[3]:/tmp/svn/subversion-1.1.0# make install}}}

[edit] Subversion Installation (Client)

The ./configure directive for my client was slightly different. This client will have no local access to the repository, so I opted to skip the db4 linking.

./configure --with-zlib --with-ssl --without-berkeley-db

I had some problems with the client installed on DreamHost so I configured my own copy. I used the following configure arguments:

./configure --with-zlib --with-ssl --without-berkeley-db --enable-all-static

[edit] Subversion Setup

My aim is to have a flexible server setup, hence the svn:svn setup for Apache 2. I added my user account to the svn group. Now to create the parent directory for repositories, as specified in the httpd.conf.

root@shed[3]:/tmp/svn/subversion-1.1.0# cd /mnt/extra
root@shed[3]:/mnt/extra# mkdir svn
root@shed[3]:/mnt/extra# chmod 2775 svn
root@shed[3]:/mnt/extra# chown -R svn:svn /mnt/extra/svn

Then I'll create an intial repository.

root@shed[3]:/mnt/extra# svnadmin create /mnt/extra/svn/test1
root@shed[3]:/mnt/extra# chmod -R g=u /mnt/extra/svn

[edit] SWIG Installation

I installed SWIG post-subversion, because I didn't need it during my initial setup. I'm leaving it here after the Subversion steps for now.

adam@shed[0]:/tmp/SWIG-1.3.22$ ./configure && make && make install
adam@shed[0]:/tmp/SWIG-1.3.22$ echo '%module swigrun' > swigrun.i
adam@shed[0]:/tmp/SWIG-1.3.22$ swig -runtime -python swigrun.i
adam@shed[0]:/tmp/SWIG-1.3.22$ gcc -I/usr/include/python2.4 -fpic -c swigrun_wrap.c
adam@shed[0]:/tmp/SWIG-1.3.22$ gcc -shared swigrun_wrap.o -o libswigpy.so
adam@shed[0]:/tmp/SWIG-1.3.22$ install -o root -g root -m 755 libswigpy.so /usr/local/lib

Once the libswigpy.so is in place, reconfigure Subversion and install the Python bindings.

However, it is simpler to use SWIG 1.3.24, and Subversion 1.1.4 or greater, in which case no libswigpy exists or is required. In this case, you can install SWIG with just a simple ./configure && make && make install, and skip the rest of the steps above. --MaxBowsher

adam@shed[0]:/tmp/svn/subversion-1.1.0$ ./configure
adam@shed[0]:/tmp/svn/subversion-1.1.0$ make swig-py
adam@shed[0]:/tmp/svn/subversion-1.1.0$ make install-swig-py DESTDIR=/tmp/swig-py
adam@shed[0]:/tmp/svn/subversion-1.1.0$ mv /tmp/swig-py/usr/local/lib/* /usr/lib/python2.4/site-packages

To test your setup, run python -c 'import svn' and see if you get import errors. If not, you're set. If so...?

If so, asking on the Subversion Users mailing list is a good first step. --MaxBowsher

[edit] Install ViewCVS

ViewCVS is a great way to view Subversion repsitories on the web. The WebDAV browser is nice in a pinch, but ViewCVS is more full-featured. Check the official Subversion repository as an example.

I happen to follow the Subversion log message style guide, and my checkin messages consist of a brief descriptive sentence or two followed by a list of changed files. I don't really need the file list to show up in ViewCVS in the browse view, so I wrote [attachment:viewcvs-smartlog.patch.ksh a small patch] to viewcvs.py to only include my brief message in the browser.

At present, you'll have to download and install ViewCVS from CVS to get SVN support.

adam@shed[0]:/tmp$ cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/viewcvs login
adam@shed[0]:/tmp$ cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/viewcvs co viewcvs
adam@shed[0]:/tmp$ cd viewcvs
adam@shed[0]:/tmp/viewcvs$ ./viewcvs-install

I chose an installation path of /var/www/viewcvs-1.0-dev.

I modified the following values in viewcvs.conf:

root_parents = /mnt/extra/svn : svn
default_root = svn
mime_types_file = /usr/local/apache2/conf/mime.types
docroot = /viewcvs-static

I added the following lines to /usr/local/apache2/conf/httpd.conf:

Alias /viewcvs-static "/var/www/viewcvs-1.0-dev/templates/docroot"
<Directory "/var/www/viewcvs-1.0-dev/templates/docroot">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

ScriptAlias /view "/var/www/viewcvs-1.0-dev/www/cgi/viewcvs.cgi"
<Location /view>
    AuthType Digest
    AuthName "SVN"
    AuthDigestFile /etc/svn/auth-digest
    Require valid-user
</Location>

[edit] Questions

Q. What happens if Sally and Joe checkout the same file, Sally renames the file and checks in, and Joe edits the file and updates?

A. Nothing good. (Update: I believe this is fixed in Subversion 1.2.) Here are the necessary steps to recover from this problem:

Joe
  1. svn co project
  2. cd project
  3. svn mv config.h defines.h
  4. svn ci
Sally
  1. svn co project
  2. cd project
  3. vi config.h
  4. svn update [1]
  5. merge config.h defines.h defines.h [2]
  6. rm config.h
  7. svn ci


  1. Sally now has Joe's copy of config.h with the new name, "defines.h." Her local config.h has been changed and needs to be checked in, but no longer exists in the repository under that name.
sally@localhost$ svn update
A  defines.h
svn: Won't delete locally modified file 'config.h'
  1. Sally merges her copy of config.h into the new defines.h file.

You must know the old and new filenames for this to work. Yet another reason checkin messages are so important.

[edit] See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox