如何在 SVN 中进行独占结账?
我正在寻找一种从 SVN 进行独家结帐的方法。
有没有办法在检出文件时自动锁定文件?
如果一个用户进行独占签出,然后另一个用户对同一文件进行签出,我如何向第二个用户生成某种通知或即时消息,告知该文件已锁定?
I'm looking for a way to make an exclusive checkout from SVN.
Is there a way to automatically lock a file when it's being checked out ?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以添加属性或自动属性
svn:needs-lock
,使文件变为只读,并要求您在文件上加锁才能对其进行编辑。如果您使用 TortoiseSVN,您将看到锁定文件的不同图标,这应该很容易让第二个用户看到并知道不要编辑该文件。
在 TortoiseSVN 文档中引用
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
您可以使用 svn lock 来防止其他用户重新签入更改(请注意,您可以使用
--force
来获取其他用户的锁定)。 这将在命令行上生成消息,告诉人们谁锁定了该文件。这样做并不常见。 人们通过签出副本(非排他性)并写回与其他更改合并的更改来使用 SVN(这种情况发生在可合并格式(例如文本)中 - 您不能对二进制文件执行此操作,并且如果另一个签入已被拒绝,则签入将被拒绝)在此期间发生)。
我不希望经常使用它,而且我通常依赖 a) svn 的合并能力 b) 与其他团队成员的沟通,以确保我不会踩到别人的脚趾。
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.
如果我理解您的后续帖子,我认为您真正想要的是确保人们了解锁。 我想象这样一种情况,用户 A 和 B 已经签出了 jpeg。 用户 A 现在将其锁定,并且您希望确保用户 B 知道,这样他或她就不会开始编辑 jpeg 并浪费时间和精力。
如果这是正确的,我建议两件事:首先也是最重要的是沟通(不是很技术性,但如果一致使用的话非常强大); 其次,您可以查看
svn
的post-lock
存储库挂钩。 当有人锁定文件时,您可以使用它发送电子邮件。来自
颠覆
书: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 forsvn
. You can use that to have emails sent when someone puts a lock on a file.From the
subversion
book: