gpt4 book ai didi

c# - P4Api client.GetFileMappings 不返回分支文件的前导减号/破折号

转载 作者:行者123 更新时间:2023-12-04 10:52:34 24 4
gpt4 key购买 nike

我在多个分支下的 P4 服务器上有文件,例如

//depot/branch1/file.txt
//depot/branch2/file.txt
//depot/branch3/file.txt

假设 file.txt 是同一个文件但不同的分支

当我使用命令行时
p4 -c testWorkspace where somepath\file.txt

我得到以下结果
-//depot/branch1/file.txt {client path depot path}
-//depot/branch2/file.txt {client path depot path}
//depot/branch3/file.txt {client path depot path}

并且从中我可以告诉客户端testWorkspace中的file.txt应该通过branch3访问(所以从这个仓库路径我将获得FileSpec、元数据、编辑等

但是当我尝试通过 P4api.net 做同样的事情并使用
Client.GetClientFileMappings("somepath\file.txt")

或者
P4Command cmd3 = new P4Command(con, "where", true, "somepath\file.txt");
P4CommandResult result3 = cmd3.Run();

我得到了类似的结果,但没有前导减号(破折号 - )符号
//depot/branch1/file.txt {client path depot path}
//depot/branch2/file.txt {client path depot path}
//depot/branch3/file.txt {client path depot path}

而且我不知道我在这里做错了什么。

我需要的是获取给定工作空间的当前文件属于哪个分支的信息,或者更好地获取其正确的 FileSpec,以便我可以使用 MoveFile、Add 等。但我只获得所有分支的路径,并且可以识别它属于当前工作区的哪个分支

最佳答案

查看 GetClientFileMappings 的接口(interface):

https://www.perforce.com/manuals/v15.1/p4api.net/p4api.net_reference/html/M_Perforce_P4_Client_GetClientFileMappings.htm

看起来它实际上并没有返回映射;它返回一个 FileSpec 对象列表,没有关于映射类型的信息(例如 -+& )。在 C++ API 中,这由 MapType 表示。枚举:

https://swarm.workshop.perforce.com/projects/perforce_software-p4/files/2018-2/support/mapapi.h#6

在 .NET API 中有一个类似的枚举:

https://www.perforce.com/manuals/v15.1/p4api.net/p4api.net_reference/html/T_Perforce_P4_MapType.htm

这是 MapEntry 的一部分类型:

https://www.perforce.com/manuals/v15.1/p4api.net/p4api.net_reference/html/M_Perforce_P4_MapEntry__ctor.htm

如果您能找到返回 MapEntry 列表的任何内容s,这将是你想要的,但我找不到任何东西。 GetClientFileMappings似乎是事情,特别是因为名称中有“映射”,但是......

关于c# - P4Api client.GetFileMappings 不返回分支文件的前导减号/破折号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59404338/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com