September 03, 2006

Configuring Subversion on Eclipse

Trying to install SVN (Subversion) on Eclipse for the first time was a bit tricky for me. There seems to be a lack of resources on the subject, or a latent assumption that it's too trivial, so,
here's how I did it:

Prerequisites
1. Apache installed (on your server). If you're using WinXP OS on your server, you must have Apache2.0 installed, as the svn modules are not compatible with Apache2.2.
2. Eclipse installed (on your client)

What to do:
1. Download and install SVN on your server
http://subversion.tigris.org/
This, along with the Apache service will be the Version Control server.

2. Download and install TortoiseSVN on your server (and possibly on other machines)
http://tortoisesvn.tigris.org/
TortoiseSVN integrates with the windows explorer itself (not to be confused with IE..), so, after installation, you will have a few more options when right-clicking a folder or file (namely, you can choose to import them or checkout an existing repository).

3. Open a new Repository
We will now instruct the SVN server to open and import a new repository (a managed storage place for you code\documents).
Right click on a new folder, and have the TortoiseSVN import your data there

4. Download and install Subclipse using the Eclipse IDE
Use the Help->Software Updates->Find and Install menu
Configure a new Update Server for the Subclipse plug-in at:
http://subclipse.tigris.org/update_1.0.x
This tells the Eclipse to download a plug-in, with which it is able to communicate with the Subversion service.

5. Checkout the Repository
Create a new directory on your computer. You can checkout a project from the repository to that directory either by using the Eclipse IDE or via the TortoiseSVN itself (right-click on the directory and select checkout). If Indeed TortoiseSVN is installed on your local computer, the Files and Folders under that directory are now marked with Green Checks, indicating that they are up to date. Notice each folder now contains a hidden directory called .svn. Do not delete these directories.

6. Configure the post-commit hook
If you're working on a web-application like me, you will want a read-only copy of your code (sometimes called a mirror) on a directory accessibly by your HTTP service.
This copy should be updated to reflect the changes made by you or your team members while using the Eclipse IDE.
Subversion provides a hooking mechanism (in the hooks directory, under the repository directory). I use a modification of the post-commit file, taken from
http://www.svnforum.org/2017/viewtopic.php?t=1694.
Essentially, this batch file is called after each commit, and causes the Subversion to update a working copy at D:\WorkingCopyPath.

@ECHO ON
REM POST-COMMIT HOOK
set repo=%1
set rev=%2
set log="D:\SVN\Repository\logs\post-commit_log.txt"
set err="D:\SVN\Repository\logs\post-commit_err-log.txt"
set svn="C:\Progra~1\Subversion\bin\svn.exe"
set svnpath="C:\Progra~1\Subversion\bin"
( echo ========================================================================
echo Start commit %repo% r%rev%
date /t
time /t ) >> %log%
set cmd=%svn% update D:\WorkingCopyPath
(start "start-title" /D%svnpath% /BELOWNORMAL /B %cmd% >> %log%)

That's about it. Hope you find this helpful.

1 comment:

Tomer Levinboim said...

Here are some additional useful links \ info

the svn book
http://svnbook.red-bean.com/en/1.1/ch06s04.html

Installing on uniformserver (I didn't actually try this, but it gives some insight as to what should be done in the httpd.conf file, if it's missing)
http://wiki.uniformserver.com/Installing_SVN

creating a repository manually
[taken from http://svn.haxx.se/users/archive-2006-02/0926.shtml]

cd \temp\svn
svnadmin create repo
mkdir import
time /t > import\test.txt
cd import
svn import -m"" . file:///c:/temp/svn/repo/
cd ..
mkdir wc
svn co file:///c:/temp/svn/repo wc