SVN:Externals - Setting In CFEclipse/Subclipse

Have you used svn:externals yet? From the SVN book online:

Sometimes it is useful to construct a working copy that is made out of a number of different checkouts. For example, you may want different subdirectories to come from different locations in a repository, or perhaps from different repositories altogether. You could certainly setup such a scenario by hand—using svn checkout to create the sort of nested working copy structure you are trying to achieve. But if this layout is important for everyone who uses your repository, every other user will need to perform the same checkout operations that you did.

Fortunately, Subversion provides support for externals definitions. An externals definition is a mapping of a local directory to the URL—and possibly a particular revision—of a versioned resource.

At work - I have the following setup in Subversion:

  • /trunk
    • /artifacts (my docs)
    • /build (my Ant build files)
    • /coldfusion (my CFM code)
    • /oracle (my ddl scripts, etc)
    • /testing (my selenium scripts)

While I could checkout /trunk and setup my webserver to point to the /coldfusion directory this wouldn't be exactly the same as my production environment. I need to checkout the /coldfusion directory. This leaves my build, testing and other directories left out. By using svn:externals I can grab those directories as well during checkout.

Note: Be aware there are several issues with svn:externals regarding update/commits of code included in the external directories. Please read the related documents online (and if you have Tortoise SVN installed check out the section related to svn:externals in their excellent HELP section - it is listed under the "How Do I..." section in "Include a common sub-project").

svn:externals - checkout

Now lets see how to setup svn:externals using CFEclipse. First if you haven't already - we'll checkout a copy of our project. Here I'm checking out a my /coldfusion subdirectory which contains my project code.

Here is the project in the CFEclipse Navigator view. You can see the path reflected (core/trunk/coldfusion). Now I need to add the other directories (build, testing, etc)

Navigator view

Now we can right click on the top level of our project - select Team > Set Property.

Set Property

The svn property dialog will appear. For the property name select svn:externals. Make sure "Enter a text property" is selected and enter the following (alter this path to match what you want to include):

CODE:
  1. oracle https://your.svn.repo.com/svn/telework/core/trunk/oracle

The svn:property consists of two items - one the name - here I'm using 'oracle' and the full path to the repo. We can define several of these so we'll end up with:

CODE:
  1. oracle https://your.svn.repo.com/svn/telework/core/trunk/oracle
  2. testing https://your.svn.repo.com/svn/telework/core/trunk/testing
  3. build https://your.svn.repo.com/svn/telework/core/trunk/build
  4. artifacts https://your.svn.repo.com/svn/telework/core/trunk/artifacts

Externals

External directories Click OK and you will return to the Navigator view and your svn icon will have changed to let you know things are out of sync. Commit then Update your project (Team > Commit / Update) and you should now see your external directories!

Again please note there are some things to be aware of regarding updating and commiting changes in the external directories. From the Tortoise SVN Help:

Each time you update your main working copy, you will also receive the latest version of all external projects.

If the external project is in the same repository, any changes you make there there will be included in the commit list when you commit your main project.

If the external project is in a different repository, any changes you make to the external project will be notified when you commit the main project, but you have to commit those external changes separately.

While in this example I am using CFEclipse and Subclipse you should be able to follow similar steps using any tool that works with Subversion.

2 Comments

  1. Erik
    Posted February 26, 2008 at 9:49 am | Permalink

    Nice article.

    I have a question about your repository layout. I notice that you have the following layout:

    telework/core/trunk/coldfusion
    telework/core/trunk/oracle
    etc.

    I assume this means that you also have

    telework/core/branches/branchA/coldfusion
    telework/core/branches/branchA/oracle
    etc.

    and

    telework/core/tags/tag1/coldfusion
    telework/core/tags/tag1/oracle
    etc.

    If this is correct, what made you choose this layout over for example this one:

    telework/core/coldfusion/trunk
    telework/core/coldfusion/branches/branchA
    telework/core/coldfusion/tags/tag1
    telework/core/oracle/trunk
    telework/core/oracle/branches/branchA
    telework/core/oracle/tags/tag1
    etc.

    What do you see as the pros & cons of the two approaches?

  2. Posted February 26, 2008 at 10:25 am | Permalink

    Erik - great question. Unfortunately I have no good answer. I think we looked at your second option but decided to go with what we did. So far it’s worked well - we don’t branch much so haven’t run into any issues. That doesn’t mean it’s the ‘best’ way. Just what we picked when we were getting started using SVN.

Creative Commons License

Copyright © 2007 thecrumb.com. All rights reserved.