Blog Projects
Escape Keys
A ColdFusion and Web Development Blog by Tom de Manincor
 

I had posted a while back about setting up a Subversion Server on a Windows machine. However, now I am running my SVNSERVE on a Windows 2003 Server Virtual Machine with VMWare. With the Shared Folders feature I am able to access my repositories from the HOST machine.

When I tried to set it up as a service using the code provided in my earlier post, I kept getting errors when starting the service. I tried mapping a network drive, in order to avoid the double slashes in the URN path to the share, but no dice.

After a good noggin knock it was apparent the syntax needed to be tweaked when using the URN path to allow for the double slashes.

Use the following single-line command:

sc create "svnserve" binpath= "\"C:\Program Files\Subversion\bin\svnserve.exe\" --service --root \"\\.host\Shared Folders\DEV\repo\"" displayname= "Subversion Repository Server" depend= Tcpip start= auto

I wanted to include some 3rd party code from another repository with my current project and store it with the rest of the files in my SVN repo. Which you can do by grabbing a copy from the 3rd party and including them when you commit your files. However, having to update and export before committing can become grueling and unnecessary. Subversion offers a simpler solution with its use of Properties. External definitions, in this case. I have a few methods laid out for you.

Command Line Method:

First, make sure you have an editor set in the Subversion config file. You can find it in:

Windows

%USERPROFILE%\Application Data\Subversion\config
Mac \ Linux
~/.subversion/config

Now, make sure the 'editor-cmd' parameter is uncommented and then set it to the command line editor of your choice. Be sure to replace the word 'editor', that is there by default, with your selection. (i.e. -editor-cmd = vi).

Next, navigate to the folder of your working copy where you want to add the external repo to. Run 'svn propedit svn:externals .' This will open the editor with a temp file for you to add/edit the properties. Enter your externals like this:

local/path/ svn://external/url/ (grabs HEAD revision)
local/path/ -r# svn://external/url/ (grabs specific revision #)

Save, and exit the editor.

Update your working copy. It will now fetch the external repositories and place them into the folders specified.

Finally, commit your changes. You will see the folder you added the Properties to listed as 'modified'. This will write your external links to the server-side repo, so the next time you or anybody else pulls from the repository they will have the externals already attached.

GUI Method - TortoiseSVN (PC)

Right Click on the Subversioned folder, and go to TortoiseSVN, Properties. Click ADD, select 'svn:externals' from the Property Name dropdown. Enter the mapping and url of the external reference described above. Click OK, and OK again. Run SVN Update to fetch files, and SVN Commit to add the changes to the Repository.

GUI Method - SmartSVN (Mac)

Open a project. Right click on the root or one of the folders and select EDIT EXTERNALS. Enter your local path for the mapping, and the URL of the external repository. You can select a revision or grab the HEAD by default. Click OK. Update and Commit.

Running SVNSERVE as a Windows Service

If you are using Subversion and utilizing the native svn server with SVNSERVE, I'm sure you've noticed that the Command Line window needs to stay open in order to keep the server alive.

A simple remedy is to set it up as a Windows Service. Most will recommend FireDaemon, which is a great program. If you don't want to get into adding any extra software, you can use the SC command built in with Windows 2003 and XP.

Just use the following command:

sc create "svnserve" binpath= "C:\Program Files\Subversion\bin\svnserve --service -r f:\repos" displayname= "Subversion Repository" depend= Tcpip start= auto

But remember to update the path to Subversion if you didn't use the default, and of course, your Repository path.

Multiple Repos:

The service is looking at the root path you specify with -r. That will be the root of your SVN server. So when you point to a Repository it will look something like this:

svn://myhostname.com/repoName

If you need to run mulitple instances and point them to different root paths you need to approach that differently. Same concepts apply just specify a differnt listening port and service name.

You're command would now have an additional switch and a unique service name:

sc create "svn-pub" binpath= "C:\Program Files\Subversion\bin\svnserve --service -r f:\pub\repos --listen-port=8080" displayname= "Subversion Repository" depend= Tcpip start= auto

This is a simple guide for a simple SVN server solution. I am installing Subversion with a MacPorts nice little auto-installer for public packages.

I started off by using MacPorts to search for the package with:

port search subversion

then installed the package with

sudo port install subversion

MacPorts installs all the required packages and the latest subversion release.

Subversion is now installed. Now let's get the Server setup.

Create a folder where you will be storing all your Repository files. (/RepoHome)

Then to create a new repo from the shell run:

svnadmin create /RepoHome/NewRepoName

This next step is Optional. If you want to have user authentication, you need to go to the folder of the repo you want to add security to. In the /conf folder you will see 3 files. Open all 3 and the comments say it all.

Now, to start up our SVN server.

svnserve -d -r /RepoHome
(this loads it in daemon mode with a root path of /RepoHome)

If running a Firewall be sure ports 3690 and 80 are open.

To connect to the repo point your SVN client to:

I just posted about doing this on a Mac. After I did that, I realized I need to install this on my server and start reading up on the security settings. But anyway, very similar to the Mac install, this is even easier, actually.

Grab the latest windows installer package from the Subversion Tigris Site.

Run the installer with the defaults.

Create a folder to house the Repositories. (/RepoHome)

Bring up a command promt and run: (startuncmd)

svnadmin create /RepoHome/NewRepoName

To setup user authentication and permissions go to the /RepoHome/NewRepoName/conf folder and open the 3 files in there. The comments in the files explain it all.

To start the SVN daemon run:

svnserve -d -r /RepoHome
(this starts it with a root of /RepoHome)

Ports used: 3690 and 80

To connect to the repo point your SVN client to: