views:

248

answers:

1

The context is that I have an on off-the-shelf CMS which I want to make customizations to; so I want to keep the files I modify under version control, but I don't see the need to put the whole file tree under version control.

My problem is that I need to add a file to be kept under version control which is located a few subdirectories down, but I don't want to add anything else to the repository asides from the file and its parent folders.

To illustrate, say I have the following file in my project:

project/folder1/folder2/file.txt

I want to add file.txt to the repository, and folder1 is under version control but folder2 is not. There are existing files in folder1 and folder2 which I do not want to all put under version control.

Doing an svn import folder1/folder2/file.txt doesn't seem to work, as then I need to check out the file, and even if I delete the local version first, SVN complains that its parent folder exist. I presume that this means that if I use the --force option this would just clobber the contents of these folders.

The problem with svn add folder1/folder2/file.txt is that it requires each parent folder to be in the repository already (I gather from the fact that it can't find the folder2/.svn/entries file), but only folder1 is in the repository. So I figured I could do svn add folder1/folder2 first. The problem is that this puts the entire contents of folder2 into the repository, which I don't want. It seems the solution would be to do svn add --depth=empty folder1/folder2 which just adds the folder and no contents, but the --depth option is a new feature in Subversion 1.5, whereas I'm using 1.4.2 and it would good to avoid upgrading at this point.

So I'm wondering if there is a way around the lack of a --depth option in older versions of Subversion? Or is there another way of solving this problem" I'm also wondering if perhaps the way I went about setting it up in the first place was not so helpful.

+1  A: 

You should add the folder with the option "--non-recursive":

svn add --non-recursive folder1/folder2
tangens
I saw that option but for some reason thought it would mean add each sub item, but don't descend any further. But it did exactly what I was after, thanks :)
humble coffee