tags:

views:

1368

answers:

8

This isn't, I don't think, a standard svn ignore question.

I have a repository with a huge directory in it that I don't want. Because others using the repository do, I can't just delete it from the tree. BUT, I don't want to redownload this directory every time I do a svn up. I can understand that ignore will prevent directories that I have from being uploaded to svn, but how I can I tell svn that I don't want it to redownload particular directories that are already in the repository.

What I do...

svn up
rm badDirectory

and then future svn up's redownload it. I want to prevent that.

Thanks!

edit: OK. I was hoping that SVN had a built in option that I just hadn't noticed yet. I was hoping to avoid having to "hack" around subversion's inadequacies, but the options below seem like acceptable alternatives.

edit again to address a couple of comments:

Is there particular reason why you cannot check-out that folder and keep it ? no disk space (probably not since you can check-out it) ? security reason ?

I could check out the folder. The entire svn repository is about 291 megs.. 290 of it is in this "bad" directory. Basically, some other people who have control over the repository (and therefore get to decide what goes in there) put a directory in there that really didn't need to be in there. I didn't mean for this to be a question about policy and the "proper & right" ways to use svn. I was just wondering if there was a technical solution.

Can you give a better description of the tree structure of the repository? Are there files at the same level as the bad directory, or only other directories? –

Basic structure:

repository root
 - good dir 1
    - plenty of subdirs in all of these directories
 - good dir 2
 - good dir X
 - bad dir 1
 - bad dir 2
 - bad dir X 
 - good file 1
 - good file 2
 - good file X
+3  A: 

You could use a script to svn update --non-recursive the current directory, then individually update the remaining subdirectories recurvively. With a bash script you could loop over all the subdirectories and just skip over the offending one.

Something like this:

#!/bin/bash

BADDIR="bad"
FILELIST="*"

svn update --non-recursive

for file in $FILELIST
do
if [ -d $file ]
then
   if [ $file != $BADDIR ] 
   then
     svn update $file
   fi
fi
done
Stephen Pape
+1  A: 

If you rename the .svn directory in the bad folder and then run an update, svn will skip over the directory and say it was deleted even though it's still there.

You will need to put it back though when you want to commit, at least at an upper level which contains the bad directory.

Andrew Burgess
A: 

You could specify --non-recursive or -N to suppress it from getting all the subdirs

and the explicitly do an update on the ones that you want.

A small batch file would make it easily repeatble

\0

A: 

If it's not a necessary folder for day to day work for you (or your group) you could ask the administrator to update the svn hierarchy to move that folder at the same level (or higher) than the folders you have to update.

for example

projet - non-essential folder 
       \ essential folder

and you will only have to update (check-out) the "essential folder" and the others will also have to update (check-out) the "non-essential folder".

Max
+4  A: 

You can do a sparse checkout:

svn co url/to/repo mywc --depth=files

that will get you a wc with only the files in it, no subfolders. You can now get all the folders you want with

svn up url/to/repo/subfolder1 --set-depth infinity 
svn up url/to/repo/subfolder2 --set-depth infinity 
svn up url/to/repo/subfolder3 --set-depth infinity 
...
Stefan
A: 

Solutions already provided, I'd say that the need to ignore one part of the repository on a regular basis is a clear sign of bad repository structure. Try to find a way to move it to a different location inside repository or something like that.

Mart Oruaas
A: 

So I just came up with what I think is about the fastest answer to the question. Since SVN doesn't have a way to autoignore directories that I don't want updated...

Here's my existing dir structure:

root -> goodDir 1 -> goodDir 2 etc

I've deleted the bad directories from my checkout. I can't do an 'svn up' from the root directory, because it tries to recheck out the bad directories.

But, the following command works nicely:

  ls | xargs svn up

Short, sweet, simple, and easy to remember.

Kirby
That won't pull new files into the current directory will it? If someone adds a new file/folder to the top level directory, you'll miss out.
Stephen Pape
Also, I think "svn up *" has the same effect.
Stephen Pape
A: 

Kirby's solution is clean except that it doesn't update the current directory.

If you have a structure like this:

root -
     |-subdir1
     |-subdir2
     |-fileA
     |-fileB

Kirby's solution won't update fileA, fileB and any other files that are later added to the root dir.

You'll want to add a "svn up -N". You could do this with an alias and a semicolon:

alias myup='ls | args svn up; svn up -N'

(That's bash alias syntax. If you're using a different shell, alter as needed)