Merge "ChangeNotes: Skip missing changes when looking up in bulk"
This commit is contained in:
@@ -251,9 +251,15 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
|||||||
List<ChangeNotes> notes = new ArrayList<>();
|
List<ChangeNotes> notes = new ArrayList<>();
|
||||||
if (args.migration.enabled()) {
|
if (args.migration.enabled()) {
|
||||||
for (Change.Id cid : changeIds) {
|
for (Change.Id cid : changeIds) {
|
||||||
ChangeNotes cn = create(db, project, cid);
|
try {
|
||||||
if (cn.getChange() != null && predicate.test(cn)) {
|
ChangeNotes cn = create(db, project, cid);
|
||||||
notes.add(cn);
|
if (cn.getChange() != null && predicate.test(cn)) {
|
||||||
|
notes.add(cn);
|
||||||
|
}
|
||||||
|
} catch (NoSuchChangeException e) {
|
||||||
|
// Match ReviewDb behavior, returning not found; maybe the caller learned about it from
|
||||||
|
// a dangling patch set ref or something.
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return notes;
|
return notes;
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ import com.google.inject.util.Providers;
|
|||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -115,6 +116,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import org.eclipse.jgit.junit.TestRepository;
|
import org.eclipse.jgit.junit.TestRepository;
|
||||||
import org.eclipse.jgit.lib.Config;
|
import org.eclipse.jgit.lib.Config;
|
||||||
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
import org.eclipse.jgit.lib.ObjectInserter;
|
import org.eclipse.jgit.lib.ObjectInserter;
|
||||||
import org.eclipse.jgit.lib.Ref;
|
import org.eclipse.jgit.lib.Ref;
|
||||||
import org.eclipse.jgit.lib.RefUpdate;
|
import org.eclipse.jgit.lib.RefUpdate;
|
||||||
@@ -1709,9 +1711,28 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void byCommitsOnBranchNotMerged() throws Exception {
|
public void byCommitsOnBranchNotMerged() throws Exception {
|
||||||
|
TestRepository<Repo> tr = createProject("repo");
|
||||||
|
testByCommitsOnBranchNotMerged(tr, ImmutableSet.of());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void byCommitsOnBranchNotMergedSkipsMissingChanges() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
|
ObjectId missing =
|
||||||
|
repo.branch(new PatchSet.Id(new Change.Id(987654), 1).toRefName())
|
||||||
|
.commit()
|
||||||
|
.message("No change for this commit")
|
||||||
|
.insertChangeId()
|
||||||
|
.create()
|
||||||
|
.copy();
|
||||||
|
testByCommitsOnBranchNotMerged(repo, ImmutableSet.of(missing));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testByCommitsOnBranchNotMerged(TestRepository<Repo> repo, Collection<ObjectId> extra)
|
||||||
|
throws Exception {
|
||||||
int n = 10;
|
int n = 10;
|
||||||
List<String> shas = new ArrayList<>(n);
|
List<String> shas = new ArrayList<>(n + extra.size());
|
||||||
|
extra.forEach(i -> shas.add(i.name()));
|
||||||
List<Integer> expectedIds = new ArrayList<>(n);
|
List<Integer> expectedIds = new ArrayList<>(n);
|
||||||
Branch.NameKey dest = null;
|
Branch.NameKey dest = null;
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user