I have been using subversion since I started in Hitwise more than a year ago, and have been using externals on the day to day basics, but I have never tried to figure out how to setup externals on the subversion server myself. I have recently bought a new virtual server for my website and installed subversion server myself. Now it is time for me to learn how to configure and maintain the subversion server. My projects are divided into different directories in the repository, it would be easier to manage the whole project by using externals so that one single checkout will get everything we needed. Here’s a quick howto on using subversion externals to load other subversion repositories into various directories of your project. Firstly you need to setup the SVN_EDITOR environment variable by running the following command:
$ export SVN_EDITOR=vim
Vim is my favourite editor, you can choose whatever editor you prefer. I have created an “externals” directory under the root repository, so that all externals will be stored there for easy management. Now create a new directory for you project, for my case, I run
$ svn mkdir http://example.com/repo/externals/blog -m "create blog project externals"
Now checkout the externals directory
$ svn co http://example.com/repo/externals/blog
Change to the new directory “blog” just created by the checkout
$ cd blog
Now run the command to create external rules
$ svn propedit svn:externals .
Now you can make changes to the externals of the current directory specified by ‘.’, you can specify a path-url combination per line, then save and exit your editor to finish the change. The path part comes first, and is relative to where your setting the external. Example of the format:
include http://example.com/repo/trunk/blog/include
public_html http://example.com/repo/trunk/blog/public_html
php_include http://example.com/repo/trunk/php_include
Once your done adding externals, you can run “svn update” to actually pull down the external, you’ll need to commit to actually push the external property change to the server so anybody else working on the project gets it too.
$ svn update
$ svn commit -m "Added external for blog project"
There, any changes made to the other repository or path will come down when you do svn update. You can also commit changes within that external’s directory by just entering that and doing normal subversion commands. Happy subversion!!

Leave a Reply

Your email address will not be published. Required fields are marked *