PatchSet: Disallow null commitId

This field has been nullable since the very beginning (I74ef9f34), but
honestly I have no idea why. Certainly the vast majority of callers
today assume that it's not null.

Force callers to provide a non-null commitId at construction time, and
disallow mutating it later. There was one stubborn caller in
PatchScriptFactory which I couldn't get rid of without disentangling the
logic of the whole class, so I punted and left a deprecated ugly named
static factory method just for this one case.

Change-Id: If8253781c101cbe4ed18210ec9ebe78dee8f4add
This commit is contained in:
Dave Borowitz
2019-04-24 13:37:25 -07:00
parent ef40918fb4
commit 03fb740e71
20 changed files with 91 additions and 72 deletions

View File

@@ -68,8 +68,7 @@ public class TestChanges {
}
public static PatchSet newPatchSet(PatchSet.Id id, String revision, Account.Id userId) {
PatchSet ps = new PatchSet(id);
ps.setCommitId(ObjectId.fromString(revision));
PatchSet ps = new PatchSet(id, ObjectId.fromString(revision));
ps.setUploader(userId);
ps.setCreatedOn(TimeUtil.nowTs());
return ps;