@Test public void byCommitsOnBranchNotMerged() throws Exception { TestRepository<Repo> repo = createProject("repo"); int n = 10; List<String> shas = new ArrayList<>(n); List<Integer> expectedIds = new ArrayList<>(n); Branch.NameKey dest = null; for (int i = 0; i < n; i++) { ChangeInserter ins = newChange(repo, null, null, null, null); ins.insert(); if (dest == null) { dest = ins.getChange().getDest(); } shas.add(ins.getPatchSet().getRevision().get()); expectedIds.add(ins.getChange().getId().get()); } for (int i = 1; i <= 11; i++) { Iterable<ChangeData> cds = internalChangeQuery.byCommitsOnBranchNotMerged( indexes.getSearchIndex().getSchema(), dest, shas, i); Iterable<Integer> ids = FluentIterable.from(cds) .transform( new Function<ChangeData, Integer>() { @Override public Integer apply(ChangeData in) { return in.getId().get(); } }); String name = "batch size " + i; assertThat(ids).named(name).hasSize(n); assertThat(ids).named(name).containsExactlyElementsIn(expectedIds); } }
private void abandonAllOpenChanges(Project.NameKey destProject) throws NoSuchChangeException { try { for (ChangeData cd : internalChangeQuery.byProjectOpen(destProject)) { abandonOneChange(cd.change()); } } catch (IOException | OrmException e) { logWarn("Cannot abandon changes for deleted project ", e); } }