Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVN checkout filtered by file extension?

I have a home-grown automated build script in the form of a DOS batch file. In part of that script, I check out (with "svn checkout") a section of our SVN repository that includes a bunch of third-party stuff that's used in our projects. This batch file performed pretty well for a long time, but now people have checked in lots of fluff (docs, sample code, etc.) into the third-party area and the checkout part of this script has gotten lots slower. I'd like to mitigate this by checking out only the stuff we need -- mostly dll files in our case. So, my question is this: what's the best way to check out an SVN repository filtered by file extension?

I didn't see any obvious way to do this in the svn help. I have a .NET utility library that wraps svn.exe in some ways, and I was thinking of extending this to retrieve only content that matched my extensions of interest. But I'd prefer to use an easier or existing method if one exists.

like image 617
Chris Farmer Avatar asked Oct 10 '08 19:10

Chris Farmer


2 Answers

This is possible: you can svn checkout an empty directory, and then svn update filename for each file that you do want.

Your script can do something like:

  1. svn checkout svn://path/to/repos/directory --depth empty
  2. svn list --recursive svn://path/to/repos/directory
  3. Pipe that result through a filter that removes the forbidden file extensions, e.g. grep
  4. Iterate over this new filtered list and svn update --parents each file

That would give your desired result of a working copy without certain files or file extensions.

Of course, there is also the issue that you mention of “people [checking] in lots of fluff” but that’s a separate matter.

like image 120
Michael Hackner Avatar answered Oct 14 '22 06:10

Michael Hackner


As I told here, there is only one option build into SVN itself: A new feature in SVN 1.5 called sparse checkout, however you can only select checkout on directory level, so you have to sort the files you do not need in a different directory.

like image 33
Peter Parker Avatar answered Oct 14 '22 05:10

Peter Parker