Rants, rambles, news and notes from another geek

Another Cool PowerShell + Subversion Hack

As I said before, I’ve been writing an Addon for World of Warcraft using the Ace2 libraries which are hosted on a subversion server.

I was trying to track down a bug that I couldn’t reproduce so I decided to completely refresh my entire Ace addon set from the svn server.

So I needed to run through every directory in my Addons folder and if it was a subversion working copy then I wanted to delete it and re-checkout that folder from the subversion server.

Again, this only took a single line of PowerShell script:

[75] ┬╗ ls | ? { svn st $_ 2> out-null; return ($lastexitcode -eq 0) } | % { 
$xml = [xml] (svn info --xml $_ 2> out-null); $url = $xml.info.entry.url; 
del -recu -force $_; svn checkout $url $_ }

I love PowerShell. It rocks!