使用 Perforce 的 p4java 库 (http://kb.perforce.com/article/1086/p4java-api),我试图找出更改列表中的哪些文件未解决,需要先解决,然后才能提交。
IChangelist changelist = getServer().getChangelist(changelistId);
List<IFileSpec> changelistPendingFiles = changelist.getFiles(false);
在此列表中,我试图找出哪些 IFileSpec 仍需要解析。
类似这样的事情:
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
}
感谢您提供的一切!
最佳答案
综合的方法是运行P4Java版本的fstat命令,并检查文件是否需要解析。这是一个在简单测试用例中工作的代码示例(不保证万无一失)。
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());
}
在FileStatOutputOptions中,我要求提供有关打开且需要解析的文件的信息。 isUnresolved 方法应该告诉你你想要什么。
希望有帮助!
关于java - 如何使用 Perforce p4java 库查找未解析的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8713392/