Smokes your problems, coughs fresh air.

Tracking WordPress in a Subversion vendor branch

Two months prior to writing a script to upgrade MediaWiki installations using Subversion vendor branches, I wrote something similar for WordPress. It’s a little bit more limited and should really incorporate some of the improvements made for the MediaWiki version, but it worked fine so far:

tmp_dir=`mktemp -d` $tmp_dir
 version $*;
    "Downloading and extracting WordPress version $version..."
    [ -z `svn ls $svn_repo_url|grep $version` ];
        branch= $version |sed -e 's/\.[0-9]\+$//'`
        wget "$md5_file"
        wget "$archive_file"
        [ `md5sum $archive_file |cut -f 1 -d ' '` != `cat $md5_file` ];
            "MD5 sum did not match!" >&2
        tar --extract --ungzip --transform "s/^wordpress/$version/" --file $archive_file $svn_repo_url -t $version current $version
svn merge "$svn_repo_url$last_version" "$svn_repo_url$new_version" .

I’m actually planning to make both scripts a little bit more generic (in the sense that svn_repo_url becomes an external param) and to track future changes to them using GitHub’s Gist. (How ironic is that, tracking an script for Subversion using Git?)


  1. maz

    I use Capistrano and Piston to track WordPress upgrades. Some of the articles on your site were useful in figuring out how to keep the custom files separate.

    First I imported the latest version using Piston:

    piston import --repository-type svn wordpress-current 

    Then I added this deployment recipe to deploy.rb:

    namespace :wordpress do
      desc 'Updates to latest tagged version from Wordpress repository.'
      task :update do
        base_repos, current = `svn pg piston:root wordpress-current`.split(%r{/(?=[^/]+/?$)}).map {|v| v.strip}
        latest = `svn ls #{base_repos}`.split(%r{/\s*}).sort_by {|v| v.split(/(\d+)/).map { |v| v =~ /\d/ ? v.to_i : v }}.last
        logger.trace("Current WordPress version: #{current}")
        logger.trace("Latest WordPress version:  #{latest}")
        if current == latest
          logger.trace("No update necessary")
          # Update with piston
          if RUBY_PLATFORM =~ /mswin32/
            result = %x(call piston switch #{base_repos}/#{latest} wordpress-current)
            result = %x(piston switch #{base_repos}/#{latest} wordpress-current)
          #TODO: what do I do here? Must check when a new version is available :)

    You can then update to the latest WP version with:

    cap wordpress:update

    Note that if you are comfortable using the WordPress trunk (which I would not recommend for a production environment), then you can set Piston to use the trunk directly and then just use

    piston update
    — no need then for a Capistrano recipe.

    This may need some tweaking depeding on your installation. Also, the latest version of Piston does not support the “switch” command. This is an omission, so you would have to go back to an earlier version until it is reinstated. And the extraction patterns might need some tweaking as Piston evolves, but you get the idea.

  2. halfgaar

    You’ve been publishing so much about version control of webapps; perhaps it’s an idea to comment on the relevancy of some of your own posts, because I don’t know what is true anymore…

  3. Rowan Rodrik

    So true. I should also turn on comment threading somehow. That’s supported in newer WordPress versions, but not in my theme yet.

  4. halfgaar

    Comment threading? No!!!!! Go to and see why that doesn’t work.

    Are you being ironic here or have you forgotten the no-threading revolution?

  5. Rowan Rodrik

    I was just googling around on this subject a bit and noticed that it might be a serviceable idea to clean this script up a bit and make a proper release of it (instead of turning it into a Gist, for example). If anyone is interested, let me know. Your plea might just provide the missing motivation.

  6. Rowan Rodrik


    For WordPress it goes that there’s more than one way not to make a mess of it. There’s this way, and there’s that way.

© 2024 BigSmoke

Theme by Anders NorenUp ↑