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

@@ -506,9 +506,8 @@ class ChangeNotesParser {
"Multiple revisions parsed for patch set %s: %s and %s",
psId.get(), patchSets.get(psId).getCommitId().name(), rev.name()));
}
PatchSet ps = new PatchSet(psId);
PatchSet ps = new PatchSet(psId, rev);
patchSets.put(psId, ps);
ps.setCommitId(rev);
ps.setUploader(accountId);
ps.setCreatedOn(ts);
PendingPatchSetFields pending = pendingPatchSets.remove(psId);