简体   繁体   English

在SVN中管理二进制文件版本控制的好方法

[英]Good way to manage binary files versioning in SVN

I'm using XIB files in Xcode. 我在Xcode中使用XIB文件。 it's XML file, but actually it's not a simple source code, and its internal structure is organized as hierarchical references. 它是XML文件,但实际上它不是一个简单的源代码,它的内部结构被组织为分层引用。 So simple diff/merge model never work. 如此简单的差异/合并模型永远不会奏效

The problem is SVN treats that XIB files as simple text source code file. 问题是SVN将XIB文件视为简单的文本源代码文件。 I have to avoid this. 我必须避免这种情况。 How to force SVN handle these files always as binary behavior. 如何强制SVN始终将这些文件作为二进制行为处理。 (lock/unlock model) (锁定/解锁模型)

If you really need to force SVN to treat some file as binary ones, try to set this property : 如果您确实需要强制SVN将某些文件视为二进制文件,请尝试设置此属性:

svn propset svn:mime-type application/octet-stream filename

Read How does Subversion handle binary files? 阅读Subversion如何处理二进制文件? for more details. 更多细节。

As, Cedric Julien said, you need to set the property svn:mime-type on the file to make sure it's treated as a binary file. 正如Cedric Julien所说,你需要在文件上设置属性svn:mime-type以确保它被视为二进制文件。 Subversion looks at the first X bytes of a file to determine if it's binary or text, and sometimes it doesn't work all the time. Subversion查看文件的前X个字节,以确定它是二进制还是文本,有时它不能一直工作。 I know PDF files can confuse it too. 我知道PDF文件也会让人感到困惑。

You need to use a pre-commit hook to make sure that your developers store these files as binary files. 您需要使用预提交挂钩来确保开发人员将这些文件存储为二进制文件。 The developers can use auto-properties to help them automatically set the svn:mime-type property on XIB and NIBs, but you still need the pre-commit hook to verify that this property is there. 开发人员可以使用自动属性来帮助他们自动在XIB和NIB上设置svn:mime-type属性,但是仍然需要预提交挂钩来验证此属性是否存在。

You can use my pre-commit-kitchen-sink-hook.pl which allows you to verify that particular files have a particular property attached to them and that property has a particular value. 您可以使用我的pre-commit-kitchen-sink-hook.pl ,它允许您验证特定文件是否附加了特定属性,并且该属性具有特定值。

match = \.(nib|xib|pdf)$
property = svn:mime-type
value = application/octet-stream
type = string

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM