我正在尝试编写一个方法,该方法将文件路径和修订号作为其参数并返回与修订关联的日期。我的代码可以工作(虽然速度很慢)但是,当我输入大于 51 的修订号时,输出会变得混乱。这是 API。
输入
String [] filePaths= {"//file/x/y/strings/somefile.csv"};
p4Client.getDateAssociatedWithFileRevision(filePaths, 52);
输出 - 这应该只是一行......
Rev number: 2 :: Revision Date: Wed Aug 24 23:48:42 BST 2005
Rev number: 52 :: Revision Date: Wed Aug 24 23:52:53 BST 2005
Rev number: 51 :: Revision Date: Sat Aug 20 02:01:59 BST 2005
getDateAssociatedWithFileRevision
public Date getDateAssociatedWithFileRevision(String [] filePath, int revisionNumber) {
List<IFileSpec> fileList = null;
Map<IFileSpec,List<IFileRevisionData>> fileRevisionData = null;
String currentFile = null;
Date revisionDate = null;
try
{
String file = filePath[0] + "#" + revisionNumber;
currentFile = file;
fileList = getIFileSpecList(file); //Get list of file(s) in path
for(IFileSpec fileSpec: fileList)
{
if(file.toString() == null)
{
System.out.println("\"" + currentFile +"\"" + " does not exist...");
break;
}
fileRevisionData = fileSpec.getRevisionHistory(0, true,false,true,false);
int i = 0;
for(List<IFileRevisionData> revisionData : fileRevisionData.values()) {
revisionDate = revisionData.get(0).getDate();
int revision = revisionData.get(0).getRevision();
System.out.println("Rev number: " +revision +" :: " + "Revision Date: " + revisionDate);
System.out.println(i);
i++;
}
}
}
catch(Exception e){e.printStackTrace();}
return revisionDate;
}
获取IFileSpecList
public List<IFileSpec> getIFileSpecList(String file) {
List<IFileSpec> fileList = null;
try {
fileList = iServer.getDepotFiles(
FileSpecBuilder.makeFileSpecList(new String[] {file}), false); //Get list of file(s) in path
}
catch(Exception e){e.printStackTrace();}
return fileList;
}
编辑
刚刚发现集成后输出变得混乱,现在只需要找到一种方法来处理它们..