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:
@@ -21,6 +21,7 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetAncestor;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetInfo;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.ChangeUtil;
|
||||
@@ -134,6 +135,7 @@ public class CherryPick extends SubmitStrategy {
|
||||
|
||||
private PatchSet.Id psId;
|
||||
private CodeReviewCommit newCommit;
|
||||
private PatchSetInfo patchSetInfo;
|
||||
|
||||
private CherryPickOneOp(MergeTip mergeTip, CodeReviewCommit n) {
|
||||
this.mergeTip = mergeTip;
|
||||
@@ -159,6 +161,8 @@ public class CherryPick extends SubmitStrategy {
|
||||
committer, cherryPickCmtMsg, args.rw);
|
||||
ctx.addRefUpdate(
|
||||
new ReceiveCommand(ObjectId.zeroId(), newCommit, psId.toRefName()));
|
||||
patchSetInfo =
|
||||
patchSetInfoFactory.get(ctx.getRevWalk(), newCommit, psId);
|
||||
} catch (MergeConflictException mce) {
|
||||
// Keep going in the case of a single merge failure; the goal is to
|
||||
// cherry-pick as many commits as possible.
|
||||
@@ -184,7 +188,7 @@ public class CherryPick extends SubmitStrategy {
|
||||
ps.setGroups(GroupCollector.getCurrentGroups(args.db, c));
|
||||
args.db.patchSets().insert(Collections.singleton(ps));
|
||||
insertAncestors(args.db, ps.getId(), newCommit);
|
||||
c.setCurrentPatchSet(patchSetInfoFactory.get(newCommit, ps.getId()));
|
||||
c.setCurrentPatchSet(patchSetInfo);
|
||||
args.db.changes().update(Collections.singletonList(c));
|
||||
|
||||
List<PatchSetApproval> approvals = Lists.newArrayList();
|
||||
|
@@ -104,7 +104,7 @@ public class RebaseIfNecessary extends SubmitStrategy {
|
||||
ObjectId.fromString(newPatchSet.getRevision().get()));
|
||||
mergeTip.moveTipTo(newTip, newTip);
|
||||
n.change().setCurrentPatchSet(
|
||||
patchSetInfoFactory.get(mergeTip.getCurrentTip(),
|
||||
patchSetInfoFactory.get(args.rw, mergeTip.getCurrentTip(),
|
||||
newPatchSet.getId()));
|
||||
mergeTip.getCurrentTip().copyFrom(n);
|
||||
mergeTip.getCurrentTip().setControl(
|
||||
|
Reference in New Issue
Block a user