views:

1287

answers:

8

Today I came across a problem where someone had accidentally committed a proj.user file to the SVN repository. When i came to update, it obviously caused issues.

It got me wondering if there was any way that you can block certain file extensions to be committed to the repository.

I do realise there is an ignore list but as far as I am aware this still relies on the person to add the files to ignore list. Ideally I would like to control this centrally so that the repository rather than the person has control.

Is this possible?

A: 

In SVN, you add files to the repository manually. Thus it does not make sense to have a file extension block list. You can use svn ignore to ignore specific files, but again, you are meant to manually add and remove files from the repository.

See also http://stackoverflow.com/questions/210933/how-do-you-remove-a-file-from-being-version-controlled-without-deleting-the-file

superjoe30
svn doesn't actually have an ignore command... so svn ignore will simply result in an error.
Jason Coco
svn:ignore is not a command, it's a property: http://svnbook.red-bean.com/en/1.1/ch07s02.html
Simon Lieschke
+8  A: 

Yes, in general there are two ways. Either create commit-hooks (which is probably not what you want to do), or, more easily, add the svn:ignore property to your directory. Since properties are maintained along with the project, this will effect everyone. For instance, to ignore *.user files, you could add this to the directory where they would appear:

svn setprop svn:ignore '*.user' .

Then commit your change as usual. From now on, *.user files in that directory will no longer participate in svn commands such as stat, update, commit and so forth. You do have to add the property to each directory that requires an ignore field, however. It does not automatically act recursively on your project tree. If, for any reason, you do want to update an ignored file, you would pass the --no-ignores flag to the command.

Jason Coco
Will this actually keep it from being explicitly `$ svn add`'ed?
sirlancelot
No, if you specifically add it, it will be added, but updates to it will be ignored.
Jason Coco
+1  A: 

You could possibly add a subversion pre-commit hook to prevent people commiting them. This has the advantage of being server side, rather than a per client setting.

Steven Robbins
Subversion properties are also managed with the project, so they have the benefit of being revisioned as well as being maintained on the server :) plus they don't require coding.
Jason Coco
They do, but they are also more of a pain to setup when you have a lot of projects/directories.. swings and roundabouts and all that :)
Steven Robbins
I absolutely agree if you're an experienced Subversion administrator, but if you're asking this question here, I think the extra work of adding the svn:ignore property to multiple project dirs might be the better choice :)
Jason Coco
A: 

Check out the svn:ignore property.

Hank Gay
A: 

You want to add on the server side a ignore list ? I think it's not directly possible but you can analyze the files in the pre-commit hook (see : http://svnbook.red-bean.com/en/1.1/ch05s02.html#svn-ch-5-sect-2.1) and reject completly the commit if the name/pattern is incorrect ?

Matthieu
A: 

In addition to setting the ignore property you can also use the "global-ignore" run time configuration option to do this globally. Follow the links for more info. I think the global-ignore feature is what you might be looking for.

Stephen Doyle
The problem with the global-ignore setting is that it's per-client. If there's a project rule that *.user files shouldn't be revisioned but some build process or whatever generates them within controlled directories, you would have to get everyone to update their configurations manually.
Jason Coco
A: 

Regarding this:

Will this actually keep it from being explicitly $ svn add'ed? – sirlancelot Jan 6 '09 at 18:14

No, if you specifically add it, it will be added, but updates to it will be ignored. – Jason Coco Jan 6 '09 at 20:08

I believe you can't do thisplaying with svn:ignore props. As per svnbook 1.5 manual:

"Subversion's support for ignorable file patterns extends only to the one-time process of adding unversioned files and directories to version control. Once an object is under Subversion's control, the ignore pattern mechanisms no longer apply to it. In other words, don't expect Subversion to avoid committing changes you've made to a versioned file simply because that file's name matches an ignore pattern—Subversion always notices all of its versioned objects."

Sebastian
A: 

I had to use

svn propset svn:ignore '*.user' .

In order to use the accepted answer above.

Darrell Duane