问题
I like to use the Perforce Java API to make a list of all changelists since a specific Changelist of a Branch. On the command line you can get it with: p4 changes -L BRANCHNAME@CHANGELISTID,#head. But now i like to use the API.
List<IFileSpec> fileSpecs = new ArrayList<>();
FilePath path = new FilePath(PathType.DEPOT, p4Branch + "/...");
FileSpec fileSpec = new FileSpec(path);
fileSpec.setChangelistId(changelist.getId());
printFileSpec(fileSpec);
fileSpecs.add(fileSpec);
try {
changelists = server.getChangelists(100, fileSpecs, null, null, false, true, false, true);
if(changelists.isEmpty()) {
System.out.println("Empty Changelists");
} else {
System.out.println("Changelists has " + changelists.size() + " elements");
}
} catch (Exception e) {
e.printStackTrace();
}
With fileSpec.setChangelistId(changelist.getId()); I only can set that it will give me the Changelists before the Changelist (Which is similar to the command: p4 changes -L BRANCHNAME@CHANGELISTID that's also exact how my fileSpecs looks.
Is there a possibility to set something in the API to achieve this? Or do i have to use some different Methods of the API?
Thanks.
回答1:
Try building your FileSpecs this way:
List<IFileSpec> fileSpecs = FileSpecBuilder.makeFileSpecList(p4Branch + "/...@" + changelist.getId() + ",#head");
来源:https://stackoverflow.com/questions/30534297/how-can-i-get-all-changelists-of-a-branch-since-a-specific-changelist