Sparse Directories in Subversion 1.5
The last few weeks we blogged a lot about the Merge Tracking feature in Subversion 1.5. Of course there are several other great new features coming. Let’s look at what else is new.
The Subversion 1.5 release notes (which are not final of course) mention these new features for 1.5:
- Merge Tracking
- Sparse checkouts
- WebDAV transparent write-through proxy
- Cyrus SASL support for ra_svn and svnserve
- Copy/move improvements: peg revisions, 'svn mv file1 file2; svn mv file2 file3', 'svn cp *.c dir'
- Cancellation improvements
- Changelist support
- FSFS sharding
- Command-line client improvements
- JavaHL bindings improvements
- Many improved APIs
If you are new to this blog and want to find out more about Merge Tracking, check out our Merge Tracking Early Adopter Program. Over the next few weeks we’ll blog about some of the other new Subversion features. Not about everything though, other people are blogging about 1.5 as well and we’ll link to them. For example: Malcolm Rowe blogged about mod_dav_svn improvements, tree-structured FSFS repositories and backing up FSFS repositories, Subversion 1.5 style.
In this post we’ll talk about sparse directories.
Sparse Directories
When you first checkout a Subversion repository, or a directory within that repository, you get the whole directory with everything underneath it. In large projects that can be a problem because the files are copied over the network and that can take some time. This is very contrary to how Subversion subsequently sends small deltas over the network with minimal use of network resources. Also, do you want all these files cluttering your disk?
Subversion 1.5 introduces Sparse Directories, giving you more control over what to checkout and how svn update works. You can read the specs here. But I don't learn from reading, I need to play. So let's play (but let’s be mindful of the fact that SVN 1.5 is not feature complete yet).
I started with downloading the Subversion 1.5 pre-release binaries from the Merge Tracking Early Adopter Program and setup a repository:
- Download the binaries (Windows in my case).
- Copy .exe and .dll files to c:\svn and add c:\svn to %PATH%.
- Create repository (svnadmin create repo) at c:\svn (repository is c:\svn\repo).
Download the repository dump file that comes with the Merge Tracking beta. - Load the dumpfile (svnadmin load c:\svn\repo < c:\svn\mergetracking.dump).
- Create directory for working copy.
- Checkout the repository (svn checkout file:///c:/svn/repo/trunk)
The main directory of the trunk of the repository contains one file and a few sub-directories:
index.html
about
jobs
news
products
support
Suppose I'm another developer (I mimicked that with working copy wc2) and I have no need for the subdirectories. With current releases of SVN, I can use the -N switch (for: non-recursive) to checkout only the main directory of the trunk and not the sub-directories:
I now have the topmost directory of trunk and the file in it, but not the sub-directories. For a big repository, this will reduce the amount of time for the checkout, and keep your working copy cleaner and subsequent updates will only pull in files added to the directory you checked out. But –N is all the control you have.
SVN 1.5 will be more flexible by making the -N switch redundant and replacing it if for a --depth option. According to the spec, the possible values for --depth are:
- --depth=empty: Updates will not pull in any files or subdirectories not already present.
- --depth=files: Updates will pull in any files not already present, but not subdirectories.
- --depth=immediates: Updates will pull in any files or subdirectories not already present; the subdirectories will have depth=empty.
- --depth=infinity: Updates will pull in any files or subdirectories not already present; the subdirectories will have depth=infinity. Equivalent to today's default update behavior.
Now I am developer number 3 with wc3 as working copy. Let’s checkout the repository with -–depth=empty:





