Jump to content


[Perforce API, C#] how can i know this file is not latest version Before 'Checkout'


  • Please log in to reply
1 reply to this topic

#1 mw1503

mw1503

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 19 December 2019 - 04:50 AM

If i Check Out in Perforce Helix P4V, the file is not latest version Helix P4V is warrning in a popup.
"You do not have the latest revision of the file, Do you want to get the latest revision before checking it out?"

I want to this process in my C# Program.
I use Perforce API, and Checkout using function 'CreateChangeList' and 'EditFiles'
Before Calling function 'EditFiles', i want to check the file in P4V History is latest version, like Helix P4V Program provided Perforce.

How can i check do that?
Eventually, I want to make disable checkout if the file is not latest.

#2 p4bill

p4bill

    Advanced Member

  • Members
  • PipPipPip
  • 217 posts

Posted 07 January 2020 - 04:28 PM

P4V gets local file status with the fstat command. With P4API.NET, that is GetFileMetaData.

Where rep is a Repository:

IList<FileMetaData> fstatData = rep.GetFileMetaData(null, fileSpec);

GetFileMetaData (fstat) returns a lot of data on the file. You should compare the have revision and the head (latest) revision.
Assuming fileSpec is a single file and fstatData did not return null:


if (fstatData[0].HaveRev < fstatData[0].HeadRev)
{
// file is not synced to latest revision
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users