Customized WordPress: Understanding Subversion

This week, I am tackling a topic of development. Subversion. Namely, Subversion and WordPress and how to create your own custom version of WordPress. However, before I go any further, let me put the disclaimer out there that:

  • You are allowed to do this under GPL
  • If you’re creative, you can probably accomplish just about anything via WP hooks and plugins and probably do not need to, in most cases, create your own custom WordPress.
  • Do not expect WordPress support to assist you if you’ve significantly modified the core code

That said, you may find a need to have your own custom WordPress install and if that’s the case, this series is for you. Even if not, you may find it interesting anyway. We do some of this at b5media.

Subversion Basics

Subversion is a change control module that keeps track of changes made to a software package. WordPress uses this as a repository for ongoing development and so we use it as a cornerstone of our development.

As I run Mac OS X, I have the benefit of Unix on my laptop and I use the information found in the free SVN ebook. The approach taken in this series is from that perspective. Windows users can dive into TortoiseSVN and find the parallels.

Create a Working Copy

When you’re writing code or patches, you’ll never make the change directly to the repository. In the case of WordPress, unless you’re one of only a handful of individuals, you aren’t allowed to make changes to the core repository. You need to make modifications in a Working Copy then, depending on your permissions for a repository, either check those changes back in (aka, commit) or create a patch (aka a diff) for someone who can check the changes in.

To check out a working copy of WordPress into a working copy, for instance, you would create a folder and grab the latest code base:

macbrain:~/svn aaron$ mkdir wpwc
macbrain:~/svn aaron$ cd wpwc
macbrain:~/svn/wpwc aaron$ svn co .
A    wp-pass.php
A    wp-rss.php
A    wp-login.php
A    wp-comments-post.php
A    wp-blog-header.php
A    wp-rdf.php

Making Changes in SVN

Now, you can edit any of these files in your working copy and can produce a patch, or check in your changes (depending on your permissions).

To create a unified diff (the format used in most SVN repositories), make sure you’re in the top level of the working copy and use the



macbrain:~/svn/wpwc aaron$ svn diff > patch.diff

This will compare the working copy to the repository to determine what the differences are and export those changes to a file called patch.diff. If you open up patch.diff in your favorite text editor, you’ll find that the formatting is ugly and, though human readable, may not make a lot of sense. Don’t worry as these patches don’t have to be applied manually.

The other option for getting changes back into the repository is to check in or commit the changes. The format is as follows:

macbrain:~/svn/wpwc aaron$ svn ci -m "My code changes and bug fixes"

So that’s a low level introduction for interacting with a repository. Tomorrow, we’ll continue looking at SVN and setting up your own repository, then SVN Externals, which allow us to bring in external repositories into your own repository and round it all up with how to customize your build with patches. Stay tuned.