Notedb: Unify subject and patch set handling

When inserting patch sets, pass in a RevWalk along with the commit
SHA-1 so we can ensure the body is parsed. Set the subject implicitly
when we add a new patch set; always do this, even if the subject
matches the previous subject.

When parsing patch sets, we have to still parse the subject separately
from the patch set, since there is no subject field on PatchSet. But
we can use a single setter on Change to set the current patch set ID,
subject, and original subject together as a batch, rather than going
through PatchSetInfo.

Change-Id: If37c4990e2e5888d5e87bd5c34a821e59186ab6d
This commit is contained in:
Dave Borowitz
2016-01-22 11:31:38 -05:00
parent 79419f4b39
commit 5dd9c1ac98
15 changed files with 158 additions and 123 deletions

View File

@@ -563,18 +563,10 @@ public final class Change {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getOriginalSubject() {
return originalSubject != null ? originalSubject : subject;
}
public void setOriginalSubject(String originalSubject) {
this.originalSubject = originalSubject;
}
/** Get the id of the most current {@link PatchSet} in this change. */
public PatchSet.Id currentPatchSetId() {
if (currentPatchSetId > 0) {
@@ -600,6 +592,23 @@ public final class Change {
}
}
public void setCurrentPatchSet(PatchSet.Id psId, String subject,
String originalSubject) {
if (!psId.getParentKey().equals(changeId)) {
throw new IllegalArgumentException(
"patch set ID " + psId + " is not for change " + changeId);
}
currentPatchSetId = psId.get();
this.subject = subject;
this.originalSubject = originalSubject;
}
public void clearCurrentPatchSet() {
currentPatchSetId = 0;
subject = null;
originalSubject = null;
}
public String getSubmissionId() {
return submissionId;
}