如何告诉Subversion将文件视为二进制文件?
如何告诉Subversion(svn)将文件视为二进制文件?
解决方案
回答
例如:
svn propset svn:mime-type image/png foo.png
回答
根据Subversion常见问题解答,我们可以使用svn propset将svn:mime-type属性更改为application / octet-stream
回答
svn寻找一个mime类型的属性,如果它不存在,则猜测它是文本。我们可以明确设置此属性,请参见http://svnbook.red-bean.com/en/1.5/svn.forcvs.binary-and-trans.html
回答
基本上,我们必须将mime类型设置为八位字节流:
svn propset svn:mime-type application/octet-stream <filename>
回答
通常默认情况下会为我们执行此操作,但是如果不是,则需要查看文件属性和属性集。
回答
从Subversion书籍的第367页开始
In the most general sense, Subversion handles binary files more gracefully than CVS does. Because CVS uses RCS, it can only store successive full copies of a changing binary file. Subversion, however, expresses differences between files using a binary differencing algorithm, regardless of whether they contain textual or binary data. That means all files are stored differentially (compressed) in the repository. CVS users have to mark binary files with -kb flags to prevent data from being garbled (due to keyword expansion and line-ending translations). They sometimes forget to do this. Subversion takes the more paranoid route. First, it never performs any kind of keyword or line-ending translation unless you explicitly ask it to do so (see the section called “Keyword Substitution” and the section called “End-of-Line Character Sequences” for more details). By default, Subversion treats all file data as literal byte strings, and files are always stored in the repository in an untranslated state. Second, Subversion maintains an internal notion of whether a file is “text” or “binary” data, but this notion is only extant in the working copy. During an svn update, Subversion will perform contextual merges on locally modified text files, but will not attempt to do so for binary files. To determine whether a contextual merge is possible, Subversion examines the svn:mime-type property. If the file has no svn:mime-type property, or has a MIME type that is textual (e.g., text/*), Subversion assumes it is text. Otherwise, Subversion assumes the file is binary. Subversion also helps users by running a binary-detection algorithm in the svn import and svn add commands. These commands will make a good guess and then (possibly) set a binary svn:mime-type property on the file being added. (If Subversion guesses wrong, the user can always remove or hand-edit the property.)
手动编辑将通过
svn propset svn:mime-type some/type filename.extension
回答
如果在Windows中使用Torvise svn,请右键单击该文件并转到属性。单击新建,然后添加类型为svn:mime-type的新属性。对于put值:application / octet-stream
回答
尽管Subversion尝试自动检测文件是否为二进制文件,但是我们可以使用svn propset覆盖mime-type。
例如,`svn propset svn:mime-type application / octet-stream example.txt'。这将使文件充当字节的集合,而不是文本文件。另请参见有关文件可移植性的svn手册。
回答
可以使用以下方式将存储库中的文件手动标识为二进制文件:
svn propset svn:mime-type application/octet-stream <filename>
通常这不是必需的,因为Subversion会在首次添加文件时尝试确定文件是否为二进制文件。如果Subversion在应将其视为二进制文件时将某个类型错误地标记为"文本",则可以配置Subversion的auto-props功能以使用非文本MIME类型自动标记该文件。不管文件上配置了什么属性,Subversion仍将文件以二进制格式存储在资源库中。
如果Subversion将MIME类型标识为"文本"类型,则它将启用某些二进制文件不可用的功能,例如svn diff和svn blame。它还允许自动的行尾转换,这可以在逐个客户端的基础上进行配置。
有关更多信息,请参见Subversion如何处理二进制文件?