View all posts filed under 'SVN'

TortoiseSVN, Subclipse, how’s it all work?

Thursday, 6. December 2007 8:33

I’m just going to quickly talk about how I use SVN. That doesn’t mean it’s the right way, or even remotely the way it’s supposed to be used, but I’ve noticed on some forums and mailing lists that the SVN ‘getting started’ step seems to have been left out.

What you’ll need for this is a computer (what a wag!), Eclipse downloaded and installed (basically unzip into a directory) and that should be it. Apologies to Mac users I don’t use a Mac and these steps are for a Windows PC. Also this is not going to be about connecting to remote repositories, this is about creating a local SVN repository and connecting to it. So this is for developers who are just starting out with SVN and source control and want to manage their projects locally.

OK, disclaimers out of the way, lets get going.

Then go and get Tortoise SVN from here.

Run the installer, this will probably require a reboot after it’s installed.

Once you’ve done that and the machine is back up if you right click you’ll see a few extra options.

Right Clicking with Tortoise SVN Installed

This is the nice thing about Tortoise, you don’t need to open another application, it’s there in the file menu.

Go to where ever you want to create the repository and create a folder. I’ve just called mine ‘myProject’.

Right click on myProject and select ‘Create Repository Here’.

Create Repository

Select ‘Native filesystem’ (Should be selected by default) and hit OK.

Repository Created

(Hopefully!)

Open Eclipse. Go to Help -> Software Updates -> Find and Install.

Select Search for new features to install and click next.

Click on New Remote site.

Give the site a name of Subclipse and in the URL field put the URL to the Subclipse update site, currently http://subclipse.tigris.org/update_1.2.x.

Subclipse Update

Hit OK and follow the install instructions. (If you’re anything like me just keep clicking on OK or I agree until its down and installed.) Eclipse will prompt to be restarted, let it do it. If there are any problems at this point close eclipse, go to the command prompt and navigate to your eclipse install directory. Type eclipse – clean and hit enter. This launches eclipse with a clean cache and also lets it know to look for the new plugins.

This is the bit where it is a bit Irish (and I’m half Irish, so I should know). For these purposes I’ve created a new project in Eclipse called – wait for it! – myProject. (But what about the repository? Hang on…) Just FYI, it’s a flex project, but that doesn’t matter.

Flex Project

Delete the project, making sure that you have selected not to delete the contents!

Do Not Delete Project!

Navigate through the file explorer to the project created by Eclipse (not the repositorty).

Right click -> TortoiseSVN -> Import.  (Import?  But…. Yes I know – that’s the Irish bit.  The best way I can get my head about it is to think in reverse a bit.  Forget about the fact that you’ve just clicked on your project, we are actually at the repository.  So we are pulling the project in,  not pushing the project out.  Yeah – that makes sense.  Sort of.)

SVN Import

If you don’t see the repository you created click on the drop down icon on the right and select it from there. As you can see Captain Clever (me) has smartly placed the repository in New Folder(3). No matter, probably better for a real application not to copy exactly what I’ve done. I think it’s a good idea to pop a message in, so I’ve just added ‘Initial Import’ to the message area. Hit OK and hopefully : -

SVN Imported

So now we’ve added the project to the repository. Now delete the myProject project folder (not the repository……). Just in case – make a copy first ;)

Now we need to make a note of the URL for the location of the repository. As it isn’t on a server per se, the repository location is a bit different from a normal URL, and this is the easiest way to find it. Right click anywhere select Tortoise -> Repo Browser. This then opens a dialog where you can select the repository you want to look at. We are not interested in looking at a repository through Tortoise, but clicking on the drop down lists the repositories,normally with the newsest at the top of the list.

Finding the repository

Write down, or copy the location of the repository.

Back to eclipse.

Open the SVN Repository Exploring Perspective. Do this either through the quick link on the right, or through Window -> Open perspective -> Other and select SVN repository exploring from the list.

Right click in the SVN Repository window and select New -> Repository Location.

Add Repository Location

This launches the add repository dialog box. Type or paste in the repository location.

Adding Repository Step 2

Hit OK. You will now be connected to your repository and can explore it in the SVN Repository window.

Viewing the Repository

Right click on the repository and select Checkout.

Checkout Step One

These setting should be fine, but just check, then DON’T HIT FINISH! It will create the project in your defined workspace. This my be OK for you, but I rather keep my projects saved somewhere else than the workspace as I flit back and forth in workspaces as is my wont. Click next.

Checkout Step Two

Uncheck use default and browse to where you want your project to be saved. Hit finish.

Navigate back to the programing perspective you use – in my case Flex – and you will see the gleaming project, now under SVN source control in the Navigator window.

Done!

The silos icon indicate the file/folder is up to date in the repository and numbers after the files represent the version the file is at, the name afterwards is the person wot done it.

To commit changes back to the repository right click on the project folder Team – > Commit.

Right – I’m going to stop here, the repository is created and now you can have fun playing with the extra functionality of SVN gives you.

P.S. If you are working to a local repository and your machine blows up – don’t blame me…

Category:Eclipse, SVN, Tutorials | Comments (2) | Autor: admin