Josh
Josh

Reputation: 1774

Using wget to "checkout" svn repository

I have a very poorly laid out svn repository that I don't have permission to re-structure. There are several subprojects spread across the repo at various depths from the repository root. I want to be able to check out all of the trunks (but not any branch or tag folders) regardless of what depth they are at. I figure this would be a good problem for wget to solve. My initial use of wget looked something like this:

wget -r -X 'tags' -I "base/of/repo" "http://www.urlrepo.com/"

A few issues I ran into while running this command:

  1. Wget still grabbed the tags folder even though I thought the -X flag should exclude them
  2. The downloaded files are placed into folder "base/of/repo", which isn't terrible, but it would be nice to not save to this path

Thoughts?

Upvotes: 4

Views: 5487

Answers (2)

David W.
David W.

Reputation: 107080

Although it might work, it relies on something that's not 100% guaranteed: That you can use a browser when you use httpd as your Subversion repository server.

You can limit the checkout by using the --depth parameter on svn co and the --set-depth parameter when doing svn update. This will allow you to checkout only those folders and directories you want without pulling everything down. This is sometimes referred to as sparse checkouts. As a bonus, this is an actual checkout. You can do commits -- something wget won't let you do:

$ # I want to just checkout the immediate files under the URL:
$ svn co --set-depth=immediates $REPO/trunk/foo
A foo/first
A foo/second
A foo/third
# I want to checkout everything in first and third, but nothing in second:
$ cd foo
$ svn up --set-depth=none second #Removes directory second
$ svn up --set-depth=infinity first third

Using this should work with your original example:

$ svn co --depth=none http://www.urlrepo.com/ workdir
$ cd workdir
$ svn up --set-depth=none base
$ cd base
$ svn up --set-depth=none of
$ cd of
$ svn up --set-depth=infinity repo

Upvotes: 1

Ofir Farchy
Ofir Farchy

Reputation: 8047

You can do it recursively with bash and svn using sparse checkout.

Something like:

svn co --depth immediates svn://repo/trunk

Then on each subfolder, if it is 'tags':

svn up --set-depth empty tags

Else:

svn up --set-depth infinity dirName

Upvotes: 4

Related Questions