BIT-101 [2003-2017]

Setting up SVN with MediaTemple Grid Server and Subclipse


I’ve helped a couple people with this already, and I keep forgetting some of the details myself, so I thought I’d write it down so it’s here when I need it, and anyone else can benefit from it too.

One of the neat things about having a MediaTemple Grid Server account is that it comes with an SVN server. Since you get something like 100 GB storage with your account, it makes sense to host your source control there, not on the same machine you are developing on, or another machine sitting right beside it. I guess what I’m saying is if your house burns down, at least you won’t lose your source. 🙂

One of the tough things about the MT implementation of SVN though, is that it uses the svn+ssh protocol. Actually, I suppose there are some security benefits there, but it can make it a bit more confusing to set up.

So, there are two steps to setting up SVN with MT and Subclipse. First of course is creating your repository on the server. This you have to do by hand. You’ll need some way to ssh into your server. Putty is the tool of choice (free) on Windows. On OS X just fire up the terminal and type ssh.

Once you’re in there, just follow this article:

https://kb.mediatemple.net/article.php?id=143

Actually, just follow the first three steps of that article to set up the repository itself. Don’t go making directory structures and importing them. You’ll do that via Subclipse.

The next step is connecting to your repository in Eclipse via Subclipse. First, of course, install Subclipse. This page walks you through how to do that: https://subclipse.tigris.org/install.html. Follow the whole thing, step by step. When you are done, you should have the SVN Repository View open.

There’s a very important step here that took me forever to work out, but is really very simple. Go to Eclipse’s preferences, and go down to Team/SVN. You’ll see a section there called “SVN Interface”, with a couple of radio buttons. Probably, the “JavaHL (JNI)” checkbox is checked. You don’t want that. Instead, check the other one, “SVNKit (Pure Java)”. Click ok to close prefs. I have no clue what this is all about, but if you don’t do this step, you won’t be able to connect. So do it. This seems to hold true for both Windows and Mac.

Next step is to connect to your repository. Click on the “Add SVN Repository” button in the SVN Repository View. This opens a dialog where you enter the url to your repository. COMPLETELY IGNORE the steps from the MT article on how to set the url. It will not work like that in Subclipse. Instead, enter your repository path like so:

svn+ssh://mydomain.com/home/xxxx/data/reposname

Where mydomain.com is of course your domain name, xxxx is your MT account number, and reposname is whatever you named the repository when your created it. Do NOT try to stick your username/password in the url like it says in the MT article. Also, your MT Account id may include a letter, like “s1234”. The account NUMBER does not include that letter. It would just be “1234” in that example. After that, press finish. This should prompt you to enter your user name and password. You shouldn’t need to escape the @ symbol here. Just type it in. It’s usually something like serveradmin@mydomain.com. Password is whatever it is. You can check the checkbox to save this information, so you don’t have to enter it each time. I think it also asks you to type your name so it knows who is checking things in and out.

When you are done with that, if all goes well, you should connect to your repository and it will show up in the view. If not, you’ll get an error message saying what went wrong. Assuming you got it going, we’ll move on.

Now you need to set up a folder for your first project. Right click on the repository in the list and choose new folder. Name the folder whatever the project name is, i.e. myproject. You can now right click on myproject and add a tags and branches folder as well, if that’s how you set up your repositories. Do not add a trunk folder yet!

Now you are ready to import your first project. Assuming you have a project open in Eclipse, right click on the project, or whatever portion of it you want to check in. Go down to Team, and choose “Share project.” Choose SVN, and the repository you just connected to. Now it will ask you to choose a folder to check into. It defaults to using the actual Eclipse project name. But you should choose to use a specified folder name, and then browse to the project folder you just created. Now it’s going to tell you can’t use an existing folder, so will tack on “New Folder” to the path. Change that to “trunk”. Now you see why you didn’t create the trunk folder before. If you’ve done everything right, the url shown in the dialog should be something like:

svn+ssh://mydomain.com/home/xxxx/data/myrepos/myproject/trunk

You are good to go. Hit finish and it should create the folder and look through your project and present you with a list of things it things it should check in. It will skip the bin directory, but will probably include everything else in the project. It’s up to you how much you want to include. If you accept the defaults, you can then check the project out on another machine as a full blown Eclipse project, ready to run, which is kind of cool. But you might just want to check in the source folder. Again, up to your way of working. Hit OK, and it will check everything in. You are done.

Now you’ll notice that all your checked in files will have little icons on them in the Navigator. A yellow thing means it’s checked in. A gray star means it’s changed locally. There is no indication that the file has changed in the repository, so if you have more than one person working on a project, or you work on it from multiple locations, you might want to do an update before you start working each day. New files are marked with a question mark. When you’ve done some work and want to check in, right click the project and go to Team / Commit. This will present you with a list of changed files and new files. You can choose which ones to commit.

That’s all there is. The rest is just straight version control. I highly recommend the book, Pragmatic Version Control with SVN, to learn more about it if you are new.

Oh, one other thing I should mention. When you go to check out a project, don’t make the mistake I did a couple of times, of clicking on the project itself in the repository view and choosing checkout. This will check out the whole thing, trunk, tags, branches, whatever else you’ve got in there. You usually want to open the folder and right click on trunk, and check that out.

« Previous Post
Next Post »