Anuya
Anuya

Reputation: 8350

How to make a file read-only for other persons after being checked out by me in Subversion?

I am new to Subversion. My colleague is able to checkout a file which I am already editing. This leads to conflict when he tries to commit the changes he has made to the file.

What I want is, if I do some changes to the file, the file should be read-only to other persons who are trying to edit it. So that they know that this particular file is being used by some other person.

How can I configure this on subversion? Is it has to be done on all the clients OR the configuration on server is enough?

Upvotes: 0

Views: 124

Answers (1)

Rup
Rup

Reputation: 34418

You can mark a file as needs-lock in the repository:

svn propset svn:needs-lock "*" myfile.doc
svn commit

Then the next time everyone updates the file will become read-only in their checkout. In order to edit they now need to lock it:

svn lock mfile.doc

which registers that you have the file locked in the repository: you'll see this as a K in svn status and they'll see an O to mean someone else has locked the file. Once you commit, or svn unlock it you'll release the lock.

As Álvaro comments, though, you should avoid setting up locking unless you really need it. Use it only for binary files that SVN cannot merge.

Upvotes: 4

Related Questions