Package org.eclipse.jgit.lib
Class BatchRefUpdate
- java.lang.Object
-
- org.eclipse.jgit.lib.BatchRefUpdate
-
public class BatchRefUpdate extends Object
Batch of reference updates to be applied to a repository.The batch update is primarily useful in the transport code, where a client or server is making changes to more than one reference at a time.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BatchRefUpdate(RefDatabase refdb)
Initialize a new batch update.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BatchRefUpdate
addCommand(Collection<ReceiveCommand> cmd)
Add commands to this batch update.BatchRefUpdate
addCommand(ReceiveCommand cmd)
Add a single command to this batch update.BatchRefUpdate
addCommand(ReceiveCommand... cmd)
Add commands to this batch update.BatchRefUpdate
disableRefLog()
Don't record this update in the ref's associated reflog.void
execute(RevWalk walk, ProgressMonitor monitor)
Execute this batch update.List<ReceiveCommand>
getCommands()
PersonIdent
getRefLogIdent()
String
getRefLogMessage()
Get the message to include in the reflog.boolean
isAllowNonFastForwards()
boolean
isRefLogDisabled()
boolean
isRefLogIncludingResult()
protected RefUpdate
newUpdate(ReceiveCommand cmd)
Create a new RefUpdate copying the batch settings.BatchRefUpdate
setAllowNonFastForwards(boolean allow)
Set if this update wants to permit a forced update.BatchRefUpdate
setRefLogIdent(PersonIdent pi)
Set the identity of the user appearing in the reflog.BatchRefUpdate
setRefLogMessage(String msg, boolean appendStatus)
Set the message to include in the reflog.
-
-
-
Constructor Detail
-
BatchRefUpdate
protected BatchRefUpdate(RefDatabase refdb)
Initialize a new batch update.- Parameters:
refdb
- the reference database of the repository to be updated.
-
-
Method Detail
-
isAllowNonFastForwards
public boolean isAllowNonFastForwards()
- Returns:
- true if the batch update will permit a non-fast-forward update to an existing reference.
-
setAllowNonFastForwards
public BatchRefUpdate setAllowNonFastForwards(boolean allow)
Set if this update wants to permit a forced update.- Parameters:
allow
- true if this update batch should ignore merge tests.- Returns:
this
.
-
getRefLogIdent
public PersonIdent getRefLogIdent()
- Returns:
- identity of the user making the change in the reflog.
-
setRefLogIdent
public BatchRefUpdate setRefLogIdent(PersonIdent pi)
Set the identity of the user appearing in the reflog.The timestamp portion of the identity is ignored. A new identity with the current timestamp will be created automatically when the update occurs and the log record is written.
- Parameters:
pi
- identity of the user. If null the identity will be automatically determined based on the repository configuration.- Returns:
this
.
-
getRefLogMessage
public String getRefLogMessage()
Get the message to include in the reflog.- Returns:
- message the caller wants to include in the reflog; null if the update should not be logged.
-
isRefLogIncludingResult
public boolean isRefLogIncludingResult()
- Returns:
true
if the ref log message should show the result.
-
setRefLogMessage
public BatchRefUpdate setRefLogMessage(String msg, boolean appendStatus)
Set the message to include in the reflog.- Parameters:
msg
- the message to describe this change. It may be null if appendStatus is null in order not to append to the reflogappendStatus
- true if the status of the ref change (fast-forward or forced-update) should be appended to the user supplied message.- Returns:
this
.
-
disableRefLog
public BatchRefUpdate disableRefLog()
Don't record this update in the ref's associated reflog.- Returns:
this
.
-
isRefLogDisabled
public boolean isRefLogDisabled()
- Returns:
- true if log has been disabled by
disableRefLog()
.
-
getCommands
public List<ReceiveCommand> getCommands()
- Returns:
- commands this update will process.
-
addCommand
public BatchRefUpdate addCommand(ReceiveCommand cmd)
Add a single command to this batch update.- Parameters:
cmd
- the command to add, must not be null.- Returns:
this
.
-
addCommand
public BatchRefUpdate addCommand(ReceiveCommand... cmd)
Add commands to this batch update.- Parameters:
cmd
- the commands to add, must not be null.- Returns:
this
.
-
addCommand
public BatchRefUpdate addCommand(Collection<ReceiveCommand> cmd)
Add commands to this batch update.- Parameters:
cmd
- the commands to add, must not be null.- Returns:
this
.
-
execute
public void execute(RevWalk walk, ProgressMonitor monitor) throws IOException
Execute this batch update.The default implementation of this method performs a sequential reference update over each reference.
- Parameters:
walk
- a RevWalk to parse tags in case the storage system wants to store them pre-peeled, a common performance optimization.monitor
- progress monitor to receive update status on.- Throws:
IOException
- the database is unable to accept the update. Individual command status must be tested to determine if there is a partial failure, or a total failure.
-
newUpdate
protected RefUpdate newUpdate(ReceiveCommand cmd) throws IOException
Create a new RefUpdate copying the batch settings.- Parameters:
cmd
- specific command the update should be created to copy.- Returns:
- a single reference update command.
- Throws:
IOException
- the reference database cannot make a new update object for the given reference.
-
-