Recently, I become involved in Zend Framework even more – this time not only developing using it (which I am doing for some 3 years now), but actually contributing back whenever I can. And I plan to dedicate even more hrs/week to work on this undoubtedly nice, yet complex piece of software.
So, lyrics aside – today I had to learn new Subversion trick (the hard way), so I am writing it down here, in hope that it saves some other hacker time to play PacMan.
Problem:
I needed to checkout into single working copy all relevant (to me) parts of ZF repository. Not doing separate checkouts for the trunk, then branches, then incubator, but having single checkout of repo which I can keep up to date by simple
svn up
directly from the root of working copy.
Now the problematic part: you never ever want to checkout whole ZF repository – need I mention that it is HUGE? So, what I actually wanted is to checkout the whole repo excluding some paths – such as lots of previous releases in tags/branches folders.
Solution:
That’s where Sparse Directories chapter from svn book comes handy.
I will not repeat what’s written there, as I doubt I can explain it better. Yet I would add couple of notes, that might be a time savers I was talking about:
First, as of Subversion 1.6 you can actually exclude directories explicitly (go on and actually read that chapter, to find out that 1.5 supports what they call implicit exclusion).
And second, if you are tempted to run
$ svn co http://framework.zend.com/svn/framework/standard zf-standard --depth immediates
it is probably a bad idea.
In theory it should work like a charm, in practice on my Ubuntu box it takes for ever to bring those 4 immediate directories located in “standard” repo. I checked those directories with svn info and they have Depth attribute set (quite correctly) to “empty” – yet it takes a lot of network traffic and time to checkout them (once that’s done – svn up takes no time at all though). It takes so much time, as to make all this sparse directory magic not worth using.
Fortunately, there’s a work around: proceed one directory at a time, using “empty” as depth:
$ svn co http://framework.zend.com/svn/framework/standard zf-standard --depth empty $ cd zf-standard $ svn co http://framework.zend.com/svn/framework/standard/branches --depth empty $ svn co http://framework.zend.com/svn/framework/standard/tags --depth empty $ svn co http://framework.zend.com/svn/framework/standard/trunk --depth infinity
As you see, I made sure that trunk directory is fetched recursively. That’s because I work on trunk and need it in full.
Now let’s fetch some branch that we are interested in, while ignoring (and as such implicitly excluding) those that are too outdated to waste time and traffic on them.
Descend to zf-standard/branches directory of your newly created working copy and issue following command:
$ svn up release-1.10
As you don’t provide any depth specifiers “infinity” is assumed, and whole branch is fetched. Once that done, you can use your regular svn up/ci workflow – directory depth parameter is sticky, so you don’t have to worry about any directory that you didn’t fetch. Everything works as in normal checkouts, you just don’t have some of files (and in our case number of files tends to be 6-7 digit number) from your central repo.
Although I tend to git more and more lately, subversion can still amaze me (after all these years!)




no comment untill now