Coloured svn diff

The output of svn diff can sometimes be hard to read, especially when there are a lot of changes to read through.

I also realise that you might think I’m a dinosaur for still using svn because git has nicely coloured diffs out of the box but talk to any WordPress plugin developer and they’ll have to use svn at some stage. On the other hand, if you’ve used svn for years you may not even realise you need coloured diffs.

I found a neat solution to that. Pipe the output of svn into colordiff.

This Bash function, svndiff, should be placed in the .bashrc in your home directory (or .zshrc or whatever shell you use, it’ll probably be similar)

function svndiff () {
    svn diff $@ | colordiff | less -R;

Log out and log back in or do source ~/.bashrc from the command line to get it working.


svn: “local file delete, incoming file edit upon update”

Google knows all, most of the time. However, I know I’m in trouble when I the first link returned by a search for an error message in a widely used piece of software is a commit entry adding test scripts for that and related errors to the software.

So, just in case you run into this problem where Subversion thinks you have deleted a file locally and someone has updated the same file on the Subversion server you should use the following to fix it:

$ svn resolve
$ svn revert

Tell “svn resolve” to keep local changes (mc) which means the file will be deleted, and then “svn revert” will revert that delete. You’ll finally be back to a pristine work area.