The long and short of it
This article covers how to quickly install Subversion on a standalone Mac OS X workstation. If you are a developer who has used a source control program like CVS, and really don’t care about all of the different ways of setting up SVN, other than for personal development purposes, then this article is for you.
Some people want to get stared quickly and others enjoy the narrative. I have included both the long and short. The long narrative starts right after this paragraph. The short of it starts at the section titled, “How do I get started?”
The journey begins
Every wondered how to quickly set up Subversion, aka SVN, on your home workstation? I did, and it took me some time to figure out how to do it right. I’ve actually used Subversion at work and was able to set up the environment the way that most documents illustrate. When it came time to set it up on my home computer, I encountered a whole new experience that wasn’t pretty.
So, to save you some grief, I put together this article so that you can learn from my experience and maybe learn some things on the way. As with any endeavour, you should be careful of what you do on your computer. If you decide to install the software listed in this article, back up your computer first! This is common sense, but not too many people practice this until after the fact. So with that said, back-up your computer and come back when you are ready.
Save Your Butt
I’ve used CVS and SourceSafe in the past. Both programs use the same concept of source control where you have a central repository that stores a copies of your files in your project. You check out a file or whole projects onto your computer, do your work and the check those files back into the repository. The source control server then checks your files against what is in the repository, and depending on the options your have set up for your environment, asks your for additional bits of information, such as a log for the file commitment.
I’ve heard about Subversion from a fellow developer and I was intrigued. When this guy mentions a program, it’s usually good. After some poking around, I found that Subversion has a lot of nice features and some weird ones. SVN offers a really nice way of handling directories and tracing the history of those folders. Since I worked a lot with directories, SVN seemed like a good tool.
The Good, The Bad and The Ugly
I had the fortunate opportunity of installing Subversion at my office alongside CVS. The process wasn’t too painful: the documentation called for Apache to be installed along with WebDav components and this worked well on my server. The client computers used SmartSVN as a GUI client and importing projects into the server wasn’t too hard. SVN seemed quicker than CVS and worked very well over SSH connections.
I also had the unfortunate opportunity of setting up SVN on my home computer. All of the documentation available stated that you need to use Apache to have the clients work with the SVN server. So, there I was trying to figure out how this would actually work on a standalone computer. I couldn’t find anything that showed a single workstation set up and I even tried installing Apache with WebDav on my home computer. This just didn’t make sense! There are a lot of developers that work on their on computer and use that same computer for versioning their work. CVS of course made it very easy, and SVN seemed like the opposite.
So what happened? I did a lot of reading, that’s what happened. I haven’t done this much reading since I first learned C. To me, a source control program doesn’t seem like something that should require so much research, but times have changed and so have the tools.
How do I get started?
So enough talking and let’s get down to business. Here are the steps that you need to take to install a standalone version of SVN on your own computer along with a client that allows you to check out/in your project files.
Step 1: Download the software
This goes without saying. But what do you need? You need the following tools:
1. Subversion, aka SVN, can be found at http://subversion.tigris.org/
2. [Optional] A good graphical tool like SmartSVN
Step 2: Install the software
Mac OS X
These instructions came from the Apple Developer Connection site, http://developer.apple.com/tools/subversionxcode.html, but here is my shortened version:
1. Download the source files from: http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=260&expandFolder=74
2. Open the Terminal application, found in /Applications/Utilities/.
Extract the zip archive:
$ cd ~/Desktop
$ tar xvfz subversion-1.4.5.tar.gz
$ cd subversion-1.4.5
Compile the source code:
$ ./configure –prefix=/usr/local \
–mandir=/usr/local/share/man –with-ssl \
–with-apxs=/usr/local/apache2/bin/apxs –with-zlib \
–enable-swig-bindings=no –without-berkeley-db \
Run the make command, and then run the sudo make install command:
$ sudo make install
Add the ‘/usr/local/bin’ path to your profile:
$ cd ~
$ echo ‘export PATH=”$PATH:/usr/local/bin”‘ >> .profile
If you don’t want to go through that trouble, you can run the following shell script on your computer: SubversionInstall.sh.
Step 3: Create a repository
This can be the confusing part. In a version control system like CVS, you have a single repository where all of your files and their versions are kept. In Subversion, you can have one repository for all of your projects, or you can create a repository for each project or a combination of both. I took the way that I am most familiar with and created a single repository for all of my projects. To create a repository, you type the following command in the Terminal App:
$ svnadmin create /path/to/your/repository
The repository can be anywhere you like. If you want to place a folder named ‘SVN’ in a Development folder in your Documents folder, you would type in Terminal:
$ cd ~/Documents/Development
$ svnadmin create SVN
The last command creates the SVN folder and all of the items in it to support the Subversion repository. You can name the folder anything you want; you don’t have to use SVN as the name of the folder.
Now that you have a repository, it’s time to create some folders for each project…
Step 4: Create folders for each project and import
So, to create a folder for your project, type in this command in Terminal:
$ svn mkdir -m “Creating project folders” file:///Users/yourname/Documents/Development/SVN/MyProject
You can repeat this command for however many folders you need to create. To create multiple folders at one, you can separate each path with a backslash:
$ svn mkdir -m “Creating project folders” \
To import your work into any of the folders you created, you can import your code using the following command:
svn import /path/toyour/projectfolder/MySmallProject file:///Users/yourname/Documents/Development/SVN/MySmallProject \
–message ‘First time project import into Subversion’
Just like any version control software, you have to check out the project before you start to work with it:
svn checkout file:///Users/yourname/Documents/Development/SVN MySmallProject
Notice that I first changed directories to a CPP folder. When you checkout the project for the first time, Subversion is going to copy all of the files from the repository into a new folder named MySmallProject in the CPP folder. That is a one time thing: every time you check out the project afterwards, Subversion will check the version of the file that is in that directory and do an update where necessary.
Maybe by now, you are saying to yourself that this is too much work. Well, that is were graphical tools come in handy..
Step 5: Explore Subversion with SmartSVN
SmartSVN is a great tool for working with your repository. It gives you a graphical view of your file history and allows you to see what files have changed. In the next installment, I will show you some basic commands using SmartSVN and how to use Subversion with Xcode.
Till then, happy coding!