Not too long ago, I had a need to tie a number of svn repositories together. What I wanted was to create a 1 repository with a number of sharable assets (images, language files, 3rd party libraries, shared code) and have other repositories somehow link to it.
The way I had handled this in the past was simple: checkout each svn repository and cross reference them. As an example, my directory structure would look something like:
AssetRepository/references/xunit.dll Project1Respository/Project1.sln Project1Respository/Project1.Tests/Project1.Tests.csproj
I would then add a reference to the xunit.dll from Project1.Tests, which would use the following relative path: ../../AssetRepository/references/xunt.dll.
This solution works great, except it imposes a structure that each team-member must adhere to. In this case, all repositories must be at the same level within the same folder.
Luckily, Subversion has a better solution, the svn:externals property. svn:externals essentially creates a shortcut/link from a folder in one repository to some other repository (or to another place within the same repository). Once 1 person sets it up, it just works for everyone else – they’ll never know that AssetRepository even exists.
How do you do it? If you are using TurtoiseSVN, right click on the Project1Repository and pick “Properties” from the TurtoiseSVN context-menu. Add a new entry with the name of “svn:externals” and a value to the local path + SPACE + external repository. In our case, value would look like:
That’s all there is to it. You checkout the Project1Repository, you’ll end up with an extra folder:
Project1Respository/Project1.sln Project1Respository/Project1.Tests/Project1.Tests.csproj Project1Respository/References/xunit.dll
You might think that you need to create an empty ‘References’ folder at the root of your Project1Repository – don’t. The local path specified in your svn:externals definition should not physically exists within that repository.
That’s all there is to it. Other developers can now checkout/commit without ever knowing how things are set. If they change a file within the References/ folder, it’ll commit to the proper repository, namely AssetRepository.
You can learn more from the red-book