[UPDATE] This post is useless when you upgrade Xcode to version 5.0. If you use version 4 or you’re using a linux environment with svn 1.6 and 1.7 simultaneously; read on :) [/UPDATE]
So you have these projects in your development tree, these are probably managed by the version of Subversion as used on your mac – which with a very high probability would be version 1.6. But now and again, you might find yourself with a Subversion 1.7 project you received from someone else. Your mac will then shout something like this;
svn: The path '.' appears to be part of a Subversion 1.7 or greater
working copy. Please upgrade your Subversion client to use this
working copy.
If – like me – you are NOT prepared to switch to SubVersioN 1.7 entirely, then read on :)
First, make sure you have a way to install Subversion 1.7 as an extra – not as the default. I used HomeBrew for this, as I do with everything I have written on this blog. And HomeBrew was kind enough to install version 1.7 in /usr/local/bin/svn . Now, you might have to play with the PATH settings in your bash_profile (~/.bashrc or ~/.bash_profile) so that this version 1.7 SVN is NOT used by default.
Then add this to your bash_profile;
alias svn17='/usr/local/bin/svn'
now you can use
svn17
svn
That’s handy, right? right! but is it automatic? no… Transparent? no… we still have to remember which command to use and you probably won’t and get frustrated by the error mentioned earlier. All we did here is prevent having to type /usr/local/bin/svn every time we need version 1.7.
So we also add this;
alias svn16='/usr/bin/svn'
now you can use
svn16
svn
Wait…, wut?!… what good will that do?!… Good question. It allows us to force the use of Subversion 1.6. The why part comes in just about … now!
Add this;
svn () {
svn16 "$@" 2> /tmp/$$.svn.out
[ cat /tmp/$$.svn.out | grep "Subversion 1.7" | wc -l | awk ' { print $1 } '
-gt 0 ] \
&& svn17 "$@"
rm /tmp/$$.svn.out
}
now you can use the
svn
Neat, huh?!
enjoy!
p.s. remember; if you make changes to your bash_profile, you have to reload it;
. ~/.bash_profile
Yes, that’s a . in front. You could also type
source ~/.bash_profile
“.” is just faster than “source” is :)