Monday, January 06, 2014

learning something new for SVN... sparse checkouts

So for years now, SVN has been my goto tool for revision control. I keep saying that I'm going to try GIT, but I just haven't had the right opportunity yet, and on the project I've been working the last few years.... lets just say I now know enough clearcase to ask "what the f--- were they thinking when they created it".

Anyways so one of my big hangups on SVN has been the checkout level, you can easily extract a single file from SVN, but then you lose its connect and it is just a simple file, if you actually want to use the benefits of a revision control system, you need the directory the files resides in. But what if you don't want all the files in said folder.... well enter sparse checkouts.

So evidently with SVN 1.5 this feature was added, I guess I just missed the memo, then again in 2008, my SVN setup worked great so I really didn't pay much attention. Also back then I was only using SVN for code and well when developing libraries... you kind of want the whole build tree so it really wasn't a problem, but since 2009 I've been working with a company that also uses SVN to control Document revisions... and quite often, I really only care about a single doc or maybe a handful.

Anyways... I'm rambling, which if you actually read this blog that is pretty much how the posts go :-).

So I guess I finally typed the right query into google and came across this stack overflow post:
http://stackoverflow.com/questions/192810/svn-checkout-filtered-by-file-extension
and the first answer told me what to look for, but the second answer gives you the simple fact of how to do it.

Basically you checkout the folder the files reside in using the sparse checkout option of '--depth empty', and then you do an 'update' on the file/s you want.

  1. svn checkout svn://path/to/repos/directory --depth empty
  2. svn list --recursive svn://path/to/repos/directory
  3. Pipe that result through a filter that removes the forbidden file extensions
  4. Iterate over this new filtered list and svn update each file
If  you can filter with a simple grep statement you can easily do step 4 as "svn update `svn list.... | grep ....`"

Fun... now time to remove all those extra large folders and recheck them out with this sparse technique, thanks stack overflow community.

No comments: