8

There are situations where as part of development environment setup, certain files are distributed with default settings and these files are checked in to svn. But we do not want the users to commit local modifications to these files accidentally.

Is there a way possible in svn to do this? I am aware that svn:ignore does not work on files that are already checked in. Or is there a different practice to achieve the same results?

Rag
  • 1,363
  • 4
  • 19
  • 36

4 Answers4

4

It depends on the Client you're using. Tortoise, for example, has Changelists. You can put files on an ignore-on-commit changelist and by default when you come to check-in your code, they won't be ticked. Other clients such as Smart SVN have similar functions.

DaveShaw
  • 52,123
  • 16
  • 112
  • 141
4

The usual approach is completely omit such file (via svn:ignore) and commit a template instead. The user is expected to copy the template and tweak the copy to his liking:

http://subversion.apache.org/faq.html#ignore-commit

I have a file in my project that every developer must change, but I don't want those local mods to ever be committed. How can I make 'svn commit' ignore the file?

The answer is: don't put that file under version control. Instead, put a template of the file under version control, something like "file.tmpl".

Then, after the initial 'svn checkout', have your users (or your build system) do a normal OS copy of the template to the proper filename, and have users customize the copy. The file is unversioned, so it will never be committed. And if you wish, you can add the file to its parent directory's svn:ignore property, so it doesn't show up as '?' in the 'svn status' command.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
1

For anyone coming to this now the answer is here on stackoverflow:

svn changelist ignore-on-commit file-you-want-to-add

Community
  • 1
  • 1
Matt Clarkson
  • 14,106
  • 10
  • 57
  • 85
0

Use my pre-commit hook. You can specify down to individual file levels who has commit permission on particular files. For example, you could do this in the Control file:

[file You are not allowed to modify template files]

file = /**/*.template
access = read-only
users = @ALL

[file Bob is allowed to change the templates]

file = /**/*.template
access = read-write
users = bob

Now, users won't be able to modify your template files anywhere on your system (i.e. assuming they end in the suffix template), but Bob, who is smart and handsome, can modify the template files when needed.

I originally wrote this pre-commit hook to allow users to create, but not modify tags:

[file You can't modify a tag]
file = /tag/**
access = read-only
users = @ALL

[file You can't modify a tag]
file = /tag/*
access = add-only
users = @ALL

This allows all users to create a new tag, but no one is allowed to commit changes to a tag once it has been created.

David W.
  • 105,218
  • 39
  • 216
  • 337