Reputation: 13315
I would like to use Subversion and checkout only source files (for example: checking out only .c
, .cpp
and .h
files). Is this possible ? If so, how can I do that?
I am trying to get the webkit source code from:
http://svn.webkit.org/repository/webkit/releases/WebKitGTK/
I don't really want to change the code and check it in again or build it. I just want the source files because downloading the entire release is about 3GB per version.
PARTIAL SOLUTION:For now I am going to download the directories i want. But i could traverse through the directories recursively, and then download the files that follow the pattern i want.
This is a pseudo python code I will call
GetAllSourceFiles('http://svn.webkit.org/repository/webkit/releases/WebKitGTK/')
def GetAllSourceFiles(directoryName):
list = svn ls directoryName
for name in list:
if name is a file of type c,cpp or h:
do svn export directoryName + name
else if name is directory:
do GetAllSourceFiles(name)
Upvotes: 4
Views: 2842
Reputation: 620
If you know structure of repository, you can checkout specific folders. I never tried it with files. But you need checkout each folder separately. You need to write it like this for typical svn repository
for trunk
svn co repository_url/trunk/path_to_folder checkout_destination/
for branch
svn co repository_url/branches/name_of_branch/path_to_folder checkout_destination/
for release
svn co repository_url/releases/name_of_releases/path_to_folder checkout_destination/
edit
You can try to write a script working in loop
Using
svn ls repository_url/releases/name_of_releases/path_to_folder
check if folder contains source files.
if folder contains source files, then download it using
svn co repository_url/releases/name_of_releases/path_to_folder --non-recursive
Check next folder
Upvotes: 3
Reputation: 9148
Just a minor correction, I know this is a detail but might as well be on the same wave-length. When you say downloading is 3 GB per version, that is not quite the correct way to see it. First checkout would be a big download. Subsequent updates of code-base to head or even going back versions would just be approximately the size of the diff between the 2 revisions.
Now, let's assume you may be low on drivespace or want to save a bit of bandwith. I was thinking on your question and the only thing I can come up with is using Externals definitions to do a checkout of an external repository in a repository of your own. This is the only way I can think of where you can cherry pick the files you want without 3rd party help. But this is a lot of manual work, not so great.
The other solution is to get these programmatically, a bit more work but allows for a bit more flexibility for any project if done right. I see you from your profile you seem to like Java, there are client libraries out there that would allow you to fetch an svn ls, you parse the result to only either fetch these .c and .ccp files. But that would be very slow, as it would check out files individually. Though, once you can do this, you might as well generate your External definitions in a file, and thus have the best of both worlds. You have the speed of svn, flexibility of being able to cherry-pick and best of all automation.
Svn can be very flexible, but for some of the specialised needs, you have to slap the tool together yourself, and thankfully there are pretty decent client libraries available in most any language.
Good-luck :)
UPDATE:
According to this post:
If you're lucky enough to use subversion 1.6, you can have external links for both directories AND files
Upvotes: 1