Categories

Tags

Archives


Using svn:externals


This post was published on Sunday 13 April 2008.

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!