This page was last modified: November 04 2006 13:24:42   
Too Cool for Internet Explorer

Subversion

I have used CVS in the past, but always as a committer, never as an administrator. So when I decided to put some version control on this site, my knowledge was very limited. I asked around and decided to use subversion.

The first lesson I learned was that you should never save application generated content in the same directory as the actual application (e.g. a webpage) ... big mistake! If for example you are maintaining an online photoalbum, never save the pictures in a subdirectory. It will come back and bite you when the time comes to add version control.

I strongly recommend reading the subversion book "Version control with subversion". It's free and can be downloaded from the subversion website.

This article is based on the lessons I learned while creating an initial repository and adding nerdgirl.dk into it.

First I reinstalled Apache, since it was not compiled with berkeley.

cd /usr/ports/www/apache20/
make clean
make WITH_BERKELEYDB=db42
make deinstall
make reinstall

And I did the following because they told me to at www.bsdguides.org/guides/freebsd/misc/subversion.php. Actually I am not sure if it is necessary or not.:

We make sure that the apache2 aprutil library is known, this file sometimes seems to get "lost"

ldconfig -m /usr/local/lib/apache2/
echo "/usr/local/lib/apache2" >> /etc/ld.so.conf
echo "/usr/local/lib/apache2" >> /etc/ld-elf.so.conf

Next, install subversion:

cd /usr/ports/devel/subversion
make install WITH_SVNSERVE_WRAPPER=yes WITH_MOD_DAV_SVN=yes

Create a repository:

svnadmin create /usr/local/www/subversion

Create an initial project with the layout they recommend in the subversion book:

mkdir /root/nerdgirl.dk/
mkdir /root/nerdgirl.dk/branches
mkdir /root/nerdgirl.dk/tags
mkdir /root/nerdgirl.dk/trunk

Copy the working website into the 'trunk'

cp -r /usr/local/www/nerdgirl.dk/ /root/nerdgirl.dk/trunk/

Imported the project to the new repository:

svn import /root/nerdgirl.dk file:///usr/local/www/subversion/nerdgirl.dk -m "Initial import"

Delete the project...

rm -rf /root/nerdgirl.dk

If for some reason you want to start over from scratch, just delete the root directory (ind this example, that would be the 'subversion' directory).

rm -rf /usr/local/www/subversion

In a professional environment they have seperate servers for developing and testing stuff. I dont. Well, I could install Apache on my laptop and do my programming there, but I think it's a bit overkill for this. So instead I decided to use a password protected sub domain as my working copy: test.nerdgirl.dk

Then did a checkout to get the code from the repository (this command will fetch the project and create the test.nerdgirl.dk folder):

svn checkout file:///usr/local/www/subversion/nerdgirl.dk/trunk/ test.nerdgirl.dk

I also did a checkout to the public site:

svn checkout file:///usr/local/www/subversion/nerdgirl.dk/trunk/ www.nerdgirl.dk

Now I can test and fool around on test.nerdgirl.dk. When I'm done, I commit the changes and update the public site:

pwd
/usr/local/www/test.nerdgirl.dk
svn commit -m "Corrections to newsyslog, cron and webalizer articles"
Sending   freebsd/crontab.php
Sending   freebsd/newsyslog.php
Sending   website/webalizer.php

Transmitting file data ...
Committed revision 7.

cd ../www.nerdgirl.dk/

svn update
D   statistics
U   freebsd/newsyslog.php
U   freebsd/crontab.php
U   website/webalizer.php

Updated to revision 7.

That's all for the initial setup... Here's a page with the most frequently used commands.

Inspired by: www.bsdguides.org/guides/freebsd/misc/subversion.php
Subversion homepage: subversion.tigris.org
Subversion book: svnbook.red-bean.com

How to use subversion to version control system configuration files:
subversion.tigris.org/faq.html#in-place-import