Package com.google.gerrit.server.notedb
Class ChangeUpdate
- java.lang.Object
-
- com.google.gerrit.server.notedb.AbstractChangeUpdate
-
- com.google.gerrit.server.notedb.ChangeUpdate
-
public class ChangeUpdate extends AbstractChangeUpdate
A delta to apply to a change.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ChangeUpdate.Factory
-
Field Summary
-
Fields inherited from class com.google.gerrit.server.notedb.AbstractChangeUpdate
accountId, authorIdent, noteUtil, psId, realAccountId, serverIdent, when
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToPlannedAttentionSetUpdates(AttentionSetUpdate update)
void
addToPlannedAttentionSetUpdates(Set<AttentionSetUpdate> updates)
All updates must have a timestamp of null since we use the commit's timestamp.boolean
allowWriteToNewRef()
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
bypassMaxUpdates()
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
deleteComment(HumanComment c)
void
deleteCommentByRewritingHistory(String uuid, String newMessage)
void
fixStatusToMerged(SubmissionId submissionId)
protected Project.NameKey
getProjectName()
protected String
getRefName()
Map<Account.Id,ReviewerStateInternal>
getReviewers()
void
ignoreFurtherAttentionSetUpdates()
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
putReviewer(Account.Id reviewer, ReviewerStateInternal type)
void
putReviewerByEmail(Address reviewer, ReviewerStateInternal type)
void
putRobotComment(RobotComment c)
void
removeApprovalFor(Account.Id reviewer, String label)
void
removeAssignee()
void
removeReviewer(Account.Id reviewer)
void
removeReviewerByEmail(Address reviewer)
void
setAllowWriteToNewRef(boolean allow)
void
setAssignee(Account.Id assignee)
void
setBranch(String branch)
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
setCommit(org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectId id, String pushCert)
void
setCurrentPatchSet()
void
setGroups(List<String> groups)
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
setTag(String tag)
void
setTopic(String topic)
void
setWorkInProgress(boolean workInProgress)
-
Methods inherited from class com.google.gerrit.server.notedb.AbstractChangeUpdate
getAccountId, getChange, getId, getNotes, getNullableAccountId, getPatchSetId, getWhen, setParentCommit, setPatchSetId
-
-
-
-
Method Detail
-
commit
public org.eclipse.jgit.lib.ObjectId commit() throws IOException
- Throws:
IOException
-
setChangeId
public void setChangeId(String changeId)
-
setBranch
public void setBranch(String branch)
-
setStatus
public void setStatus(Change.Status status)
-
fixStatusToMerged
public void fixStatusToMerged(SubmissionId submissionId)
-
putApproval
public void putApproval(String label, short value)
-
putApprovalFor
public void putApprovalFor(Account.Id reviewer, String label, short value)
-
removeApprovalFor
public void removeApprovalFor(Account.Id reviewer, String label)
-
merge
public void merge(SubmissionId submissionId, Iterable<SubmitRecord> submitRecords)
-
setSubjectForCommit
public void setSubjectForCommit(String commitSubject)
-
setSubject
public void setSubject(String subject)
-
setChangeMessage
public void setChangeMessage(String changeMessage)
-
setTag
public void setTag(String tag)
-
setPsDescription
public void setPsDescription(String psDescription)
-
putComment
public void putComment(Comment.Status status, HumanComment c)
-
putRobotComment
public void putRobotComment(RobotComment c)
-
deleteComment
public void deleteComment(HumanComment c)
-
deleteCommentByRewritingHistory
public void deleteCommentByRewritingHistory(String uuid, String newMessage)
-
deleteChangeMessageByRewritingHistory
public void deleteChangeMessageByRewritingHistory(String targetMessageId, String newMessage)
-
setTopic
public void setTopic(String topic) throws ValidationException
- 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
-
addToPlannedAttentionSetUpdates
public void addToPlannedAttentionSetUpdates(Set<AttentionSetUpdate> updates)
All updates must have a timestamp of null since we use the commit's timestamp. There also must not be multiple updates for a single user. Only the first update takes place because of the different priorities: e.g, if we want to add someone to the attention set but also want to remove someone from the attention set, we should ensure to add/remove that user based on the priority of the addition and removal. If most importantly we want to remove the user, then we must first create the removal, and the addition will not take effect.
-
addToPlannedAttentionSetUpdates
public void addToPlannedAttentionSetUpdates(AttentionSetUpdate update)
-
setAssignee
public void setAssignee(Account.Id assignee)
-
removeAssignee
public void removeAssignee()
-
getReviewers
public Map<Account.Id,ReviewerStateInternal> getReviewers()
-
putReviewer
public void putReviewer(Account.Id reviewer, ReviewerStateInternal type)
-
removeReviewer
public void removeReviewer(Account.Id reviewer)
-
putReviewerByEmail
public void putReviewerByEmail(Address reviewer, ReviewerStateInternal type)
-
removeReviewerByEmail
public void removeReviewerByEmail(Address reviewer)
-
setPatchSetState
public void setPatchSetState(PatchSetState psState)
-
setCurrentPatchSet
public void setCurrentPatchSet()
-
setRevertOf
public void setRevertOf(int revertOf)
-
setCherryPickOf
public void setCherryPickOf(String cherryPickOf)
-
getRefName
protected String 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
protected Project.NameKey getProjectName()
- Specified by:
getProjectName
in classAbstractChangeUpdate
- Returns:
- the NameKey for the project where the update will be stored, which is not necessarily the same as the change's project.
-
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)
-
-