Tag Archive for 'subversion'

Using svn:externals

After learning most of the basics of subversion, I discovered I had missed one of its most useful features: svn:externals.  This allows you to checkout multiple repositories into one location.  For a more detailed definition, go here.  To access the property, use your subversion program (look for an option called 'Show Properties' or something like that).  Or, if you can log into your server's shell:

$ svn propedit svn:externals ../some_dir/another/

This will open vim (or whatever text editor you have) to edit the property 'svn:externals' for the directory '../some_dir/another/'.  You don't have to be in the directory to edit its svn properties – simply specify the relative path to it at the end of the command.

The best way to think of svn:externals (and the other svn properties) is as an invisible file.  There is one for every directory in your repository.  This means that when you checkout a project, it also checks out the external variables into the folders you specify.  So, for example, I have all the code for my website in an SVN repository, and in the root web directory (public_html) I have this line in svn:externals:

blog    http://svn.automattic.com/wordpress/tags/2.5/

This checks out whatever files are in the repository at 'http://svn.automattic.com/wordpress/tags/2.5/' into the directory 'blog'.  This is basically it, but there is one more thing I didn't realise at first.  If you want to checkout a project into a directory, say public_html/blog/wp-content/themes/some_theme/, you don't have to add the command to the svn:externals property of the 'themes' directory.  Instead, you can do this, in the svn:externals of public_html:

blog/wp-content/themes/some_theme    http://some_repos/trunk/

You can have as many of these as you like.  I use them to checkout plugins for my blog – as you can see from this example file.  If you hadn't already discovered svn:externals, I hope you find it as useful as I do!

Custom SSH port with svnserve

I had some trouble accessing my svn repository on my server.  The people who host my website use a non-standard SSH port, and they force you to access the svn server through SSH – but without telling svnserve to use the non-standard port!

So, after much trawling through the internet, I finally found the solution, thanks to this page.  Their solution didn't quite match my needs (as they assume root access for the Linux shell, which I don't have), but it got me over the hump.  Their solution is to set the global variable $SVN_SSH, '
It seems like the environment variable is the only way to set the SSH port.'

However, this is wrong – there is another way, and it is more elegant, I think.

The subversion configuration file settings on a standard Linux setup can be found in the '.subversion' directory.  In this folder you can find the 'config' file.  Open this, and you will find the '[tunnels]' section.  Add the following code to that section:

custom_ssh = $SVN_SSH ssh -p 12345

This creates a custom ssh access protocol which is identical to the standard one, except with a different port number.  If you want to specify a different (or non-ssh) protocol you can do that too.  More details can be found here.

To access the repository now, you simply use this:

$ svn co svn+custom_ssh://username@server_ip/path/to/repos/ .

instead of this:

$ svn co svn+ssh://username@server_ip/path/to/repos/ .

Problem solved!

Eclipse and Subversion over SSH

I use subversion for my version control – and I have recently had to set up Eclipse to access the subversion repository on my new server. This proved trickier than expected, largely because of bad instructions all over the internet!

Many of them provide instructions for setting up a tunnel in putty, or through TortoiseSVN. Both are unnecessary with the right Eclipse setup.

These instructions assume you have setup a repository on your SVN server, and have imported files into it. For instructions on how to do this, please go here:

SVN QuickStart

First, you need to install WebTools (WTP) and Subclipse in Eclipse. I use the PHP Development Tools (PDT) plugin to edit PHP scripts – the PDT 'all-in-one' package comes with WTP pre-installed. Instructions for installing Subclipse can be found here:

Subclipse Update

Once you have everything installed, open Eclipse and go to the Window... Preferences.

Navigate to Team > SVN and set 'SVN interface' to 'SVNKit (Pure Java)'. Click OK.

Now go to Window...Open Perspective...Other... Select 'SVN Repository Exploring' and click OK.

In the 'SVN Repository' window, right-click and select New... Repository Location.

The URL is in the format:

svn+ssh://username@server_ip_address/path/to/repos/username is the username you use to log onto your server over SSH
server_ip_address is pretty obvious.. I find IP addresses work better than domain names
/path/to/repos/ is the full filesystem path to the repository (e.g. /home/ben/svn/)

Click 'Finish' and you will be taken to the 'Enter SSH Credentials' page.

Your username will be pre-filled. Select 'Use password authentication', and enter your password. Ensure that the port information is correct. The default is 22, but if your server is behind a firewall it is likely to be something different. Check 'Save Information' if you want to, and click OK.

Eclipse will now load your repository in the 'SVN Repository' window. For instructions after this point, check out the SVN QuickStart (the link is earlier in the post).

Categories

Twitter

Recent Comments

Archives