简体   繁体   English

如何通过 python 获取给定仓库路径的 Perforce 文件类型?

[英]How do I get the Perforce file type, of a given depot path, through python?

I've got a content creation tool, updating files in perforce.我有一个内容创建工具,可以在 perforce 中更新文件。 These files have been inconsistently created as binary or text.这些文件被不一致地创建为二进制或文本。

I would like to get the file type of an existing depot file so when the user saves a new revision, it will export the correct type from the tool.我想获取现有仓库文件的文件类型,以便当用户保存新修订时,它将从工具中导出正确的类型。

It seems too hacky to just always export as text to avoid file corruption of those p4 type files.总是导出为文本以避免这些 p4 类型文件的文件损坏似乎太hacky了。 Aside from larger file sizes, are there other issues with checking in a text file as Binary in perforce?除了较大的文件大小之外,在 perforce 中将文本文件作为二进制文件签入是否还有其他问题?

I would like to get the file type of an existing depot file我想获取现有仓库文件的文件类型

Most Perforce commands that report on files will include the filetype as part of the output.大多数报告文件的 Perforce 命令将包含文件类型作为输出的一部分。 The simplest one is p4 files ;最简单的是p4 files if you run p4 files FILENAME there will be a filetype like (text) at the end of the output.如果您运行p4 files FILENAME ,则输出末尾会出现类似(text)的文件类型。

so when the user saves a new revision, it will export the correct type from the tool.因此,当用户保存新修订时,它将从工具中导出正确的类型。

Be aware that Perforce's filetype is not the same as your tool's concept of filetype!请注意 Perforce 的文件类型与您工具的文件类型概念不同! To Perforce, .PNG and .PDF are both just binary .对于 Perforce, .PNG.PDF都只是binary

Aside from larger file sizes, are there other issues with checking in a text file as Binary in perforce?除了较大的文件大小之外,在 perforce 中将文本文件作为二进制文件签入是否还有其他问题?

A binary file is essentially "not text" and will disable all of the Perforce features that depend on the concept of line breaks and textual characters -- RCS delta storage is one, but you also won't get line ending format conversion, diff/merge, p4 annotate , p4 grep , et cetera.二进制文件本质上是“非文本”,将禁用所有依赖于换行符和文本字符概念的 Perforce 功能——RCS 增量存储就是其中之一,但您也不会获得行尾格式转换,diff/合并、 p4 annotatep4 grep等等。

If the text files generated by this tool aren't diffable or human-readable, and if they aren't expected to obey native line ending conventions (or if they aren't portable across platforms in the first place), then binary sounds like the right choice across the board.如果此工具生成的文本文件不可区分或人类可读,并且不希望它们遵守本机行尾约定(或者如果它们首先不能跨平台移植),则binary听起来像全面的正确选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM