SVN set up for idiots

Ok - so maybe not for idiots. Anyone that wants to use SVN for source control can't be all daft.... ;)

I've used SVN and Trac in the past with other peoples projects, but having seen Andy Allan's post on setting up Trac on windows and then listening to the guys at ColdFusion Podcast doing their schpeel on SVN I decided that it was time I sorted out my own SVN server for work.To start with I got thoroghly distracted by the big blob of yellow text on the binary packages page on the SVN site that says that the SVN client works on windows, but the server doesn't. Then I got distracted by the SVN FAQ that also says that SVN Server doesn't run on windows and talks about the Apache Portable Runtime. All this had Andy giving me weird electronic looks via google talk and asking me wtf I was talking about! All I had to do was install SVN and Apache and that was it!

I should mention that I asked Andy about SVN 1 Click Set up - his response was fairly to the point and suggested that blunt instruments would be used about my bodily-person if I used it, because it sets up SVNServe which can cause concurrency issues and Apache is better anyway.

So I resorted back to Google and came up with this article! HOWTO: Subversion for Windows with Apache server - a beginner's guide. This article is very good. It provides all the information you need to get up and running, including setting up users, permissions and backing up your projects, as well as providing a direct link to the SVN windows downloads.

I used the svn 1.3.2 setup exe and that worked fine for me.

The next task was to get my existing project into SVN. Eclipse 3.2 with subclipse didn't seem to have a means to put an existing project into a repository or at least no clear means of doing this. I've used TortoiseCVS before, so I grabbed TortoiseSVN and installed that. Annoyingly Tortoise asks you to restart at the end of installation, but you can quite happily ignore that and it'll work anyway.

TortoiseSVN attaches itself to the right-click menu providing you a bunch of SVN tools for folders and files. For a folder that isn't already associated with SVN there are only a couple of options - one of those options is "export". The export function allows you to specify an svn repository and folder and export the content to that repository. So thats exactly what I did!

I made sure I had my trunk, branches and tags folder made in my project's SVN repository, selected my existing project and then exported its content to the trunk folder.

The last thing I had to so was get eclipse to synchronise with SVN.

Under SVN Repository Explorer I added the url for the project's repository, right-clicked on the trunk folder and then selected "checkout". I was then prompted to create a new project or to select an existing project. I selected my already existing project.

Now - something slightly scary happens.... You get prompted to delete the existing project content. As long as no one has edited any of the files in your project since you put them into the repository this is fine - all your files get replaced with the exact same files from SVN.

My project is pretty small at the minute, so its not like it had to replace a vast quantity of files. You might also want to download the SVN version into a new project and move/remove the existing project yourself.

There's probably an easy way to put your eclipse project that I've completely missed without all this messing. If anyone knows, please drop me a note.

Next job is installing Trac from Andy's blog entry.

TweetBacks
Comments
Thanks for the tips, this was very helpful. I think you have to delete the project at the end because they don't want un svnized projects floating around anymore. Or at least this was how cvs was described to me a long time ago...
# Posted By Tyler Weaver | 3/13/08 9:39 PM
Thanks for this post, I've been having all kinds of pains understanding the FAQ's as well, and after reading your post it seems pretty clear on how things are done. Setting up SVN tommorrow at work! :)
# Posted By craig | 3/13/08 9:39 PM
I'm glad you found the post useful...

I should note though that the you no longer have to do the scary export/import of a project into SVN. If you right click on the project title and bring up the "Team" menu item you'll find "Share Project". This will allow you to put your project into SVN and set up all the client side SVN stuff without having to export and then import the project all over again. Much less scary! :D
# Posted By Stephen Moretti | 3/13/08 9:39 PM
If I already have the above set-up, but I now want to put the repos online
to be able to share it with someone abroad, how would I do that?

Any explanation as clear as the above would be highly appreciated.
Thanks.
# Posted By Nicole | 3/13/08 9:39 PM
Nicole,

If you've got svn running through apache you should now be able to give the url of the project to whoever you like. Say the IP address of your server is 12.345.67.890 and you have a project called "myproject" The address you would give to the other users of the repo would be http://12.345.67.890/myproject If you have a DNS entry assigned to the IP address, say "svn.mydomain.com", the address would be http://svn.mydomain.com/myproject

If the IP address of your svn server starts with 10. or 192. These are IP addresses for your internal network only. You will need to find out what your external IP address is - your network administrator should be able to help you with that.
# Posted By Stephen Moretti | 3/13/08 9:39 PM
Hi Stephen,

First of all, thanks a lot for your quick reply.

The thing is, SVN was installed by someone else, using the SVN 1-Click setup (the one that you did not recommend). Then he put the project on SVN using the SVNTortoise. We then checked out the project from eclipse with subversion. Now, we need to access it abroad, as I mentioned.
So, should I reinstall SVN with Apache or do you think there's a way to make it work with the current setup?

P.S: Sorry for what may be sounding like really silly questions. I am a beginner at this. :D
# Posted By Nicole | 3/13/08 9:39 PM
Nicole,

Don't worry about silly questions - everyone is a beginner at some point (I was when I originally wrote this blog entry)

You shouldn't need to set up SVN again - you should be able to follow the instructions in the HOWTO guide (http://svn.spears.at/#3.2) on setting up and configuring Apache. Once you've got apache and SVN talking to one another you should simply be able to disable SVNServer and connect through apache instead. It shouldn't be too difficult, but as I've always used Apache I don't have the specifics of what is required.

I guess the only thing I would make sure you do is duplicate all the user names and passwords from SVNServe in your Apache auth config, which should give you a fairly seamless transition for existing users.

For more information on configuring svnserve on windows (and disabling it) take a look in the svn red book : http://svnbook.red-bean.com/en/1.4/svn.serverconfi...
# Posted By Stephen Moretti | 3/13/08 9:39 PM
Hi,
Thanks for such a nice post for a beginner like me.

I have few questions and I will really appreciate if you could give some help.

The system (it is redhat not windows) is already running with SVN and apache installed and working fine for a set of user and their files. All this is done by someone else and I have to take of the system. Now my job is to create a set of new users and provide them access authorization without touching the existing users and their file. The new users too should be able to access the svn through apache. I guess I have to create a new svn folder. I am confused on proceed further.
Could you please give some guidelines.
Cheers.
# Posted By thabo | 3/13/08 9:39 PM
Hey Thabo, Glad you like the post... With a bit more experience now I feel like my post is a bit out of date - I really should write a new post :)

With regards to managing svn users and their access rights - unless you need a new repository you should be able to add the users to the existing password and authz file. To find out where you password and authz files are, take a look in the config files for apache. You should see some entries that look like this:

AuthUserFile /somepath/dav_svn.passwd
AuthzSVNAccessFile /somepath/authz_svn.access

To add new users and passwords take a look at the apache documents for htpasswd on http://httpd.apache.org
For authz settings take a look at the svn server config link I gave to Nicole above. Look for and read through the authentication sections.

Hope that helps
# Posted By Stephen Moretti | 3/13/08 9:39 PM
Thanks for such a quick reply and I will get back to you when I get through it.

Cheers.
# Posted By Thabo | 3/13/08 9:39 PM