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
- Make a drupal core repository
- Create your project repository
- Reference to the drupal core
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
- 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."
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 http://example.com/svn/project
svn add trunk
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."
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 http://example.com/svn/project/trunk project
As we have our initial install we need a sites/ directory. So we export this from drupal-6-core.
svn export http://example.com/drupal-6-core/trunk/sites
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.
- 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.