Fix merging change by direct push

When a commit is pushed, Gerrit will auto close the corresponding change
if there is one. To do so, it will query all the open changes on the
same branch, iterate through them to find a change with same change-id
as the one in the pushed commit. During the iteration, the changes are
loaded from DB. If any of the open changes is deleted between the time
the query is executed and the time the change is loaded from DB, a
NoSuchChangeException was thrown preventing the auto close operation
from completing. The net result was commit merged in the repository but
its corresponding change status not transitioned to merged.

Change-Id: I2735686455eae3575fdeea74143a6cdd5ccff91e
This commit is contained in:
Hugo Arès
2017-12-20 11:35:17 -05:00
parent 46bb5c7a2c
commit b046129965

View File

@@ -2882,7 +2882,11 @@ public class ReceiveCommits {
throws OrmException {
Map<Change.Key, ChangeNotes> r = new HashMap<>();
for (ChangeData cd : queryProvider.get().byBranchOpen(branch)) {
r.put(cd.change().getKey(), cd.notes());
try {
r.put(cd.change().getKey(), cd.notes());
} catch (NoSuchChangeException e) {
//Ignore deleted change
}
}
return r;
}