ChangeSet, MergeOp: Ease up change set calculation
In MergeOp we need a list of ChangeData for a target branch. This can be directly extracted from the ChangeSet instead of using a list of change ids and reconstructing ChangeData from it using a changeDataFactory. Change-Id: I0d7f682016da5a19cf7f46230db67851f64fdd00
This commit is contained in:
@@ -91,12 +91,12 @@ public class ChangeSet {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Multimap<Branch.NameKey, Change.Id> changesByBranch()
|
||||
public Multimap<Branch.NameKey, ChangeData> changesByBranch()
|
||||
throws OrmException {
|
||||
ListMultimap<Branch.NameKey, Change.Id> ret =
|
||||
ListMultimap<Branch.NameKey, ChangeData> ret =
|
||||
ArrayListMultimap.create();
|
||||
for (ChangeData cd : changeData) {
|
||||
ret.put(cd.change().getDest(), cd.getId());
|
||||
ret.put(cd.change().getDest(), cd);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -394,18 +394,14 @@ public class MergeOp {
|
||||
logDebug("Perform the merges");
|
||||
try {
|
||||
Multimap<Project.NameKey, Branch.NameKey> br = cs.branchesByProject();
|
||||
Multimap<Branch.NameKey, Change.Id> cbb = cs.changesByBranch();
|
||||
Multimap<Branch.NameKey, ChangeData> cbb = cs.changesByBranch();
|
||||
for (Project.NameKey project : br.keySet()) {
|
||||
openRepository(project);
|
||||
for (Branch.NameKey branch : br.get(project)) {
|
||||
setDestProject(branch);
|
||||
|
||||
List<ChangeData> cds = new ArrayList<>();
|
||||
for (Change.Id id : cbb.get(branch)) {
|
||||
cds.add(changeDataFactory.create(db, id));
|
||||
}
|
||||
ListMultimap<SubmitType, ChangeData> submitting =
|
||||
validateChangeList(cds);
|
||||
validateChangeList(cbb.get(branch));
|
||||
toSubmit.put(branch, submitting);
|
||||
|
||||
Set<SubmitType> submitTypes = new HashSet<>(submitting.keySet());
|
||||
@@ -586,7 +582,7 @@ public class MergeOp {
|
||||
}
|
||||
|
||||
private ListMultimap<SubmitType, ChangeData> validateChangeList(
|
||||
List<ChangeData> submitted) throws MergeException {
|
||||
Collection<ChangeData> submitted) throws MergeException {
|
||||
logDebug("Validating {} changes", submitted.size());
|
||||
ListMultimap<SubmitType, ChangeData> toSubmit = ArrayListMultimap.create();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user