简体   繁体   中英

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

Trying this:

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

I always get an empty file back even though I've verified the 'path' using "p4 print" from the command line. Note that the string in 'path' is something like '//source/things/stuff/that_file_I_need.txt@our_p4_label_2021_5_8'.

However, if I use '//source/things/stuff/that_file_I_need.txt' (omitting the @label part) for the value of 'path' then execution returns the contents of the file in the tip of the depot. This is not the version of the file I want obviously. I simply can't figure out (or find) how to get the file at a selected label (@) OR at a specific version (#). These are the common p4 conventions for doing such.

Anyone know the answer here? Thanks in advance!

Construct the filespec with a PathSpec and VersionSpec rather than concatenating a string together:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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