如何告诉 TortoiseHg 文件不是二进制文件?

发布于 2024-11-02 12:45:57 字数 182 浏览 1 评论 0原文

最近有人将 PowerShell (.ps1) 脚本添加到我们的 Mercurial 存储库中。该文件是纯文本,但 TortoiseHg 似乎认为它是二进制的并显示一条消息:“文件或差异未显示:文件是二进制的”。

如何告诉 TortoiseHg ps1 文件是文本文件而不是二进制文件。我正在使用版本 TortoiseHg 2.0.3

Someone has recently added a PowerShell (.ps1) script to our Mercurial repository. The file is plain text but TortoiseHg seems to think it's binary and displays a message: "File or diffs not displayed: File is binary".

How to I tell TortoiseHg that ps1 files are text and not binary. I'm using version TortoiseHg 2.0.3

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

慈悲佛祖 2024-11-09 12:45:57

这些文件以 UCS-2 编码进行编码,我使用 notepad++ 将其转换为 UTF-8。

现在已经完成了,mercurial 似乎可以将该文件识别为文本并正确执行差异。

是时候我再阅读这篇文章了!

可能也值得一看这个,因为 UCS-2 看起来很接近与 UTF-16 相关。根据该链接,它放弃了它,但将 Windows 从 UCS-2 迁移到 UTF-16 的努力自 2000 年之前就一直在进行!

The files are encoded in UCS-2 encoding and I used notepad++ to convert it to UTF-8.

Now that's done, mercurial seems to recognises the file as text and performs a diff properly.

It's time I read this again!

It might be worth looking at this, too as UCS-2 seems closely related to UTF-16. According to that link, it super-cedes it but the effort to move Windows to UTF-16 from UCS-2 has been ongoing since before 2000!

难以启齿的温柔 2024-11-09 12:45:57

很抱歉回复这么旧的帖子,但出于历史目的,有一些评论是有必要的。

首先,就修订而言,底层代码存储库 (mercurial) 将所有文件视为二进制文件。您在这里失去的只是看到差异的能力,物理差异仍然被跟踪,并且由于 Tortoise 无法显示它们,这些变化的性质并没有变得更大。 (相比之下,JPEG 二进制文件即使对于较小的像素变化也具有较大的二进制差异;而这些文件的差异相对较小。)

其次,即使 Tortoise 无法显示差异,但如果您设置了 Mercurial.ini,则 kdiff3 可以显示差异适当归档。在您的主目录中,您可能有一个 Mercurial.ini 文件,即使只是为了记录您的用户名。如果将其扩展以包含合并模式。在此处查找合并模式:http://www.selenic.com/mercurial/hgrc。 5.html.

在那里,您将看到如何告诉 Mercurial 这些文件中的差异应该使用 kdiff3 显示,即使 Mercurial 认为它们是二进制的。 Tortoise 仍然不会在工作台上显示差异,但您可以右键单击该文件并向父级显示差异,您会很好地看到差异。它并不完美,但总比没有好。

Sorry for responding to a post that's so old, but for historical purposes, a few comments are in order.

First, the underlying code repository (mercurial) treats all files as binary as far as revisions go. All that you're losing here is the ability to see the differences, the physical differences are still tracked, and the nature of those changes aren't any larger by virtue of the fact that Tortoise can't display them. (JPEG binary files, by contrast, have large binary differences even for small pixel changes; whereas these files will have relatively small differences.)

Second, even though Tortoise can't display the differences, kdiff3 can if you set up your mercurial.ini file appropriately. In your home directory, you likely have a mercurial.ini file, even if just to record your username. If you expand it out to include merge-patterns. Look here for merge-patterns: http://www.selenic.com/mercurial/hgrc.5.html.

There, you'll see how to tell mercurial that differences in these files should be displayed with kdiff3, even though mercurial believes them to be binary. Tortoise still won't display the differences on the workbench, but you can right-click the file and show differences to parent, and you'll see the differences just fine. It ain't perfect, but it's better than nothing.

忆梦 2024-11-09 12:45:57

使用 notepad++ 有助于将 UCS-2 编码转换为 UTF-8。

但是,当我使用它来转换 XML(Visual Studio csproj)文件时,不要忘记将 XML 编码从 utf-16 更改为 utf-8,例如:

<?xml version="1.0" encoding="utf-8"?>

Using notepad++ helps with converting UCS-2 encoding to the UTF-8.

However, when I use it, for example, to convert XML (Visual Studio csproj) file, do not forget to change the XML encoding from utf-16 to utf-8, like:

<?xml version="1.0" encoding="utf-8"?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文