在Mercurial中具有.sql扩展名的文件被标识为二进制 [英] Files with .sql extension identified as binary in Mercurial

查看:108
本文介绍了在Mercurial中具有.sql扩展名的文件被标识为二进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
为什么Mercurial认为我的SQL文件是二进制文件?

Possible Duplicate:
Why does Mercurial think my SQL files are binary?

我为数据库中的存储过程生成了一套完整的脚本.当我创建Mercurial存储库并添加这些文件时,它们都以二进制形式添加.显然,我仍然可以获得版本控制的好处,但是会损失很多效率,文本文件的差异化"等.我确认这些文件确实都是文本.

I generated a complete set of scripts for the stored procedures in a database. When I created a Mercurial repository and added these files they were all added as binary. Obviously, I still get the benefits of versioning, but lose a lot of efficiency, 'diff'ing, etc... of text files. I verified that these files are indeed all just text.

为什么要这么做?

该如何避免呢?

是否有办法让Hg对这些文件改变主意?

IS there a way to get Hg to change it mind about these files?

这是变更集日志的一小段:

Here is a snippet of changeset log:

   496.1 Binary file SQL/SfiData/Stored Procedures/dbo.pFindCustomerByMatchCode.StoredProcedure.sql has changed
   497.1 Binary file SQL/SfiData/Stored Procedures/dbo.pFindUnreconcilableChecks.StoredProcedure.sql has changed
   498.1 Binary file SQL/SfiData/Stored Procedures/dbo.pFixBadLabelSelected.StoredProcedure.sql has changed
   499.1 Binary file SQL/SfiData/Stored Procedures/dbo.pFixCCOPL.StoredProcedure.sql has changed
   500.1 Binary file SQL/SfiData/Stored Procedures/dbo.pFixCCOrderMoneyError.StoredProcedure.sql has changed

在此先感谢您的帮助 吉姆

Thanks in advance for your help Jim

推荐答案

与Mercurial的关于二进制文件的视图保持一致文件,它实际上不会跟踪文件类型,这意味着用户无法将文件标记为二进制文件或非二进制文件.

In fitting with Mercurial's views on binary files, it does not actually track file types, which means that there is no way for a user to mark a file as binary or not binary.

正如tonfa和Rudi所述,Mercurial通过查看文件中是否存在NUL字节来确定文件是否为二进制文件.对于UTF- [16 | 32]文件,几乎可以保证NUL字节.

As tonfa and Rudi mentioned, Mercurial determines whether a file is binary or not by seeing if there is a NUL byte anywhere in the file. In the case of UTF-[16|32] files, a NUL byte is pretty much guaranteed.

要修复"此问题,必须确保文件使用UTF-8而不是UTF-16编码.理想情况下,导出时,数据库应具有Unicode编码的设置.如果不是这种情况,另一种选择是编写一个预提交钩子来执行此操作(请参见

To "fix" this, you would have to ensure that the files are encoded with UTF-8 instead of UTF-16. Ideally, your database would have a setting for Unicode encoding when doing the export. If that's not the case, another option would be to write a precommit hook to do it (see How to convert a file to UTF-8 in Python for a start), but you would have to be very careful about which files you were converting.

这篇关于在Mercurial中具有.sql扩展名的文件被标识为二进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆