user1489969
user1489969

Reputation: 11

how to lock files and make it read-only in svn

I am using VisualSVN Server to store my files in a repository. Then I check them out using TortoiseSVN client. I want to make sure that when one client has locked and started working on a file, the other clients should not be able to make changes to the same file as well. When they check out the repository they should see the file as "read-only".

In order to do this I went to the config file of the TortoiseSVN and added the property "*.* = svn:needs-lock=true" and I also uncommented the line enable-auto-props = yes, both in the server and the client side to be sure. But still after making the lock, the other clients are able to modify the file, though they cannot commit it, since the lock is already made.

Can anyone please take a look at this and tell me what I am doing wrong?

Upvotes: 0

Views: 8189

Answers (2)

Ferenc Kiss
Ferenc Kiss

Reputation: 307

With the JIRA add-on called Commit Policy you can reject modified files that do not match a regex or glob expression:

"Changed files must match a pattern" condition

Verifies the committed files, including modified, added, removed or otherwise touched files.

It matches a regular expression or a glob pattern to the every file included in the commit. The condition is satisfied only if the pattern matches all file paths.

With this condition type, you can lock single or multiple files (glob):

!({*/README.txt,README.txt})

...single or multiple directories (glob):

!(src/main/java/com/company/internal/)

or any mix of these.

See more examples here.

Upvotes: 0

bahrep
bahrep

Reputation: 30662

Auto-props instructs Subversion to automatically set properties on newly added or imported files. It won't touch files that already exist in a repository. See http://svnbook.red-bean.com/en/1.8/svn.advanced.confarea.html#svn.advanced.confarea.opts

To implement the lock-modify-unlock model you are required to perform the following general steps:

  1. The first step would be to set svn:needs-lock property on files. After applying svn:needs-lock to a file the file gets read-only attribute. Before editing the file, it should be explicitly locked (this fact is reflected in the repository). After committing the lock is released by default.

  2. Then you can implement some kind of locking policy (see http://svnbook.red-bean.com/en/1.8/svn.advanced.locking.html#svn.advanced.locking.break-steal) to restrict some of the users from being able to steal locks,

  3. You can setup pre- and -post lock and unlock hooks to notify users (or managers) that a file has been locked or unlocked, when and by whom.

I strongly advise you to carefully read the following SVNBook sections:

Upvotes: 1

Related Questions