Perforce:防止 Perforce 更改文本文件格式
有没有办法告诉 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
将所有客户端/工作区规范设置为“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/
如果您在客户端上正确设置了
LineEnd
选项,则 Perforce 客户端在同步到不同平台时可以正确处理行结束。也许你的设置错了?打开您的客户端规格并根据您的需要设置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 theLineEnd
option according to your needs.Check out this KB article on their website for more info. Here's an excerpt:
将要被视为二进制的文本文件添加到 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 isp4 add -t binary file.pdf
.我刚刚遇到了完全相同的问题,但有一个更好的解决方案,不涉及更改客户端规范(这些规范是国际性的,并且并非所有我都具有写入权限)。
我们所有的客户端都是 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.
为文件指定不同的扩展名。
Give the files a different extension.