Sharing a development codebase among different teams and different offices can be a real challenge. Like many developers we use subversion to control and manage project repositories and to collaborate on projects. While there are other options like TFS or Git, if you’re using subversion or are planning to implement it, it takes some work to get off the ground. In this week’s Noodles & Doodles, I’ll walk you through how to share code using SVN externals and shared repositories. Enjoy!
A new addition to this structure is a new folder we’re calling a site to hold project-specific code that will not be shared across all projects. So what we’re doing here is we’re now splitting this out and placing or repositioning the files in the new file structure. So you would grab the all components under the admin tools, for example and create corresponding sub-folders and place the files in the admin tools area. You would grab all of your, all other things under code that are not worthy by your decision of being extracted out into a separate component area, and we’ll just simply place them under code. And your documents will go in the documents.
Anything from your code that could be extracted out to be project specific, for example, you could duplicate CSS code to be both in the base, but also when applied specifically to a website or a project you would have styling to override the base to give a custom look and feel to a website. So you grab some of these components and put them under a Project One under the site.
Okay. Now we have the new repository structure defined. Next you have to set up SVN Externals for your particular project. So Project One under empty sites and again that repository is empty. The only thing you have to do is add SVN External properties to that particular repository. And properties are pairs of information. They have the target in your file structure that would be checked out to a local machine and also a specification of where the source would be coming from.
So in here we’re mimicking exactly this initial file structure. We say that going into the code folder under the Admin Tools File Manager, that particular information will come from now the Global Repository Admin Tools, probablyfile manager as well. And similarly your main code will come from the Global Code Repository, and your site specific code would go to code/site and come from the Global site, Project One specific repository.
You add those properties, you commit them to the repository and then the result is next time you do a checkout of this repository you have the file structure exactly like this with the addition of the new site folder. And the beauty of it is you’re going to have the same exact look and feel of development in your old structure, but the source code you modify will be now shared across multiple projects. So you have that benefit of code reusability.
That’s it. Thank you for watching.