使用来自Perforce (http://kb.perforce.com/article/1086/p4java-api)的p4java库,我试图找出变更列表中哪些文件未解析,需要在提交它们之前解析它们。
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
}感谢您所能提供的一切!
发布于 2012-01-05 00:44:48
综合的方法是运行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方法应该告诉你你想要什么。
希望这能有所帮助!
https://stackoverflow.com/questions/8713392
复制相似问题