How do I do an exclusive checkout in SVN?

廉价感情. 提交于 2019-12-05 03:35:12

If I understand your follow-up posts, what I think you really want is to make sure that people know about locks. I'm imagining a case where users A and B have already checked out a jpeg. User A now locks it, and you want to make sure that user B knows, so that he or she doesn't begin editing the jpeg and wasting time and effort.

If that's correct, I recommend two things: first and foremost, communication (not very technical, but very powerful when used consistently); second, you might take a look at the post-lock repository hook for svn. You can use that to have emails sent when someone puts a lock on a file.

From the subversion book:

The post-lock hook runs after one or more paths have been locked. It is typically used to send email notification of the lock event.

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.

Referenced in TortoiseSVN documentation

You can use svn lock to prevent other users checking changes back in (note that you can use --force to take a lock from another user). This will generate messages on the command line telling people who's locked that file.

It's not common to do this. People work with SVN by checking out copies (non-exclusively) and writing back changes which are merged with other changes (this occurs for mergeable formats like text - you can't do this for binaries and a checkin will be rejected if another checkin has occurred in the meantime).

I would not expect this to be used regularly, and I normally rely on a) svn's merging capability b) communication with other team members to ensure I'm not treading on other people's toes.

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