Friday, February 19, 2010

Mystery Solved: SVN's Sparse Directories

A while back I mentioned a hack to pull down subdirectories on subversion that were stubbornly refusing to be pulled in. The hack works, but I couldn't explain why it was necessary.

Today, annoyed by yet another set of directories that wouldn't update, I did more Google and found the answer.

Turns out, subversion has a concept of sparse directories. These are directories that don't automatically recursively update.

Apparently, I'm a big fan of sparse directories. They allow me to keep a large repository of client code, yet not have to have it all checked out at one time.

Given my new found knowledge of sparse directories, here are a few key things to know:

  • When you checkout code in a non-recursive fashion, it sets the depth to be immediates - which means the directory won't recursively update.
  • The setting you get when you do a checkout is sticky. This is what was throwing me off - no matter how many times you svn update, the depth will still be immediates.
  • Running svn update --depth infinity does not reset the depth on the directory. In fact, it won't do anything.
  • Running svn update --set-depth infinity will reset the depth attribute, and will recursively grab all files. This is what I was looking for all along.
  • You can check the current depth of the directory by running:
    svn info . | grep ^Depth

Who even know there was a svn info command?

Subversion, you're just totally unappreciated. I wonder what other tricks you have up your sleeve?

No comments:

Post a Comment