Use repo from BatchUpdate.Context directly more often

Avoid some ugly indirection where we do nothing in the updateRepo
phase but read something from the repo for use in updateChange.

Change-Id: Ibc646fc9b0e0dfb5e9f956b1919f7d7670ba0d74
This commit is contained in:
Dave Borowitz
2015-12-10 14:25:30 -05:00
parent 7517c70825
commit 8a1cef198a
4 changed files with 22 additions and 29 deletions

View File

@@ -84,7 +84,6 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
private final RefControl refControl;
private final IdentifiedUser user;
private final Change change;
private final PatchSet patchSet;
private final RevCommit commit;
@@ -101,6 +100,7 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
private boolean updateRef;
// Fields set during the insertion process.
private Change change;
private ChangeMessage changeMessage;
private PatchSetInfo patchSetInfo;
@@ -230,9 +230,6 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
public void updateRepo(RepoContext ctx)
throws ResourceConflictException, IOException {
validate(ctx);
patchSetInfo = patchSetInfoFactory.get(
ctx.getRevWalk(), commit, patchSet.getId());
change.setCurrentPatchSet(patchSetInfo);
if (!updateRef) {
return;
}
@@ -242,9 +239,14 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
@Override
public void updateChange(ChangeContext ctx) throws OrmException, IOException {
change = ctx.getChange(); // Use defensive copy created by ChangeControl.
ReviewDb db = ctx.getDb();
ChangeControl ctl = ctx.getChangeControl();
ChangeUpdate update = ctx.getChangeUpdate();
patchSetInfo = patchSetInfoFactory.get(
ctx.getRevWalk(), commit, patchSet.getId());
ctx.getChange().setCurrentPatchSet(patchSetInfo);
if (patchSet.getGroups() == null) {
patchSet.setGroups(GroupCollector.getDefaultGroups(patchSet));
}