Pass RevWalk to PatchSetInfoFactory

Previously #get(RevCommit, PatchSet.Id) would NPE if the body of the
commit was not parsed; callers needed to remember to either parse the
body or ensure that the RevWalk that created the commit had
setRetainBody(true). In all cases, there is already a handy RevWalk;
pass this into get and do the parseBody there, such that it's
impossible for the caller to forget. (In the BatchUpdate.Op cases, we
need to shuffle call order around a bit so the PatchSetInfo gets
populated during updateRepo.)

Change-Id: I2e42ed1cc5c4a50958b6367051065e6bbad5cc54
This commit is contained in:
Dave Borowitz
2015-10-14 15:12:43 -04:00
parent 8408244c21
commit b9805aee6d
7 changed files with 28 additions and 20 deletions

View File

@@ -2102,7 +2102,7 @@ public class ReceiveCommits {
newPatchSet.getId()));
}
private void newPatchSet() {
private void newPatchSet() throws IOException {
PatchSet.Id id =
ChangeUtil.nextPatchSetId(allRefs, change.currentPatchSetId());
newPatchSet = new PatchSet(id);
@@ -2117,7 +2117,8 @@ public class ReceiveCommits {
if (magicBranch != null && magicBranch.draft) {
newPatchSet.setDraft(true);
}
info = patchSetInfoFactory.get(newCommit, newPatchSet.getId());
info = patchSetInfoFactory.get(
rp.getRevWalk(), newCommit, newPatchSet.getId());
cmd = new ReceiveCommand(
ObjectId.zeroId(),
newCommit,
@@ -2698,7 +2699,7 @@ public class ReceiveCommits {
result.change = change;
result.changeCtl = projectControl.controlFor(change);
result.newPatchSet = ps;
result.info = patchSetInfoFactory.get(commit, psi);
result.info = patchSetInfoFactory.get(rp.getRevWalk(), commit, psi);
result.mergedIntoRef = refName;
markChangeMergedByPush(db, result, result.changeCtl);
hooks.doChangeMergedHook(