Using the p4java library from Perforce (http://kb.perforce.com/article/1086/p4java-api), I'm trying to find out what files in a changelist are unresolved and need to be resolved before I can submit them.
IChangelist changelist = getServer().getChangelist(changelistId);
List<IFileSpec> changelistPendingFiles = changelist.getFiles(false);
In this List, I'm trying to figure out which IFileSpec still need to be resolved.
Something like this:
for (IFileSpec pendingFile : changelistPendingFiles) {
// How to find out if pendingFile needs to be resolved?
FileAction action = pendingFile.getAction();
// The above results in "FileAction.EDIT",
// but that doesn't tell me anything about the unresolved state
// The "diffStatus" variable for this pendingFile is "pending"
// The "howResolved" variable for this pendingFile is null
// The "opStatus" variable for this pendingFile is VALID
}
Thanks for anything you can provide!
The comprehensive way is to run P4Java's version of the fstat command, and check if the file needs resolving. Here's a code sample (not guaranteed to be bulletproof) that works in a simple test case.
List<IExtendedFileSpec> extfiles = server.getExtendedFiles(changelistPendingFiles,
-1,
-1,
-1,
new FileStatOutputOptions(false, false, false, false, false, true),
null);
for(IExtendedFileSpec extfile : extfiles) {
System.out.println(extfile.isUnresolved());
}
In the FileStatOutputOptions, I'm asking for information on files that are open and need resolving. The isUnresolved method should tell you what you want.
Hope that helps!