We primarily are a Subversion shop at Sparx. Sure all the cool kernel kids use Git but we have a slightly different use case. Plus our electrical CAD tool of choice supports Subversion natively. So we use Subversion for all aspects of collaboration, configuration management, and version control. If you looked inside our project repositories, you would see datasheets, documentation, SolidWorks models, source code, schematics, and anything else associated with a project. But this created a problem for me until I recently stumbled on the solution. If I checked out all the files for a particular project, I would end up filling my SSD with tons of huge SolidWorks models. If I separately checked out just the directories I wanted, it was a pain to keep them all in sync with separate updates and I would often break relative paths between folders. So I was faced with two bad choices… bloated directories of unneeded files or extra headache to remember to update each directory separately and to keep their relative paths intact by hand.
But there’s a simple solution. I imagine it will work for any SVN client but I’m going to demonstrate on TortoiseSVN, the excellent Windows SVN client. The idea is simple, you can simply set the checkout depth for any folder and then override that depth later.
The screenshot shows the subfolders in the top level of the project folder. I’m not interested in having the ME folders full of solid models or the hundreds of photos taking up space on my hard drive. So when I do my initial check out of that project from the svn repo with TortoiseSVN, I am going to change the checkout depth drop down menu from “Fully recursive” to “Immediate children, including folders” as shown in the second screenshot. This will give you only the immediate folders and files at the top most level. Those folders will be empty for now. And if you do an update, TortoiseSVN remembers that you want them empty and they will stay that way (until you override the ones you want in the final step).
So now I want the CS folder to actually pull in all the sub-folders and files. To do that, I need to tell TortoiseSVN that I changed my mind and that folder should now be fully recursive when I do an SVN update. To do that, I just right click on the CS folder and choose the “TortoiseSVN->Update to Revision” context menu as shown below.
That will bring up a dialog where you have the option to select a particular version from history or change the checkout depth. Now we can change the checkout depth of just the folder or folders we want.
We get to have our cake and eat it too, a single directory checkout for the whole project but we get to skip the directories we don’t care about. And the best part is you can change your mind as much or as often as you want. If you need to tweak one file, you can simply change the depth of the containing folder, update, make your change, commit, and then update your depth back to a shallow checkout. Very, very handy for me. Note that the final screenshot is obscuring a checkbox under the drop down menu that lets you decide if this change is sticky or temporary. So far I have just left it sticky and change it back when I want. But I suppose if you were sure you just wanted to do a quick change and then back to shallow checkout you could un-check that box.