Ihsan chahi
Ihsan chahi

Reputation: 307

SVN Needs Lock can be removed by any user

I lock a file in SVN Using Needs lock ,but another user on his system get the code and unlock the file by simply removing the needs lock property. Is there any thing no other user can unlock any file lock by a specific user.

Upvotes: 1

Views: 363

Answers (1)

Ben
Ben

Reputation: 8905

That is completely the wrong way to lock or unlock a file. "needs lock" just tells SVN that the file ought to be locked before editing. It does NOT lock the file. It is not even necessary to set "needs lock" on a file before locking it. You can lock any file at all. The needs-lock property only lets SVN set that file to readonly on checkout, so that you are reminded not to accidentally edit a file without locking it first.

Actual locking is done with the svn lock command. If you lock a file, only you can commit changes to that file. If somebody else tries to commit changes, or even if YOU try to commit changes from a different working copy, the commit will fail.

Now, by default anybody can still "break" or even "steal" your lock, but they need to do that explicitly and it is considered quite rude. It is necessary sometimes, for example, if the lock holder goes on a 3-month vacation or something.

It is possible to set up a server-side "pre-lock" hook script to allow or disallow a given lock operation based on whatever criteria you choose. You could in theory install such a script to always disallow breaking a lock held by somebody else. But locks are meant as a communication mechanism, nothing more. If people start breaking a lock willy-nilly for no good reason, your team has a problem with working as a team that needs to be addressed.

Upvotes: 2

Related Questions