繁体   English   中英

如何使用 Repository.GetFileContents() 在 p4api.net 中获取文件 @Label

[英]How do I use Repository.GetFileContents() to get file @Label in p4api.net

试试这个:

var path = $"{filePath}@{fileLabel}";
var dloc = new DepotPath(path);
var opts = new GetFileContentsCmdOptions(GetFileContentsCmdFlags.Suppress, null);
var file = p4repo.GetFileContents(opts, dloc);

即使我已经从命令行使用“p4 print”验证了“路径”,我总是会得到一个空文件。 请注意,“路径”中的字符串类似于“//source/things/stuff/that_file_I_need.txt@our_p4_label_2021_5_8”。

但是,如果我使用 '//source/things/stuff/that_file_I_need.txt'(省略 @label 部分)作为 'path' 的值,则执行将返回 depot 尖端中文件的内容。 这显然不是我想要的文件版本。 我根本无法弄清楚(或找到)如何在选定的 label (@) 或特定版本 (#) 处获取文件。 这些是执行此操作的常见 p4 约定。

有人知道这里的答案吗? 提前致谢!

使用PathSpecVersionSpec构造文件规范,而不是将字符串连接在一起:

https://www.perforce.com/manuals/p4api.net/p4api.net_reference/html/M_Perforce_P4_FileSpec__ctor_3.htm

暂无
暂无

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

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