Tuesday, September 12, 2006

How to run Subversion 1.4.0 in Windows

Subversion 1.4.0 was released the other day, adding many exciting new features.

Subversion is a modern source revision control software, a very useful utility for a developer to easily keep track of changes in source code. Subversion runs as a server, either directly through svnserve, or as a module in the Apache web server.
Subversion is open source and runs on Windows, Linux, Mac OS X and more.
Homepage is here.

TortoiseSVN is a Windows client to Subversion shell extension, integrating Subversion features directly into the Windows Explorer.
Homepage is here.

As I am developing under the Windows platform mostly, and working with web development, I have been frustrated in the past for the lack of Apache 2.2 support in the 1.3 branch of Subversion. But behold! A new shiny feature of the 1.4 branch is the svnserve, which will now run natively as a Windows service.

Now I can simply run Subversion as a separate server, and as a side effect I can upgrade to Apache 2.2.3 on my development box.

Here's a quick rundown in how to install Subversion 1.4.0 and TortoiseSVN under Windows.


1. Installing Subversion
Download svn-1.4.0-setup.exe from here.
Install Subversion to D:\SVN


2. Create a repository (Read more here).
D:\SVN\bin>svnadmin create D:\SVN\repos
This will create a repository in the directory D:\SVN\repos (the directory will also be created).
In this setup, I will use only one "root repository", and place my projects as subdirectories under this repository. There are other ways to configure multiple repositories if you prefer.


3. Configure user access to the repository
Edit D:\SVN\repos\conf\svnserve.conf:
[general]
anon-access = none
auth-access = write

password-db = passwd

realm = webroot repository
This will block anonymous read access, and allow write access to the users specified in the "passwd" file.

Edit D:\SVN\repos\conf\passwd:
[users]
martin = test123
This will allow the user "martin" write access using the password "test123"


4. Import directory into the newly created repository
D:\SVN\bin>svn import D:\webroot file:///d:/SVN/repos/webroot -m "initial import"
This will import D:\webroot and all subdirectories into the repository in the subdirectory "webroot", notice that I don't import this directly under the root directory. We will later be able to easily import different projects at the same directory level (ie file:///d:/SVN/repos/otherproject)


5. Install the svnserve Windows Service
C:\>sc create SVN binpath= "D:\SVN\bin\svnserve.exe --service --root D:\SVN\repos --listen-port 48000" displayname= "Subversion" depend= Tcpip start= auto
[SC] CreateService SUCCESS
The syntax is a little wierd, I know. The whitespace after = is required by the SC tool.


6. Starting and stopping the service

You can now start and stop the service as any other Windows service:
C:\>net start svn
The Subversion service is starting.
The Subversion service was started successfully.

C:\>net stop svn
The Subversion service is stopping.
The Subversion service was stopped successfully.


7. Uninstalling the service
C:\>net stop svn
The Subversion service is stopping.
The Subversion service was stopped successfully.

C:\>sc delete SVN
[SC] DeleteService SUCCESS

8. Install TortoiseSVN

Download TortoiseSVN-1.4.0.7501-win32-svn-1.4.0.msi (or newer) from here.
Install & reboot machine.

Choose to what directory to import the repository, and make sure the directory is empty.
Right click on the directory, in my example D:\webroot
Select SVN Checkout

In URL of repository, type: svn://localhost:48000/webroot
You will now be presented with a user authentication dialog box. Enter your username and password here and let the program remember your settings.