views:

429

answers:

3

Hi All,

We have two websites for the same client (main www site and another for the ecommerce site which sits on a seperate server) that use shared portion of code (various features/styles/javascript etc.). We currently manage this by having the shared code as seperate projects (in the same repos) in SVN and using svn:externals to pull the branch of each of these into the two website projects.

We have just created two release branches, one each for the two sites. Everything gets commited to trunk for each of the sites as normal when working and when "ready for live" we merge it into the release branch for that site. Works a treat except today we modified the some of the shared code and noticed that the release branch pulled it in straight away when we did an update on the release branch. This is not what we wanted :(

So any ideas how we can iron out this problem. We used externals to DRY up the sharing of the code but is there another way? Notice that in this question (http://stackoverflow.com/questions/245337/how-can-i-branch-in-svn-and-have-it-branch-my-svnexternal-folders-as-well) they mention externals are bad and we should be using a different build process but no mention of what that should be.

We have CruiseControl.net running our builds and are keen to get this nut cracked. Has anyone any ideas on a better process?

Cheers

Pete

A: 

You can do svn update --ignore-externals if you don’t want the externals to be updated.

Michael Hackner
I'm thinking externals might not be the way to go at all. My trouble is getting changed from the externals into the release branch when I want them to be, currently they are added regardless when we do an update. The only solution with the current setup is to have release branches for each of the externals and that quickly becomes a knightmare to manage, too much going on. Hence me thinking externals are a deadend in this case.
Pete Duncanson
one thing that made externals work for us:http://svnxf.codeplex.com/
dnndeveloper
+5  A: 

If I understand correctly you have something like the following structure:

  • project1
    • trunk
      • library (via svn:externals library svn://repo/library)
    • branches
      • release1
        • library (via svn:externals library svn://repo/library)
      • release2
        • library (via svn:externals library svn://repo/library)
  • project2
    • trunk
      • library (via svn:externals library svn://repo/library)
    • branches
      • release1
        • library (via svn:externals library svn://repo/library)
  • library

I'm assuming you are settings svn:externals on /project1/trunk to /library. If you then merge the revision with the svn:externals to /project1/branches/release1 and update that branch, you will automatically get the latest version from the library. By default svn:externals will get the HEAD revision of the link.

You could define the svn:externals to link to a specific revision, like this: svn:externals -r123 library svn://repo/library. This means that the externals link will always point to that specific revision. So you can safely use this type of svn:externals link in your release branch without worrying that the shared library code will ever be updated unless you manually change the svn:externals

Probably a better way would be to use tags for the shared library and link to a specific tag. In this case you would get the following repository structure:

  • project1
    • trunk
      • library (via svn:externals library svn://repo/library/tags/version3)
    • branches
      • release1
        • library (via svn:externals library svn://repo/library/tags/version1)
      • release2
        • library (via svn:externals library svn://repo/library/tags/version2)
  • project2
    • trunk
      • library (via svn:externals library svn://repo/library/tags/version2)
    • branches
      • release1
        • library (via svn:externals library svn://repo/library/tags/version1)
  • library
    • tags
      • version1
      • version2
      • version3
Otherside
Ahhh now thats more like it. Great write up btw. Thanks. I suppose it would be safe to leave trunk referencing the HEAD of the externals but have my releases point to a tagged version. Would that be safe I wonder? I've been going around and around with this problem of late and been getting my self in a mess. Thanks for the clarity.
Pete Duncanson
+1  A: 

Yes, using externals pointed to a specific revision or tag is the way to go. You could easily found this out just by reading the svn manual on externals... RFD! also, is just about one page long ... :)

http://svnbook.red-bean.com/en/1.0/ch07s03.html

Alienation
I've been reading up so much of late, all while under preasure to get projects out the door, update our build server to handy release branches, while taking on new staff (taking us to a total of 3!), inbetween breaking two sites because we've not had sufficent prcoesses in place. Its easy to get burnt out with all the info. I posted here not out of lazyness but frustration, exhaustion and confusion. So far its been worth the bounty hit. Thanks for your answer ;)
Pete Duncanson