4

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)
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
yossi
  • 12,945
  • 28
  • 84
  • 110
  • 1
    What kind of files do you want to exclude ?? And is it your repo or you are checking out from a public repo?? Also, If it is your repo, then you want to exclude them for all checkouts?? – Balanivash Jun 16 '11 at 10:55

2 Answers2

3

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

firescreamer
  • 620
  • 8
  • 20
  • 1
    problem is that the sources are scattered all over the place :) – yossi Jun 16 '11 at 11:21
  • 1
    I proposed a script for you in my answer. :) And you can't checkout specific file. – firescreamer Jun 16 '11 at 12:01
  • the script for working in loop sound like it might work , i think i will try that – yossi Jun 16 '11 at 12:41
  • i will simply getting directry list using svn ls and then only download the things i need. have not written the script yet but i will add pusedo code. – yossi Jun 16 '11 at 13:18
1

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

Community
  • 1
  • 1
Stephane Gosselin
  • 9,030
  • 5
  • 42
  • 65
  • thank you for you reply. the problem is the initial size of all the versions.it would have been the best to use svn client and not write my own code , but if i would do it , it will be in python and not in java. any way thanks for your answer. – yossi Jun 16 '11 at 12:28
  • 1
    Also check [this very relevant and related SO post with other good tips](http://stackoverflow.com/questions/192810/svn-checkout-filtered-by-file-extension). One option that is suggested that I would consider of interest is a java ant task. – Stephane Gosselin Jun 16 '11 at 12:31
  • 1
    What do you mean the size of all versions? You do not need to download all versions, you can always easily diff between versions even straight from the repository without even checking out. And if you rather have the whole codebase, doing svn update -r only downloads the diff, you never have all versions at the same time on your end. – Stephane Gosselin Jun 16 '11 at 12:34
  • i need all version because i want to find the diff between versions (its for research), the svn update -r sound good , how do i use it exactly ? – yossi Jun 16 '11 at 12:44
  • i am not lucky :), svn version could be older than 1.5 – yossi Jun 16 '11 at 13:02