Single user checkout in SVN

拟墨画扇 提交于 2019-12-12 11:11:01

问题


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.


回答1:


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.




回答2:


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.




回答3:


  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.


来源:https://stackoverflow.com/questions/4014742/single-user-checkout-in-svn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!