MergeOp: Order keys in problems multimap by ID

We return a descriptive exception message including problems for
multiple changes, of the form:

  Failed to submit N changes due to the following problems:
  Change C1: problem for one change
  Change C2: problem for another change
  Change C2: problem for a third change

It looks odd if the component changes are in an arbitrary order based
on the implementation detail order that they were checked in. Just
sort by ID so they're incrementing.

Change-Id: Iff34c4895c2c4f82ca7d2b1e9b75d55da1abe668
This commit is contained in:
Dave Borowitz
2016-01-11 11:04:46 -05:00
parent 34e3763e20
commit 674a0bce1f

View File

@@ -31,6 +31,7 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;
import com.google.common.collect.Table;
import com.google.common.hash.Hasher;
@@ -286,7 +287,13 @@ public class MergeOp implements AutoCloseable {
commits = new HashMap<>();
openRepos = new HashMap<>();
problems = MultimapBuilder.linkedHashKeys().arrayListValues(1).build();
problems = MultimapBuilder.treeKeys(
Ordering.natural().onResultOf(new Function<Change.Id, Integer>() {
@Override
public Integer apply(Change.Id in) {
return in.get();
}
})).arrayListValues(1).build();
}
private OpenRepo openRepo(Project.NameKey project)