Manage your sites with svn externals

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

  1. Make a drupal core repository
  2. Create your project repository
  3. Reference to the drupal core

Directory layout

In 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/
You could opt not to use the data directory and even leave out the sites directory but my guess is you get into more troubles. When using windows checkout the junction tool for creating symlinks.

Getting drupal core

  1. We assume we have a fresh repository named drupal-6-core.
  2. We will checkout from this fresh repository.
  3. Next we add a trunk directory.
  4. Download drupal and rename it into www.
  5. Next moved the sites directory and replaced it by a symlink to the ../sites/ directory.
  6. Next we filled our pristine new drupal-core repository.
svn checkout
cd drupal-6-core
mkdir trunk
cd trunk
tar xzf drupal-6.14.tar.gz
mv drupal-6.14 www
rm drupal-6.14.tar.gz
cd www
mv sites ../sites
ln -s ../sites/
cd ../..
svn add *
svn commit -m "Initital drupal-6-14 checkin."

Your project

We now create our project from scratch and then drop it to reuse the trunk.

Filling up your project

We 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
cd project
mkdir trunk
svn add trunk
cd trunk

Some magic

Now we link our project to the drupal core repository.
svn propedit svn:externals .
Add this line with your editor
Next we commit our changes.
svn commit -m "Added external drupal-6-core repository."

Start working

You may now delete your project directory and checkout the trunk instead. You will note that you get the drupal-6-core sources too.
svn checkout project
cd project
As we have our initial install we need a sites/ directory. So we export this from drupal-6-core.
cd project
svn export
svn add sites/
svn commit -m "Initial sites directory."
Depending on your needs you could remove sites/all
# rm -r sites/all
You may now add modules to your site.

Some notes

  1. 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.