Having a Version Control System is almost mandatory for every developer because keeping track of the evolution of his code is highly desirable. Such a system allows the developer to have individually registered version of every file in his system, including source code, documentation, diagrams etc.
Subversion (AKA as SVN) is such a system. It is open source and is considered an evolution of CVS with new features and a new internal architecture which allows SVN to have significant changes and improvements when compared to CVS, such as directories versions, truly atomic commits etc.
After this brief introduction, let’s get to work. As I am using Windows as platform for development (flames expected here ;) this article will give you the steps on installing SVN on this platform. If you are using Windows there are 3 ways to get subversion on your system:
1. Get an installer from Collabnet site.
2. Get a zipped file with binaries from tigris.
3. Get the sources from the repository and compile them on your system.
I’ll stick to the first two situations, because you would normally need the third one only if you need the latest features on the system. The stable releases should be enough for most needs.
Using Collabnet’s installer
Collabnet is the company that designed and created subversion. Using this prepared installation file should be the easiest way to get subversion up and running on your windows box. It comes with the SVN server, a SVN command-line client and an apache server almost ready for running svn.
CollabNet provides a readme file with basic instructions on creating a repository, clearing the firewall to let SVN do his work etc. It is a good basic reference. So, simply download the file (version 1.4 as of the time of the writing) and follow instructions.
Using ZipFile Binaries
This installation option is a little bit more difficult than the one above but everyone should do fine. I will not cover apache installation on this article.
Step 1
First of all you should download the latest version of the server available from subversion project downloads page. As of the time of this writing it is version 1.4.2. You may choose to download the sources and compile them yourself or download the binaries created by contributors to the project, which though not maintained by the project team are normally reliable packages. Now scroll the downloads page down to find the binaries for SVN Server for Windows. When you are redirected to the page find the latest release (should be the last one in the list) and get the file which name looks more or less like this svn-win32-X.X.X.zip (the one I got was svn-win32-1.4.2.zip).
Step 2
Unzip the file somewhere on your hard disk where it would make sense to have the subversion binaries. We will call this folder the subversion home directory (%SVN_HOME%). For example, if you unziped the files for SVN version 1.4.2 under C:\Program Files folder, your %SVN_HOME% dir would be: C:\Program Files\svn-win32-1.4.2. On the %SVN_HOME%\bin folder you will find the executable files which you will use to maintain your server and repositories.
svn.exe - Subversion client
svnadmin.exe - Subversion repository administration
svndumpfilter.exe - Subversion dump fle filter
svnlook.exe - Subversion repository browser
svnserve.exe - Subversion Server
svnsync.exe - Subversion repository replicator
svnversion.exe - Subversion revision extractor
Step 3
Let’s create the repository. Add the %SVN_HOME%\bin folder to your path variable in Windows to make the binaries accessible from anywhere in your computer. Now, create a test repository folder somewhere on your system (let’s say c:\temp\svn-test-rep) and we will call it the %SVN_REP%.
Run the svnadmin command to create a repository called repos1. You will do that running the following command:
svnadmin create c:\temp\svn-test-rep\repos1
As a result you should have a folder called "repos1" under %SVN_REP% with the following content:
DIR --- conf
DIR --- dav
DIR --- db
------- format
DIR --- hooks
DIR --- locks
------- README.txt
Step 4Now we should test the server. This is as simple as running the command below:
svnserve -d -r c:\temp\svn-test-rep
This will get the server up and running. The "-d" tells the server to run as a daemon and "-r" tells the repository name.
Remember to enable svnserve to run on your firewall if you have one (if you don’t, you should get one ;)).
Now open another command prompt (while the server is still running), go to your "temp" folder and checkout the repository you created on step 3. Checking out a repository means getting a local version (copy with a revision number) from every file present on your repository. You can do that by typing:
svn co svn://localhost/repos1
This command will ask the svn server running on localhost to get the latest revision of every file on repository called "repos1". The "co" in the command line stands for "checkout" and "svn://" specifies the protocol used to access the repository. If had apache installed and setup to run svn mods we could use http or https to access the repository.
Well, this pretty much tells you how to install a SVN server and create repositories for your code. Of course now you will get worried about issues like: who can access my files or how do I specify security constraints? This should be subject for another article, as well as svn GUI clients and apache server.