gcc does this with contrib/gcc_update which updates the file every
update:
revision=`svn info | awk '/Revision:/ { print $2 }'`
branch=`svn info | sed -ne "/URL:/ {
s,.*/trunk,trunk,
s,.*/branches/,,
s,.*/tags/,,
p
}"`
where you now have revision and branch information.
-eric