How can i get all Changelists of a branch since a specific Changelist?

霸气de小男生 提交于 2019-12-08 03:12:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!