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, NO_OP_UPDATE, noteUtil, psId, realAccountId, rootOnly, serverIdent, when
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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(Comment c)
void
deleteCommentByRewritingHistory(String uuid, String newMessage)
void
fixStatus(Change.Status status)
DeleteChangeMessageRewriter
getDeleteChangeMessageRewriter()
DeleteCommentRewriter
getDeleteCommentRewriter()
protected Project.NameKey
getProjectName()
protected String
getRefName()
Map<Account.Id,ReviewerStateInternal>
getReviewers()
boolean
isEmpty()
Whether no updates have been done.void
merge(com.google.gerrit.server.logging.RequestId submissionId, Iterable<SubmitRecord> submitRecords)
void
putApproval(String label, short value)
void
putApprovalFor(Account.Id reviewer, String label, short value)
void
putComment(Comment.Status status, Comment c)
void
putReviewer(Account.Id reviewer, ReviewerStateInternal type)
void
putReviewerByEmail(com.google.gerrit.mail.Address reviewer, ReviewerStateInternal type)
void
putRobotComment(RobotComment c)
void
removeApproval(String label)
void
removeApprovalFor(Account.Id reviewer, String label)
void
removeAssignee()
void
removeReviewer(Account.Id reviewer)
void
removeReviewerByEmail(com.google.gerrit.mail.Address reviewer)
void
setAllowWriteToNewRef(boolean allow)
void
setAssignee(Account.Id assignee)
void
setBranch(String branch)
void
setChangeId(String changeId)
void
setChangeMessage(String changeMessage)
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
setRevisionForMissingCommit(String id, String pushCert)
Set the revision without depending on the commit being present in the repository; should only be used for converting old corrupt commits.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, isRootOnly, newIdent, setParentCommit, setPatchSetId, verifyComment
-
-
-
-
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)
-
fixStatus
public void fixStatus(Change.Status status)
-
putApproval
public void putApproval(String label, short value)
-
putApprovalFor
public void putApprovalFor(Account.Id reviewer, String label, short value)
-
removeApproval
public void removeApproval(String label)
-
removeApprovalFor
public void removeApprovalFor(Account.Id reviewer, String label)
-
merge
public void merge(com.google.gerrit.server.logging.RequestId 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, Comment c)
-
putRobotComment
public void putRobotComment(RobotComment c)
-
deleteComment
public void deleteComment(Comment c)
-
deleteCommentByRewritingHistory
public void deleteCommentByRewritingHistory(String uuid, String newMessage)
-
deleteChangeMessageByRewritingHistory
public void deleteChangeMessageByRewritingHistory(String targetMessageId, String newMessage)
-
setTopic
public void setTopic(String topic)
-
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
-
setRevisionForMissingCommit
public void setRevisionForMissingCommit(String id, String pushCert)
Set the revision without depending on the commit being present in the repository; should only be used for converting old corrupt commits.
-
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(com.google.gerrit.mail.Address reviewer, ReviewerStateInternal type)
-
removeReviewerByEmail
public void removeReviewerByEmail(com.google.gerrit.mail.Address reviewer)
-
setPatchSetState
public void setPatchSetState(PatchSetState psState)
-
setCurrentPatchSet
public void setCurrentPatchSet()
-
setRevertOf
public void setRevertOf(int revertOf)
-
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.
-
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
-
getDeleteCommentRewriter
public DeleteCommentRewriter getDeleteCommentRewriter()
-
getDeleteChangeMessageRewriter
public DeleteChangeMessageRewriter getDeleteChangeMessageRewriter()
-
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)
-
-