Class ChangeUpdate
This delta will become two unique commits: one in the AllUsers repo that will contain the draft comments on this change and one in the notes branch that will contain approvals, reviewers, change status, subject, submit records, the change message, and published comments. There are limitations on the set of modifications that can be handled in a single update. In particular, there is a single author and timestamp for each update.
This class is not thread-safe.
NOTE: This class also serializes the change in a custom storage format, used in NoteDB. All
changes to the storage format must be both forward and backward compatible, see comment on ChangeNotesParser
.
Such changes include e.g. introducing/removing footers, modifying footer formats, mutations of
the attached ChangeRevisionNote
.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
Fields inherited from class com.google.gerrit.server.notedb.AbstractChangeUpdate
accountId, authorIdent, noteUtil, psId, realAccountId, serverIdent, when
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCustomKeyedValue
(String key, String value) void
void
Adds attention set updates that should be stored in NoteDb.boolean
protected org.eclipse.jgit.lib.CommitBuilder
applyImpl
(org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectInserter ins, org.eclipse.jgit.lib.ObjectId curr) Create a commit containing the contents of this update.protected boolean
Whether to allow bypassing the check that an update does not exceed the max update count on an object.org.eclipse.jgit.lib.ObjectId
commit()
void
deleteChangeMessageByRewritingHistory
(String targetMessageId, String newMessage) void
void
deleteCommentByRewritingHistory
(String uuid, String newMessage) void
void
fixStatusToMerged
(SubmissionId submissionId) com.google.common.collect.ImmutableTable<String,
Account.Id, Optional<PatchSetApproval>> com.google.common.collect.ImmutableList<AttentionSetUpdate>
protected Project.NameKey
Returns the NameKey for the project where the update will be stored, which is not necessarily the same as the change's project.protected String
void
When set, default attention set rules are ignored (E.g, adding reviewers -> adds to attention set, etc).boolean
isEmpty()
Whether no updates have been done.void
merge
(SubmissionId submissionId, Iterable<SubmitRecord> submitRecords) void
putApproval
(String label, short value) void
putApprovalFor
(Account.Id reviewer, String label, short value) void
putComment
(Comment.Status status, HumanComment c) void
putCopiedApproval
(PatchSetApproval copiedPatchSetApproval) We expect thecopied
flag ofcopiedPatchSetApproval
to be set, since this method is only meant for copied approvals.void
putReviewer
(Account.Id reviewer, ReviewerStateInternal type) void
putReviewerByEmail
(Address reviewer, ReviewerStateInternal type) void
void
void
removeApprovalFor
(Account.Id reviewer, String label) void
removeCopiedApprovalFor
(Account.Id realUserId, Account.Id reviewerId, String label) void
removeReviewer
(Account.Id reviewer) void
removeReviewerByEmail
(Address reviewer) void
void
setAllowWriteToNewRef
(boolean allow) void
void
setChangeId
(String changeId) void
setChangeMessage
(String changeMessage) void
setCherryPickOf
(String cherryPickOf) void
setCommit
(org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectId id) void
void
void
void
setHashtags
(Set<String> hashtags) void
setPatchSetState
(PatchSetState psState) void
setPrivate
(boolean isPrivate) void
setPsDescription
(String psDescription) void
setRevertOf
(int revertOf) void
setStatus
(Change.Status status) void
setSubject
(String subject) void
setSubjectForCommit
(String commitSubject) void
void
setTopic
(String topic, TopicValidator validator) void
setWorkInProgress
(boolean workInProgress) Methods inherited from class com.google.gerrit.server.notedb.AbstractChangeUpdate
getAccountId, getChange, getId, getNotes, getNullableAccountId, getPatchSetId, getRealAccountId, getWhen, setParentCommit, setPatchSetId
-
Field Details
-
MAX_CUSTOM_KEY_LENGTH
public static final int MAX_CUSTOM_KEY_LENGTH- See Also:
-
MAX_CUSTOM_KEYED_VALUE_LENGTH
public static final int MAX_CUSTOM_KEYED_VALUE_LENGTH- See Also:
-
MAX_CUSTOM_KEYED_VALUES
public static final int MAX_CUSTOM_KEYED_VALUES- See Also:
-
-
Method Details
-
commit
- Throws:
IOException
-
setChangeId
-
setBranch
-
setStatus
-
fixStatusToMerged
-
putApproval
-
putApprovalFor
-
getApprovals
public com.google.common.collect.ImmutableTable<String,Account.Id, getApprovals()Optional<PatchSetApproval>> -
removeApprovalFor
-
putCopiedApproval
We expect thecopied
flag ofcopiedPatchSetApproval
to be set, since this method is only meant for copied approvals. -
removeCopiedApprovalFor
-
merge
-
setSubjectForCommit
-
setSubject
-
setChangeMessage
-
setTag
-
setPsDescription
-
putSubmitRequirementResults
-
putComment
-
putRobotComment
-
deleteComment
-
deleteCommentByRewritingHistory
-
deleteChangeMessageByRewritingHistory
-
setTopic
- Throws:
ValidationException
-
setCommit
public void setCommit(org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectId id) throws IOException - Throws:
IOException
-
setCommit
public void setCommit(org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectId id, String pushCert) throws IOException - Throws:
IOException
-
setHashtags
-
addCustomKeyedValue
- Throws:
ValidationException
-
deleteCustomKeyedValue
- Throws:
ValidationException
-
addToPlannedAttentionSetUpdates
Adds attention set updates that should be stored in NoteDb.If invoked multiple times with attention set updates for the same user, only the attention set update of the first invocation is stored for this user and further attention set updates for this user are silently ignored. This means if callers invoke this method multiple times with attention set updates for the same user, they must ensure that the first call is being done with the attention set update that should take precedence.
- Parameters:
updates
- Attention set updates that should be performed. The updates must not have any timestamp set (AttentionSetUpdate.timestamp()
must returnnull
). This is because the timestamp of all performed updates is always the timestamp of when the NoteDb commit is created. Each of the provided updates must be for a different user, if there are multiple updates for the same user the update is rejected.- Throws:
IllegalArgumentException
- thrown if any of the provided updates has a timestamp set, or if the provided set of updates contains multiple updates for the same user
-
addToPlannedAttentionSetUpdates
-
getAttentionSetUpdates
-
getReviewers
-
putReviewer
-
removeReviewer
-
putReviewerByEmail
-
removeReviewerByEmail
-
setPatchSetState
-
setCurrentPatchSet
public void setCurrentPatchSet() -
setGroups
-
setRevertOf
public void setRevertOf(int revertOf) -
setCherryPickOf
-
resetCherryPickOf
public void resetCherryPickOf() -
getRefName
- Specified by:
getRefName
in classAbstractChangeUpdate
-
bypassMaxUpdates
protected boolean bypassMaxUpdates()Description copied from class:AbstractChangeUpdate
Whether to allow bypassing the check that an update does not exceed the max update count on an object.- Overrides:
bypassMaxUpdates
in classAbstractChangeUpdate
-
applyImpl
protected org.eclipse.jgit.lib.CommitBuilder applyImpl(org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectInserter ins, org.eclipse.jgit.lib.ObjectId curr) throws IOException Description copied from class:AbstractChangeUpdate
Create a commit containing the contents of this update.- Specified by:
applyImpl
in classAbstractChangeUpdate
ins
- inserter to write to; callers should not flush.- Returns:
- a new commit builder representing this commit, or null to indicate the meta ref should
be deleted as a result of this update. The parent, author, and committer fields in the
return value are always overwritten. The tree ID may be unset by this method, which
indicates to the caller that it should be copied from the parent commit. To indicate that
this update is a no-op (but this could not be determined by
AbstractChangeUpdate.isEmpty()
), return the sentinelAbstractChangeUpdate.NO_OP_UPDATE
. - Throws:
IOException
- if a lower-level error occurred.
-
ignoreFurtherAttentionSetUpdates
public void ignoreFurtherAttentionSetUpdates()When set, default attention set rules are ignored (E.g, adding reviewers -> adds to attention set, etc). -
getProjectName
Description copied from class:AbstractChangeUpdate
Returns the NameKey for the project where the update will be stored, which is not necessarily the same as the change's project.- Specified by:
getProjectName
in classAbstractChangeUpdate
-
isEmpty
public boolean isEmpty()Description copied from class:AbstractChangeUpdate
Whether no updates have been done.- Specified by:
isEmpty
in classAbstractChangeUpdate
-
setAllowWriteToNewRef
public void setAllowWriteToNewRef(boolean allow) -
allowWriteToNewRef
public boolean allowWriteToNewRef()- Overrides:
allowWriteToNewRef
in classAbstractChangeUpdate
-
setPrivate
public void setPrivate(boolean isPrivate) -
setWorkInProgress
public void setWorkInProgress(boolean workInProgress)
-