BatchUpdate: Don't update change if there was nothing to do

Committing the transaction and indexing the change can be expensive,
so allow ops to skip that if they did nothing. Similar to how
updateRepo can be a no-op if no commands were added, except we don't
communicate this through the context and instead through a return
value. This is distinct from the insert/save/deleteChange methods on
ChangeContext, which refer specifically to the Change entity; a method
could update a non-Change entity and return true without calling
saveChange.

Change-Id: Id51eec8f9dfa35c80f062a365195f25777f60006
This commit is contained in:
Dave Borowitz
2016-01-20 13:44:48 -05:00
parent 3da50441d9
commit c4365ffe8b
19 changed files with 65 additions and 41 deletions

View File

@@ -1810,8 +1810,9 @@ public class ReceiveCommits {
changeId,
new BatchUpdate.Op() {
@Override
public void updateChange(ChangeContext ctx) throws Exception {
public boolean updateChange(ChangeContext ctx) {
ctx.getUpdate(psId).setTopic(magicBranch.topic);
return true;
}
});
}