svn switch
written by Ian McCracken
at Sunday, April 13, 2008
I didn't learn about
And your working copy will update to the HEAD of the branch you specify (or, if you like, you can specify a revision with the usual
Example: Zenoss's build system does an
This worked great, until I noticed the other day that builds would occur against the trunk even if we were trying to build a release against a tag. The reason for this, of course, was that the working directory already existed, from our nightly rpm builds, so specifying a tag didn't matter. The build script would just
I made a quick change.
svn switch
until recently. Turns out it's pretty handy! Basically, it's a subset of svn up
that switches your working copy to a different URL. So if you're in the trunk, and you want to work in a branch but don't want to check out all the code fresh, you can just:svn switch http://repo/branch/url .
And your working copy will update to the HEAD of the branch you specify (or, if you like, you can specify a revision with the usual
-r
option.Example: Zenoss's build system does an
svn checkout
of the source trunk/branch/tag as an initial step. In order to save time (rpm builds took an hour), we trimmed down tasks that could be avoided; among other things, instead of checking out the code fresh each time, we would just svn update
if the working copy already existed.This worked great, until I noticed the other day that builds would occur against the trunk even if we were trying to build a release against a tag. The reason for this, of course, was that the working directory already existed, from our nightly rpm builds, so specifying a tag didn't matter. The build script would just
svn up
the trunk.I made a quick change.
svn up /my/working/copy
became svn switch http://dev.zenoss.org/svn/path/to/branch /my/working/copy
. If the working copy has the same URL as the one specified, it's a synonym of svn up
; otherwise, we switch to the tag. Now we get the time-saving benefits of reusing already-checked-out code, while still building off of our branch of choice.