Firedragon
Firedragon

Reputation: 3733

Change a Subversion file so it can never be modified

Is it possible to change a file stored in Subversion so that it can never be modified? We have a file that we need to be stored in the system but no user should be able to update it.

Upvotes: 1

Views: 96

Answers (4)

David W.
David W.

Reputation: 107080

I see you've already accepted an answer, but I have a Perl pre-commit hook that does what you want. All you have to do is sent an entry in the control file:

[file You are not allowed to modify this file]
file = /the/file/you/cannot/modify.txt
access = read-only
users = @ALL

By the way, you should create an administrator's group that can modify these files, so you don't have to change the hook if you do have to modify it:

; Creates a group of users who are allowed to modify read-only files
[group admins]
users = firedragon, bob, ted, carol, alice

[file Only Admins are allowed to modify this file]
file = /the/file/you/cannot/modify.txt
access = read-only
users = @ALL

; Order is important. The last entry that matches
; the file is the one implemented
[file Only Admins are allowed to modify this file]
file = /the/file/you/cannot/modify.txt
access = read-write
users = @admins

You can specify a group of files using Ant-styled globs or Perl regular expressions, and the access control can be read-write, read-only, no-delete, or add-only which is great for tags. Users can create a tag, but not modify it.

[file You can create a tag, but not modify it]
file = /tags/**
access = read-only
users = @ALL

[file You can create a tag, but not modify it]
file = /tags/*/
access = add-only
users = @ALL

The first one removes all ability to write anywhere in the entire tags directory tree. The second one allows users to only add a tag directly under the /tags/ directory.

By the way, you should create an administrator's group that can modify these files, so you don't have to change the hook if you do:

Upvotes: 2

nebula
nebula

Reputation: 4002

I think the answer is yes and no both. Yes in the sense that you can lock the file and never unlock for other users. No in the sense that if you unlock the file, another user can modify it. Its up to you to find the right choice of answer.

Upvotes: 0

kichik
kichik

Reputation: 34744

You can use svn lock, but other users can force the lock away. The best method is to use a hook that will deny modification of the file.

These articles should get you going:

Upvotes: 1

James Clark
James Clark

Reputation: 1821

You can create a pre-commit hook that rejects any commit which includes that file.

See Implementing Repository Hooks.

Upvotes: 2

Related Questions