Setting Up Subversion In An Instant

One of the biggest issues being pushed at this year's CFUNITED conference was the need for each and every one of us developers to be using some sort of source control.  I've since joined the converted faithful and have seen the light as to just how important source control is, especially when working in a team environment. 

Subversion is a free, easy-to-use, source control server with widespread support including direct integration with CFEclipse as well as the Windows file system.  This is my quick and easy guide to getting up and running and setting up your repositories.  It only takes a matter of seconds to setup each new repository instance, so hopefully this will allow everyone to get up and running in a jiffy.  Keep in mind that these directions are for Windows, but should be pretty similar for the Mac.

The first thing you'll need is a copy of the Subversion server.  This is where your repositories will sit and these will hold the master copies of all your code (along with any revisions).   You can download a copy here (the ones ending in '-setup' come with a friendly installer program).  Once installed, perform the steps below to get it running as a service:

  1. Create a root directory to hold all of your repositories (e.g. c:\svnrepo).
  2. Download the SVN Service Wrapper (alternate location) and unzip it to your c:\Program Files\Subversion\bin\ folder or wherever your SVNServe.exe is located.
  3. Open a command prompt and type 'SVNService -install -d -r c:\svnrepo'.  The -d installs it as a daemon and the -r specifies that it will only server repositories located under the specified directory.
IMPORTANT: Make sure to backup that root folder and protect your repositories!!!

The second thing you'll want to download and install on that machine is the Tortoise SVN client.  Once that's installed:
  1. Go to the directory which you specified for your subversion repositories (c:\svnrepo) and create a new folder there - name it whatever you would like your repository to be called, typically the name of your project. 
  2. Next, right-click on that folder and select Tortoise SVN from the context menu, then choose 'Create repository here...'  Select Native Filesystem at the prompt and you should then get a confirmation that everything was created OK. 
  3. Double-click into that directory and you should now see 5 directories and 2 files.  Go into the conf directory and edit svnserve.conf.  Uncomment every line with only a single ## sign except for the line starting with 'authz-db', then save and exit.  You can change the 'anon-access' value to 'none' to disable read-access by all.
  4. Edit the passwd file - remove the ## before [users] and replace the sample users with your own username/password combinations.
That's it, your repository should now be setup.  Time to start adding some directories...
  1. Right-click on the folder we first added (the one containing the conf and other directories), and select 'Tortoise SVN', then 'Repo-browser'.
  2. Right-click anywhere in the main screen that pops up and select 'Create folder...'  Standard convention specifies 3 directories for the top-level:  trunk, tags, and branches.  Create those now - enter 'trunk' as the name of the directory.  Each action performs a commit which requires a memo, so we'll use 'creating initial trunk directory'.  Do the same for tags and branches.
Next we need to get our code into the repository.  If your web server is on a different machine than your Subversion server, you'll need to install the Tortoise SVN client onto it as well.  It's important to remember that the actions on the menus are always in relation to your Subversion repository.  So an import means that we'll be adding files to our repository.
  1. Right-click on the directory of your webroot and select 'Tortoise SVN' and then 'Import'. 
  2. Enter the location of your Subversion repository (by default Subversion includes its own svn protocol).  It should look something like this: svn://your.ip.address/repos_name/trunk.  For the comment use 'initial trunk import'.
You should get a success message once all your files are imported.  That's it!  You've now got your source code hosted in a Subversion repository with all of the benefits that provides!

In the next post, we'll look at using CFEclipse along with Subversion to create an efficient, manageable development environment.  Stay tuned!

Related Blog Entries

TweetBacks
Comments
Michael Brennan-White's Gravatar Please forgive me for missing the point here but what benefits do you receive from installing the subversion server and then the Tortoise SVN client on the server and your workstation. I installed Tortoise on both locations and then was able to set up the Repository through Tortoise.

If there are major bennies from installing the server, can I take the repository I already created through Tortoise on the server and use it with the regular Subversion server?

Thanks a lot,

Michael Brennan-White
# Posted By Michael Brennan-White | 8/9/06 6:07 PM
Charlie Arehart's Gravatar Nice, Joe. Thanks for sharing. This was very helpful. I've added a pointer to it in the comments of a blog entry I did a couple weeks ago called, "Getting into Subversion as a CFML developer: Another Resource List"

http://carehart.org/blog/client/index.cfm/2006/7/1...

Perhaps readers of your blog entry here will enjoy some of what's there.
# Posted By Charlie Arehart | 8/10/06 12:37 AM
Joe Danziger's Gravatar Michael - the main reason to install Tortoise on the server is because as far as I can tell, Tortoise can only create a repository on the machine it is installed on. You need to actually point it at a specific directory. It may make some more sense after my next post about setting up your dev environment.

Charlie - thanks for the add!
# Posted By Joe Danziger | 8/10/06 11:02 AM
Thomas A Lenz's Gravatar This total noob finds your directions are easy to follow. Thanks for doing a meticulous job. But I have run into a snag. I'm getting this error when I click on the SVN Service Wrapper link: The requested URL /~mbn/svnservice/ was not found on this server. I've googled, but all I find are many links, all referring to the same place. Is there an alternate place to get it, or is there a workaround?
# Posted By Thomas A Lenz | 12/12/06 11:22 PM
Joe Danziger's Gravatar Weird - that site seems to have disappeared. I found a copy on my machine and posted it for download at http://ajaxcf.com/misc/SVNService.zip
# Posted By Joe Danziger | 12/14/06 12:04 PM
Brook's Gravatar Thank you for the great article. I am following along and also setting up eclipse after using DWMX for a long time.

What I am having trouble with is this; I have a development server and 2 production servers. My SVN Repository is on the dev server. I figured out how to set up 'svnserve' as a service so that I can connect to my remote repository via the svn: protocal. I work over a VPN, so the lack of encryption is okay for me in this instance. Now, my problem is w fold:

1. When I check a file in and out of the repository, I want that file to be available via my development website. Does this mean my repository should be where the website is, c:\inetpub\wwwroot\mysite.com\ or should I use a 'hook' to move the files from the repository to the webroot after each commit?

2. Next, I need to figure out how to push files from the dev server to the live server(s). I don't think I can write a hook that would do that, because I don't want ALL updated files pushed to the live server, only certain files and certain times. Maybe I need an alternate technology/solution for moving files from development to production. What do you think?
# Posted By Brook | 6/24/07 5:19 PM
TR's Gravatar I'm completely new at this and I have exactly the same questions as Brook.

Thanks for the article!
# Posted By TR | 8/29/07 1:06 PM
Bob C's Gravatar Is there anyway to tie the auth process to Active Directory?
# Posted By Bob C | 8/30/07 7:42 AM
JohnEric's Gravatar Yes, Tortoise can only create a repository on the local machine. But that also means you can do it on a network path as well. On the server you can use the command line to create a repository. Just create a new directory and then type 'svnadmin create C:\path\to\repository' at the command line.
# Posted By JohnEric | 8/30/07 9:26 AM
Gary Woodfine's Gravatar Thanks for taking the time in doing this post, it made the learning process so much easier
# Posted By Gary Woodfine | 11/15/07 1:03 PM