Package com.google.gerrit.server.edit
Class ChangeEditModifier
- java.lang.Object
-
- com.google.gerrit.server.edit.ChangeEditModifier
-
public class ChangeEditModifier extends Object
Utility functions to manipulate change edits.This class contains methods to modify edit's content. For retrieving, publishing and deleting edit see
ChangeEditUtil
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChangeEdit
combineWithModifiedPatchSetTree(org.eclipse.jgit.lib.Repository repository, ChangeNotes notes, PatchSet patchSet, List<TreeModification> treeModifications)
Applies the indicated modifications to the specified patch set.void
createEdit(org.eclipse.jgit.lib.Repository repository, ChangeNotes notes)
Creates a new change edit.void
deleteFile(org.eclipse.jgit.lib.Repository repository, ChangeNotes notes, String file)
Deletes a file from the Git tree of a change edit.void
modifyFile(org.eclipse.jgit.lib.Repository repository, ChangeNotes notes, String filePath, RawInput newContent)
Modifies the contents of a file of a change edit.void
modifyMessage(org.eclipse.jgit.lib.Repository repository, Project.NameKey project, ChangeNotes notes, String newCommitMessage)
Modifies the commit message of a change edit.void
rebaseEdit(org.eclipse.jgit.lib.Repository repository, ChangeNotes notes)
Rebase change edit on latest patch setvoid
renameFile(org.eclipse.jgit.lib.Repository repository, ChangeNotes notes, String currentFilePath, String newFilePath)
Renames a file of a change edit or moves it to another directory.void
restoreFile(org.eclipse.jgit.lib.Repository repository, ChangeNotes notes, String file)
Restores a file of a change edit to the state it was in before the patch set on which the change edit is based.
-
-
-
Method Detail
-
createEdit
public void createEdit(org.eclipse.jgit.lib.Repository repository, ChangeNotes notes) throws AuthException, IOException, InvalidChangeOperationException, PermissionBackendException, ResourceConflictException
Creates a new change edit.- Parameters:
repository
- the affected Git repositorynotes
- theChangeNotes
of the change for which the change edit should be created- Throws:
AuthException
- if the user isn't authenticated or not allowed to use change editsInvalidChangeOperationException
- if a change edit already existed for the changePermissionBackendException
IOException
ResourceConflictException
-
rebaseEdit
public void rebaseEdit(org.eclipse.jgit.lib.Repository repository, ChangeNotes notes) throws AuthException, InvalidChangeOperationException, IOException, MergeConflictException, PermissionBackendException, ResourceConflictException
Rebase change edit on latest patch set- Parameters:
repository
- the affected Git repositorynotes
- theChangeNotes
of the change whose change edit should be rebased- Throws:
AuthException
- if the user isn't authenticated or not allowed to use change editsInvalidChangeOperationException
- if a change edit doesn't exist for the specified change, the change edit is already based on the latest patch set, or the change represents the root commitMergeConflictException
- if rebase fails due to merge conflictsPermissionBackendException
IOException
ResourceConflictException
-
modifyMessage
public void modifyMessage(org.eclipse.jgit.lib.Repository repository, Project.NameKey project, ChangeNotes notes, String newCommitMessage) throws AuthException, IOException, UnchangedCommitMessageException, PermissionBackendException, BadRequestException, ResourceConflictException
Modifies the commit message of a change edit. If the change edit doesn't exist, a new one will be created based on the current patch set.- Parameters:
repository
- the affected Git repositorynotes
- theChangeNotes
of the change whose change edit's message should be modifiednewCommitMessage
- the new commit message- Throws:
AuthException
- if the user isn't authenticated or not allowed to use change editsUnchangedCommitMessageException
- if the commit message is the same as beforePermissionBackendException
BadRequestException
- if the commit message is malformedIOException
ResourceConflictException
-
modifyFile
public void modifyFile(org.eclipse.jgit.lib.Repository repository, ChangeNotes notes, String filePath, RawInput newContent) throws AuthException, BadRequestException, InvalidChangeOperationException, IOException, PermissionBackendException, ResourceConflictException
Modifies the contents of a file of a change edit. If the change edit doesn't exist, a new one will be created based on the current patch set.- Parameters:
repository
- the affected Git repositorynotes
- theChangeNotes
of the change whose change edit should be modifiedfilePath
- the path of the file whose contents should be modifiednewContent
- the new file content- Throws:
AuthException
- if the user isn't authenticated or not allowed to use change editsBadRequestException
- if the user provided bad input (e.g. invalid file paths)InvalidChangeOperationException
- if the file already had the specified contentPermissionBackendException
ResourceConflictException
- if the project state does not permit the operationIOException
-
deleteFile
public void deleteFile(org.eclipse.jgit.lib.Repository repository, ChangeNotes notes, String file) throws AuthException, BadRequestException, InvalidChangeOperationException, IOException, PermissionBackendException, ResourceConflictException
Deletes a file from the Git tree of a change edit. If the change edit doesn't exist, a new one will be created based on the current patch set.- Parameters:
repository
- the affected Git repositorynotes
- theChangeNotes
of the change whose change edit should be modifiedfile
- path of the file which should be deleted- Throws:
AuthException
- if the user isn't authenticated or not allowed to use change editsBadRequestException
- if the user provided bad input (e.g. invalid file paths)InvalidChangeOperationException
- if the file does not existPermissionBackendException
ResourceConflictException
- if the project state does not permit the operationIOException
-
renameFile
public void renameFile(org.eclipse.jgit.lib.Repository repository, ChangeNotes notes, String currentFilePath, String newFilePath) throws AuthException, BadRequestException, InvalidChangeOperationException, IOException, PermissionBackendException, ResourceConflictException
Renames a file of a change edit or moves it to another directory. If the change edit doesn't exist, a new one will be created based on the current patch set.- Parameters:
repository
- the affected Git repositorynotes
- theChangeNotes
of the change whose change edit should be modifiedcurrentFilePath
- the current path/name of the filenewFilePath
- the desired path/name of the file- Throws:
AuthException
- if the user isn't authenticated or not allowed to use change editsBadRequestException
- if the user provided bad input (e.g. invalid file paths)InvalidChangeOperationException
- if the file was already renamed to the specified new namePermissionBackendException
ResourceConflictException
- if the project state does not permit the operationIOException
-
restoreFile
public void restoreFile(org.eclipse.jgit.lib.Repository repository, ChangeNotes notes, String file) throws AuthException, BadRequestException, InvalidChangeOperationException, IOException, PermissionBackendException, ResourceConflictException
Restores a file of a change edit to the state it was in before the patch set on which the change edit is based. If the change edit doesn't exist, a new one will be created based on the current patch set.- Parameters:
repository
- the affected Git repositorynotes
- theChangeNotes
of the change whose change edit should be modifiedfile
- the path of the file which should be restored- Throws:
AuthException
- if the user isn't authenticated or not allowed to use change editsInvalidChangeOperationException
- if the file was already restoredPermissionBackendException
BadRequestException
IOException
ResourceConflictException
-
combineWithModifiedPatchSetTree
public ChangeEdit combineWithModifiedPatchSetTree(org.eclipse.jgit.lib.Repository repository, ChangeNotes notes, PatchSet patchSet, List<TreeModification> treeModifications) throws AuthException, BadRequestException, IOException, InvalidChangeOperationException, MergeConflictException, PermissionBackendException, ResourceConflictException
Applies the indicated modifications to the specified patch set. If a change edit exists and is based on the same patch set, the modified patch set tree is merged with the change edit. If the change edit doesn't exist, a new one will be created.- Parameters:
repository
- the affected Git repositorynotes
- theChangeNotes
of the change to which the patch set belongspatchSet
- thePatchSet
which should be modifiedtreeModifications
- the modifications which should be applied- Returns:
- the resulting
ChangeEdit
- Throws:
AuthException
- if the user isn't authenticated or not allowed to use change editsInvalidChangeOperationException
- if the existing change edit is based on another patch set or no change edit exists but the specified patch set isn't the current oneMergeConflictException
- if the modified patch set tree can't be merged with an existing change editBadRequestException
IOException
PermissionBackendException
ResourceConflictException
-
-