Phillip Pearson - Second p0st

tech notes and web hackery from the guy that brought you bzero, python community server, the blogging ecosystem, the new zealand coffee review and the internet topic exchange

2009-2-6

[Minimal] pure PHP Subversion client

Something interesting I did back in 2006 was write a pure PHP parser for the Subversion REPORT XML format, which is what a Subversion server sends in response to a checkout or update request. The code could check out a fresh copy of a repository, and also handle the XML well enough to update from revision to revision. I did this to implement the auto-update process for PeopleAggregator, for Broadband Mechanics.

It's worked pretty well, and I'm pretty proud of the code... not its beauty, because it's fairly inscrutable, but in that it worked at all, and that it was as reliable as it was. I think it took a few days to write, and after a couple of minor bugs found over the next week or two, we didn't find anything wrong with it until much later, when we shipped an update which deleted a file, which was a case I hadn't considered when writing it. After fixing that it worked just fine from then on.

Anyway, Marc gave me permission to release this as open source under the MIT license (like CC-BY: fairly unrestricted use, with attribution) a year or two back, and people have asked me about it from time to time, but I've never actually put up an official copy with the MIT license on it. So, here you go:

pure-php-subversion on GitHub.

I never spent the time to properly extricate it from PeopleAggregator, so you'll need to hack PAStateStore.php into something that fits your own database, and figure out the schema. If someone wants to write a pure-PHP handler for .svn directories, or even a generic state store which stores hashes like PAStateStore (but maybe in a flat file rather than a database), that would be brilliant. Fork and enjoy!

... more like this: []