views:

37

answers:

3

I want to do the following:

When one user is editing a file from SVN, no other user can edit this file until the first user commits his changes. That is there would be some kind of writelock on files in svn.

Is this possible in SVN? How to do it? Is it possible to set this for a single file or directory (not for the whole repository)?

Why would this be useful? Conflicts on binary and some other files cannot be easily resolved. I would like to set my excel files in svn to be write locked in the way described above.

I would welcome guide on how to do this in VisualSVN or TortoiseSVN which I use.

+3  A: 

You can set the property svn:needs-lock on such files, then the file gets checked out "read only". If you want to edit it, you have to lock the file with svn lock. That workflow is there for exactly this case.

See here http://svnbook.red-bean.com/en/1.5/svn.ref.properties.html for info on svn:needs-lock.

Adrian Smith
+2  A: 

The "svn lock" command prevents other people from committing changes to a file. It can't keep you from editing the file, since svn has no control of the file itself once it's checked out. You can procedurally tell everyone to lock the binary file before editing to prevent someone from making edits they cannot commit.

JOTN
A: 
  1. You can not make such writelock if someone has already working copy. You may put regural lock. But it can be put only per file not whole directory. Then other user may not commit their changes till lock is released. If you want to make it for whole directory then you should write a hook script. That is run on the server side, on events e.g. commit event,.... You could put more logic into it to forbid checkouts. But it is not how should we work under svn. The possiblity of parallel development is one of the key feature of svn.
  2. Writelock is not effective why someone should not work on his working copy in parallel. He will need to merge to newest version anyway.
Gadolin