Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force user to lock file in SVN before editing

We have some files in our project that can't be merged and hence the files must be locked by the users before editing them. Is there a way to force the user to lock a file before editing?

We are using Subversion and TortoiseSVN / VisualSVN.

like image 800
Zooking Avatar asked Feb 20 '09 15:02

Zooking


People also ask

How do I lock a file for editing?

Right-click a file (or click the ellipses (...)) to open the More Options menu. Click Lock. Choose a duration for the lock. If you choose unlimited, the file will be locked until you unlock it manually.

What is svn locking?

Name. svn lock — Lock working copy paths or URLs in the repository so that no other user can commit changes to them.

Does svn checkout lock files?

You can add the property or auto-prop svn:needs-lock which makes the file read-only and requires you to place a lock on the file to edit it. If you are using TortoiseSVN you will see a different icon for locked files, this should be easy for a second user to see and know not to edit the file.

How do you break the lock in TortoiseSVN?

To release a lock manually, select the file(s) in your working copy for which you want to release the lock, then select the command TortoiseSVN → Release Lock There is nothing further to enter so TortoiseSVN will contact the repository and release the locks.


2 Answers

Two steps:

  • put the svn:needs-lock property on those files. That way they are check out read-only
  • when such a file must be modified, use the svn lock command and commit as usual

links:

  • http://svnbook.red-bean.com/nightly/en/svn.advanced.locking.html
  • http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-locking.html
like image 155
cadrian Avatar answered Sep 23 '22 20:09

cadrian


More specifically, if you have TortoiseSVN installed,

  1. Right-click the file in Windows Explorer, select TortoiseSVN->Properties
  2. Click New->NeedsLock
  3. Choose Locking required in the dialog:
  4. Click OK
  5. Commit the file
  6. Done!
like image 39
Godsmith Avatar answered Sep 21 '22 20:09

Godsmith