13
votes

I have a junk folder, where my application puts temporary files. I don't want to commit them (surely), but the folder must exists or application will crash.

If I use standard TortoiseSVN ignore feature, it will add "svn:ignore junk_folder" property to parent folder, but it will also delete "junk_folder" which cannot happen.

If I revert only delete operation (did by TortoiseSVN) but leave adding "svn:ignore" property, this solution will fail. TortoiseSVN will report files inside "junk_folder" as non-versioned, which I want to avoid.

Is there any solution that would allow me to completely ignore particular folder in SVN (so no matter, what will be put in it, won't be reported as unversioned and won't be auto commited as well) without deleting it?

EDIT: I forgot to add that I'm talking about already versioned folder. It seems that, if you ignore (svn:ignore or proper option in TortoiseSVN) a folder that wasn't yet versioned (before first commit) then everything is OK. But, if you do this on the folder that already was in repository, TortoiseSVN marks it as deleted and deletes it from both repository (but not from Local Working Copy) upon next commit.

4
Could you not simply add the folder and none of its contents, so checking out will produce an empty folder?Wug
@Wug - I think because his app will create files there, so he doesn't want SVN constantly telling him there are unversioned files in that directory.CodingWithSpike
Exactly. I don't want any reports about contents or changes in this folder, especially because there are thousands of files and folders inside that junk folder, and my commit dialog gets overloaded with such entries.trejder
So, add the folder, and set svn:ignore * on the junk_folder, ignoring the contents of that folder rather then the folder itself?Wrikken
I have a few svn projects with things like configuration directories and logging directories which must be present and are themselves versioned, but have no versioned contents. SVN doesnt bother me about them. Maybe I'm just using it wrong :)Wug

4 Answers

12
votes

I believe you can just add an svn:ignore for "*" within that folder, instead of on "junk_folder" itself (in other words, ignore "junk_folder/*").

I don't know if TortoiseSVN has a button for that, but from the command line you can do it with the command:

svn propset svn:ignore "*" junk_folder

(at least I think that is the right syntax, off the top of my head. if someone thinks that is wrong, please correct me)

2
votes

I use this for things like compiler intermediate output folders, and it has never deleted anything.

To re-test this, I found an unversioned directory in one of my working copies. I right clicked on the directory, and navigated to the "Add to ignore list" option. It expanded to the directory name. I selected the directory name and received a pop up message noting that it had been added to the ignore list. Checking the working copy status, the parent folder had a property only modification. No files were marked for deletion.

Ignoring Files And Directories

enter image description here

As a side note, you can also hide unversioned files when using "Check for Modifications" and Commit dialogs with a checkbox near the bottom of the dialog.

2
votes

I am using Eclipse Subversive and Tortoise SVN.

My approach to this problem is to use the properties dialog from Tortoise (but I think Eclipse has the same feature)

If you right click on a folder in your working copy, e.g 'tmp' or 'cache' etc you can simply add the 'svn:ignore' property and put a wild card in there. You need to use the advanced button to add it because its not the the quick list of properties to add.

I am developing websites mostly on Joomla, and regularly installers or other components leave files in places that I don't want in the repo. And as mentioned 'svn:ignore'ing these folders using the 'right click ignore' method means these folder are completely excluded from the repo which is not what you want - you want the contents of those folders excluded, or sometimes just files with a certain extension.

after getting much advice from stackoverflow I signed up today to just to answer this question so hope it helps someone - I tried to attach screen shot but not enough rep :(

1
votes

What do you mean "If I use standard TortoiseSVN ignore feature, it will add svn:ignore junk_folder property to parent folder, but it will also delete junk_folder..."?

Subversion does not delete a folder you ask it to ignore. In fact, that's the whole purpose of svn:ignore: To allow you to have a folder that's not in the repository without Subversion whining about it.

How is this junk_folder created? Is it by a script you use, or do you do it manually? Exactly when does it get deleted? Do you mean when you do a new checkout, junk_folder isn't there, or that TortoiseSVN deletes it as soon as you add the svn:ignore property on its parent directory?

If you need that folder permanently in your repository, but it must remain empty, you can add junk_folder to the repository, and then create a svn:ignore property that's set to *. That will ignore anything in the folder.

My suggestion is to make sure that whatever scripts need junk_folder create it if it doesn't exist, and not to add it to your repository. You can use this pre-commit hook to keep it out of your repository. That would be the best way to handle this. There's no reason why an empty directory named junk_folder should be in your repository.