Simple introduction to SVN externals
Not so long ago, we’ve had to include a third-party library into a new project (using SVN). Our first idea (the one which did not imply thinking) was to SVN-export library files from the remote repository, paste them into the project, SVN-add them, then SVN-commit files.
Having to keep these library files up-to-date with official patches and improvements sounded like a full-time job.
This solution sucked.
We are programmers, and we really hate repetitive tasks because we are lazy. We spend most of our time building applications which automate human operations, why not take care of this one?
Good news, a quick googling revealed our issue was a common one, and there was already a ready-to-use solution: SVN externals.
What are SVN externals?
SVN externals allow to include (nest) a remote SVN repository into another SVN repository. They are set through SVN properties.
How do we use them?
If you’re a command-line geek, type:
svn propset svn:externals "http://svn.3rdapp.com/super-library/ library" .
This will create a SVN property at the current location (don’t miss the final dot “.” at the end) named “svn:externals”, and its value will be “http://svn.3rdapp.com/super-library/ library”. Which means: insert a directory named “library”, which will retrieve its content from a distant SVN repository located at “http://svn.3rdapp.com/super-library/”. The next time you run a SVN-update, the third-party application will be added to your SVN project.
You can do the same with TortoiseSVN Windows Shell Extension for Subversion: right-click when browsing your SVN project with the Windows file explorer, highlight “TortoiseSVN”, then click “Properties”:
Now, click “New…”, type or pick “svn:externals” in the “Property name:” drop-down, then type “http://svn.3rdapp.com/super-library/ library” in the “Property value:” textarea. Click “OK” twice:
Now, every time a new version of the third-party application will be released, it will be reflected when you SVN-update your local copy of your project.