Manage your sites with svn externals
Submitted by clemens on Wed, 2009/11/04 - 12:45pm
After having worked with subversion for a while I finally got time to restructure my repository layouts. What I want is a simple way to update all the sites I maintain and I want those sites under version control.
Steps I took
- Make a drupal core repository
- Create your project repository
- Reference to the drupal core
Directory layoutIn order to get a nice update-able project directory tree we choose a layout listed below.
- This contains only drupal core code will live.
- We do not want our sites getting ruined by a core update so we move it out of the way
- Our data files are out of both sites/ and www/
Getting drupal core
- We assume we have a fresh repository named drupal-6-core.
- We will checkout from this fresh repository.
- Next we add a trunk directory.
- Download drupal and rename it into www.
- Next moved the sites directory and replaced it by a symlink to the ../sites/ directory.
- Next we filled our pristine new drupal-core repository.
svn checkout http://example.com/svn/drupal-6-core
tar xzf drupal-6.14.tar.gz
mv drupal-6.14 www
mv sites ../sites
ln -s ../sites/
svn add *
svn commit -m "Initital drupal-6-14 checkin."
Your projectWe now create our project from scratch and then drop it to reuse the trunk.
Filling up your projectWe assume we have a fresh repository named project. Now the magic step is adding the drupal-6-core repository as an external one into ours.
svn checkout http://example.com/svn/project
svn add trunk
Some magicNow we link our project to the drupal core repository.
Add this line with your editor
svn propedit svn:externals .
Next we commit our changes.
svn commit -m "Added external drupal-6-core repository."
Start workingYou may now delete your project directory and checkout the trunk instead. You will note that you get the drupal-6-core sources too.
As we have our initial install we need a sites/ directory. So we export this from drupal-6-core.
svn checkout http://example.com/svn/project/trunk project
Depending on your needs you could remove sites/all
svn export http://example.com/drupal-6-core/trunk/sites
svn add sites/
svn commit -m "Initial sites directory."
You may now add modules to your site.
# rm -r sites/all
- The svn user for the drupal-6-core could and maybe even should be a different user. This way updates on your project cannot be committed back into drupal-6-core.