Bill Lovett

Setting Up Subversion

Posted on May 12th, 2004

These are my notes from setting up a Subversion repository. Subversion is like CVS, only with newer features and new car smell.

I'm using the freely available book Version Control with Subversion as my reference manual. I'm using Debian Linux packages and opting for network access over WebDAV and Apache2. My goal is to be able to access the repository from my XP desktop using Tortoise SVN.

Creating the Repository

$ su
# mkdir /subversion
# svnadmin create /subversion
# exit

Easy enough. The repository is now created, but it's empty. Rather starting to import files as the book suggests I'll switch over to setting up WebDAV.

Permissions! Good thing this sidebar was there. Since Debian apache2 runs as www-data, the files in the subversion repository need to be accessible by that user (not just root, which is who I was when I created the repository). Solution:

$ su
# rm -rf /subversion
# mkdir /subversion
# chown www-data:www-data /subversion
# su www-data
# svnadmin create /subversion
# exit
# exit

$ ls -s /subversion
-rw-r--r--    1 www-data www-data      376 May 11 20:27 README.txt
drwxr-xr-x    2 www-data www-data     4096 May 11 20:27 conf
drwxr-xr-x    2 www-data www-data     4096 May 11 20:27 dav
drwxr-xr-x    2 www-data www-data     4096 May 11 20:28 db
-rw-r--r--    1 www-data www-data        2 May 11 20:27 format
drwxr-xr-x    2 www-data www-data     4096 May 11 20:27 hooks
drwxr-xr-x    2 www-data www-data     4096 May 11 20:27 locks

That ought to work.

For authentication I'm taking the htpasswd approach for now, but plan to switch to LDAP authentication later. Not a big deal; authentication is handled through Apache. I'm putting htpasswd in the repository root, it seems like as good a place as any. My httpd.conf now looks like this:

<location /svn>
  DAV svn
  SVNPath /subversion
  AuthType Basic
  AuthName "ilovett Subversion Repository"
  AuthUserFile /subversion/htpasswd
  Require valid-user
</location>

Restarted apache; should be ready to go. Now it's time to import some files.

$ svn import jabber_spell http://scorpinox.ilovett.net/subversion \
-m "initial import"
svn: PROPFIND request failed on '/subversion'
svn: PROPFIND of '/subversion': 405 Method Not Allowed
(http://scorpinox.ilovett.net)

Duh, I specified the wrong wrong subdirectory for the repository.

$ svn import jabber_spell http://scorpinox.ilovett.net/svn \
-m "initial import"
Authentication realm:  ilovett
Subversion Repository
Password for 'blovett':
Adding         jabber_spell/jabber_spell.py

Success!

Next, from XP, I went to My Network Places, clicked Add a network Place, and went through the wizard for creating a "Web Folder". Viewing the contents of the folder should show me the current versions of all the stuff in my repository (with WebDAV being the underlying protocol that makes this possible). I see that jabber_spell.py is at the root level, which I didn't want. Not good. I need to delete that file.

$ svn delete -m "deleting jabber_spell because it's at the repository
root"  http://scorpinox.ilovett.net/svn/jabber_spell.py

That just deletes the file, though. It doesn't get rid of it (the normal behavior of a source control system, of course). It seems I can't:

"There are special cases where you might want to destroy all evidence of a file or commit. (Perhaps somebody accidentally committed a confidential document.) This isn't so easy, because Subversion is deliberately designed to never lose information. Revisions are immutable trees which build upon one another. Removing a revision from history would cause a domino effect, creating chaos in all subsequent revisions and possibly invalidating all working copies."

"The project has plans, however, to someday implement an svnadmin obliterate command which would accomplish the task of permanently deleting information. (See issue 516.)"

"In the meantime, your only recourse is to svnadmin dump your repository, then pipe the dumpfile through svndumpfilter (excluding the bad path) into an svnadmin load command. See chapter 5 of the Subversion book for details about this."

Source: Subversion FAQ

I guess I'll just have to wipe out the repository and start over...

Deciding on a Repository Layout

Since all this is for my use only, I'm opting for a single repository containing multiple projects. Following the book's lead, I'm going with:

/
   projectA/
      trunk/
      tags/
      branches/
   projectB/
      trunk/
      tags/
      branches/
   ...

Now we're in business... from XP's web folder, I see jabber_spell at root, which contains trunk, tags, and branches folders.

Just to double check:

$ svn list --verbose http://scorpinox.ilovett.net/svn/
      1 blovett             May 11 21:20 jabber_spell/

Now to make my initial checkout with Tortoise SVN. For "URL of repository" I'm specifying the trunk folder of jabber_spell. For the Checkout directory I'm specifying a folder called jabber_spell. This leaves me with what I had prior to bringing this project into subversion-- my working copy reflects the contents of trunk, but there is no trunk folder visible to me.

Good.

Back to the index of all blog entries