Merge "RelatedChangesSorter#sort: Improve error message"
This commit is contained in:
@@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.change;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
import static java.util.stream.Collectors.toMap;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@@ -76,7 +77,15 @@ class RelatedChangesSorter {
|
|||||||
// Map of all patch sets, keyed by commit SHA-1.
|
// Map of all patch sets, keyed by commit SHA-1.
|
||||||
Map<ObjectId, PatchSetData> byId = collectById(in);
|
Map<ObjectId, PatchSetData> byId = collectById(in);
|
||||||
PatchSetData start = byId.get(startPs.commitId());
|
PatchSetData start = byId.get(startPs.commitId());
|
||||||
checkArgument(start != null, "%s not found in %s", startPs, in);
|
requireNonNull(
|
||||||
|
start,
|
||||||
|
() ->
|
||||||
|
String.format(
|
||||||
|
"commit %s of patch set %s not found in %s",
|
||||||
|
startPs.commitId().name(),
|
||||||
|
startPs.id(),
|
||||||
|
byId.entrySet().stream()
|
||||||
|
.collect(toMap(e -> e.getKey().name(), e -> e.getValue().patchSet().id()))));
|
||||||
|
|
||||||
// Map of patch set -> immediate parent.
|
// Map of patch set -> immediate parent.
|
||||||
ListMultimap<PatchSetData, PatchSetData> parents =
|
ListMultimap<PatchSetData, PatchSetData> parents =
|
||||||
|
|||||||
Reference in New Issue
Block a user