What’s your favorite Subversion repository organization scheme?

I use Subversion for my source code management needs. Every project that I work on gets put into my Subversion account at my hosting provider even if I’m the only one that will ever work on it. Using Subversion has saved me from significant loss of work on a number of occasions, so there’s no way that I’d consider not using it. I’m considering bringing my Subversion hosting in-house to a VPS that I control and have been thinking about how I want to organize my repository.

I’ve seen two different methods of organizing the repository–having a separate repository for each project, and having one, master repository with separate directory for each project. I can see advantages and disadvantages for each. Separate repositories allow individual access controls and maps directly one to one with Trac projects. One consolidated repository makes administration easier by putting everything under one repository.

So, my question to you folks, is what organization method do you prefer and why? If you’d like to share your opinions, success/failure stories or other relevant info, please feel free to leave a comment below. Thanks in advance for your input.

Cool ColdFusion and Subversion integration

I recently decided to outsource my souce code management to CVSDude. I had been running SVN on my VPS that I have at Slicehost and that had been running okay. However, I’m only good enough at SVN administration to get the server up and running and create a few repositories and there were other things that I needed to do with SVN that I frankly didn’t have time to learn how to do.

One of the things that I’d heard talked about that made life much easier was using Subversion’s various hooks to automate some things around different SVN events. I emailed tech support asking how we could configure the “post-commit” hook to update the files on my VPS each time I made a commit into the SVN module. The tech told me that they do this by configuring an HTTP call to a page (or script etc) on your server. That page then triggers an SVN update of the specific module.

After hearing this, I began thinking about how to use CFEXECUTE to trigger the SVN update and was actually surprised how simple it was. My VPS runs on Fedora Core 6, so, like any *nix operating system, you need to make sure permissions on the files are set so that the user which runs ColdFusion can write to the directories. Once that was accomplished, all it took was a few lines of code and we’re ready to start receiving HTTP callbacks from CVSDude’s servers.

CVSDude structures their SVN URLs in the format http://username-svn.cvsdude.com/modulename (or https://). All my modules are named in reverse domain order for the web site that it is for (for example, this one is ws.skaggsfamily.dan). I had already checked out all my modules into a specific directory.

The HTTP callback from CFSDude’s server has 4 URL parameters that they send over: root (full path to module), author (user), revision and date. So all I really had to do was grab the URL.root value and extract the name of the module, pass that to the CFEXECUTE tag and, voila, automatic updating of the module immediately after the commit.

There were only 2 gotchas that I had to figure out:

  1. Put the full path to the svn executable
  2. Add in your username and password to the string in the arguments attribute of CFEXECUTE

The code that I used is below. I’m sure there’s more that I could have done with it, but this is a good start I think.

<cfif structKeyExists(URL, “date”) AND URL.date NEQ “” AND
    structKeyExists(URL,”author”) AND URL.author NEQ “” AND
    structKeyExists(URL, “revision”) AND URL.revision NEQ “” AND
    structKeyExists(URL, “root”) AND URL.root NEQ “”>
 
    <cfset module = replaceNoCase(URL.root, “http://username-svn.cvsdude.com/”, “”)>
 
    <cfexecute name=/usr/bin/svn”
      arguments=”up /var/sites/#module# –username yourUserName –password yourPassword”
      timeout=300
      variable=”result”>
    </cfexecute>
 
    <cflog log=”Application”
      type=”information”
      text=”#URL.author#:#URL.root#:#URL.revision# – #result#”>
 
<cfmail to=”someone@somewhere.com”
    from=”somoneelse@somewhere.com”
    subject=”Server updated successfully”>
The server has been successfully updated with your lastest changes. 
Details of the update are below:
 
Date: #URL.date#
Module: #URL.root#
Revision: #URL.revision#
 
Results:
#result#
 
</cfmail>
 
</cfif>