How do I do an exclusive checkout in SVN?

╄→尐↘猪︶ㄣ 提交于 2019-12-22 04:19:09

问题


I'm looking for a way to make an exclusive checkout from SVN.

  1. Is there a way to automatically lock a file when it's being checked out ?

  2. If one user makes an exclusive checkout, and then another user makes a checkout to the same file, how do I generate some sort of notification or an instant message to the 2nd user that the file is locked?


回答1:


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.




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/1184316/how-do-i-do-an-exclusive-checkout-in-svn

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