sixohthree.com

Subversion: Missing Features

I love many things about git, but I use Subversion at my day job. Two git features please me enough that I took the time to build them into my svn workflow: paged diffs and “commit -v.”

Paged Diffing

Many times I require my svn diff output to be paged through less. Rather than append | less continually, I created the following wrapper script as ~/bin/svn:

#!/bin/bash
[ "$1" = "less" ] && shift && exec /usr/bin/svn diff "$@" | less
exec /usr/bin/svn "$@"

With this script, I have a new svn less operation that pages diff output.

Note that ~/bin/svn must be before /usr/bin in your $PATH, or the real svn binary will take precedence over the wrapper.

Verbose Commits

I would wager that many git users type git commit -av more than once a day to commit all changed files and display the current diff in their editor. Very handy if you need a reference when creating your commit log message. Subversion will tell you what files have changed, but does not display the diff. I use the following vim mapping, adapted from the Vim wiki:

map <leader>d :vnew<CR>:read !svn diff<CR>:set syntax=diff buftype=nofile<CR>ggdd

This command opens a new window vertically, then fills that window with the diff of the current directory. Unfortunately this is of only limited usefulness: since vim does not know what files you are committing, it displays a diff of all changes in the current directory. Also, svn commit with no arguments seems to move the current directory up one level, which can give an inaccurate diff. I use svn commit * when I need to work around this feature. The wiki page has some variations that appear to work around these problems.

Posted 2010-01-25 at 12:31
Categories Personal
Tags , ,
Comments 0 comments