Perforce:防止 Perforce 更改文本文件格式

发布于 2024-08-19 08:24:20 字数 430 浏览 3 评论 0原文

有没有办法告诉 Perforce 保留文本文件而不将文件类型设置为二进制?或者除此之外,有没有办法告诉 Perforce 客户端比较二进制文件?二进制通常是不可取的,因为我失去了区分的能力。

澄清一下:如果我在 Windows 客户端上编辑并更改 *.txt 文件,换行符将按照 DOS 格式包含 CR+LF。但如果我在 Unix 客户端上进行 P4 同步,它将只有 LF。我需要 Perforce 保持格式不变,无论 Perforce 客户端位于何处。

也就是说,我确实有一个解决方法:将文件类型设置为二进制;和/或创建一个文本文件设置为“文本”的分支,并定期集成回文本文件设置为“二进制”的主线。但这对于一个本应非常简单的问题来说是一个过于复杂的解决方法。

最后,我使用的是 Perforce Windows 客户端 2006.2。

提前致谢。

Is there a way to tell Perforce to leave text files alone without setting the file-type as binary? Or barring that, is there a way to tell the Perforce client to diff binaries? Binary usually isn't desirable, because I lose the ability to diff.

To clarify: If I edit and make changes to a *.txt file on my window client, newlines will have CR+LF as per the DOS format. But if I P4 sync on a Unix client, it will have LF only. I need Perforce to keep the format as-is, regardless of where the Perforce client lives.

That said, I do have a work-around: Set file-type as binary; and/or create a branch with text files set as "text", and integrate periodically back into the mainline where text files are set as "binary". But this is an overly-complicated work-around for what should be a very simple problem.

Finally, I'm on Perforce Windows client 2006.2.

Thanks in advance.

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

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

发布评论

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

评论(5

可可 2024-08-26 08:24:20

将所有客户端/工作区规范设置为“unix”行结尾。那么当您在 Windows 上签入时将不会发生任何转换。

请参阅http://answers.perforce.com /articles/KB_Article/CR-LF-Issues-and-Text-Line-endings/

Set all of your client/workspace specs to 'unix' line-endings. Then no conversion will take place when you check in on Windows.

See http://answers.perforce.com/articles/KB_Article/CR-LF-Issues-and-Text-Line-endings/

我要还你自由 2024-08-26 08:24:20

如果您在客户端上正确设置了 LineEnd 选项,则 Perforce 客户端在同步到不同平台时可以正确处理行结束。也许你的设置错了?打开您的客户端规格并根据您的需要设置 LineEnd 选项。

请查看这篇知识库文章他们的网站以获取更多信息。这是摘录:

在服务器端,Perforce 处理
所有使用 Unix 风格 LF 的文本文件
行结束符。尽管 Perforce 商店
服务器归档文件在磁盘上
操作系统的本机行
终止约定(CR/LF on
Windows、Unix 上为 LF)、所有行结尾
被标准化为 Unix 风格的 LF
内部 Perforce 的行尾
服务器操作,例如 p4sync、p4
提交和 p4 diff。

在客户端工作区方面,Perforce
行结束的处理已确定
通过每个全局选项
客户规格。当您同步文本文件时
使用 p4 同步到客户端工作区,或者
将它们提交回 Perforce Server
使用 p4 提交,它们的行结尾是
按照指定的方式转换
clientspec LineEnd 部分。

The Perforce client can handle line ending properly when syncing to different platforms provided you have LineEnd option set properly on your client. Perhaps you have yours set wrong? Open up your client specs and set the LineEnd option according to your needs.

Check out this KB article on their website for more info. Here's an excerpt:

On the server side, Perforce processes
all text files using Unix-style LF
line-endings. Although Perforce stores
server archive files on disk in the
operating system's native line
termination convention (CR/LF on
Windows, LF on Unix), all line-endings
are normalized to Unix-style LF
line-endings for internal Perforce
Server operations such as p4 sync, p4
submit and p4 diff.

On the client workspace side, Perforce
handling of line-endings is determined
by a global option for each
clientspec. When you sync text files
to a client workspace with p4 sync, or
submit them back to a Perforce Server
with p4 submit, their line-endings are
converted as specified in the
clientspec LineEnd section.

囍笑 2024-08-26 08:24:20

将要被视为二进制的文本文件添加到 Perforce 时,请使用带有 -t 选项的命令 p4 add 来覆盖类型映射表。请参阅此处的文档。给出的示例是p4 add -t binary file.pdf

When adding text files that you want to be considered binary to Perforce, use the command p4 add with the -t option to override the type mapping table. See the documentation here. The example given there is p4 add -t binary file.pdf.

甜中书 2024-08-26 08:24:20

我刚刚遇到了完全相同的问题,但有一个更好的解决方案,不涉及更改客户端规范(这些规范是国际性的,并且并非所有我都具有写入权限)。

我们所有的客户端都是 Windows PC,但 Cygwin 包含在 Perforce Depot 中。 Cygwin 是 Unix 的 Windows 实现,要求文本文件使用 LF 作为行结尾。

对于旧版本的 Cygwin,一个可能的解决方案是使用“text”选项挂载根目录,这意味着文件可以具有 CR+LF 行结尾。然而,升级到 Cygwin 1.7.9 后,这不再起作用,因为安装是暂时的,除非将它们写入 /etc/fstab。我没能成功完成这项工作。

幸运的是,坐在我旁边的 Perforce Guru 提出了将文件类型更改为 binary+D 的解决方案,它使用与文本文件相同的 RCS 增量补丁存储,但没有自动行结束转换。

我可以在本地工作区和软件仓库之间成功区分这些“文本”文件。

I have just come across exactly the same problem, but have a better solution that does not involve changing client specs (which are international, and not all of which I have write access to).

All of our clients are Windows PCs, but Cygwin is included within the Perforce Depot. Cygwin is a Windows implementation of Unix, and requires that text files use LF for line endings.

A possible solution for older versions of Cygwin is to mount the root using the "text" option, meaning that files can have CR+LF line endings. However, on upgrading to Cygwin 1.7.9, this no longer worked, as mounts are transient unless they are written into /etc/fstab. I did not manage to make this work.

Luckily, the Perforce Guru sitting next to me came up with the solution of changing the filetype to binary+D, which uses the same RCS incremental patch storage as text files, but without the automatic line ending conversion.

I can diff these "text" files successfully between my local workspace and the depot.

屋顶上的小猫咪 2024-08-26 08:24:20

为文件指定不同的扩展名。

Give the files a different extension.

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