public class BatchRefUpdate extends Object
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.
Modifier | Constructor and Description |
---|---|
protected |
BatchRefUpdate(RefDatabase refdb)
Initialize a new batch update.
|
Modifier and Type | Method and Description |
---|---|
BatchRefUpdate |
addCommand(Collection<ReceiveCommand> cmd)
Add commands to this batch update.
|
BatchRefUpdate |
addCommand(ReceiveCommand... cmd)
Add commands to this batch update.
|
BatchRefUpdate |
addCommand(ReceiveCommand cmd)
Add a single command 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 without option strings.
|
void |
execute(RevWalk walk,
ProgressMonitor monitor,
List<String> options)
Execute this batch update.
|
List<ReceiveCommand> |
getCommands() |
protected PushCertificate |
getPushCertificate()
Set the push certificate associated with this update.
|
List<String> |
getPushOptions()
Gets the list of option strings associated with this update.
|
PersonIdent |
getRefLogIdent() |
String |
getRefLogMessage()
Get the message to include in the reflog.
|
boolean |
isAllowNonFastForwards() |
boolean |
isAtomic() |
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 |
setAtomic(boolean atomic)
Request that all updates in this batch be performed atomically.
|
void |
setPushCertificate(PushCertificate cert)
Set a push certificate associated with this 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.
|
String |
toString() |
protected BatchRefUpdate(RefDatabase refdb)
refdb
- the reference database of the repository to be updated.public boolean isAllowNonFastForwards()
public BatchRefUpdate setAllowNonFastForwards(boolean allow)
allow
- true if this update batch should ignore merge tests.this
.public PersonIdent getRefLogIdent()
public BatchRefUpdate setRefLogIdent(PersonIdent pi)
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.
pi
- identity of the user. If null the identity will be
automatically determined based on the repository
configuration.this
.public String getRefLogMessage()
public boolean isRefLogIncludingResult()
true
if the ref log message should show the result.public BatchRefUpdate setRefLogMessage(String msg, boolean appendStatus)
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.this
.public BatchRefUpdate disableRefLog()
this
.public boolean isRefLogDisabled()
disableRefLog()
.public BatchRefUpdate setAtomic(boolean atomic)
When atomic updates are used, either all commands apply successfully, or
none do. Commands that might have otherwise succeeded are rejected with
REJECTED_OTHER_REASON
.
This method only works if the underlying ref database supports atomic
transactions, i.e. RefDatabase.performsAtomicTransactions()
returns
true. Calling this method with true if the underlying ref database does not
support atomic transactions will cause all commands to fail with REJECTED_OTHER_REASON
.
atomic
- whether updates should be atomic.this
public boolean isAtomic()
public void setPushCertificate(PushCertificate cert)
This usually includes commands to update the refs in this batch, but is not required to.
cert
- push certificate, may be null.protected PushCertificate getPushCertificate()
This usually includes commands to update the refs in this batch, but is not required to.
public List<ReceiveCommand> getCommands()
public BatchRefUpdate addCommand(ReceiveCommand cmd)
cmd
- the command to add, must not be null.this
.public BatchRefUpdate addCommand(ReceiveCommand... cmd)
cmd
- the commands to add, must not be null.this
.public BatchRefUpdate addCommand(Collection<ReceiveCommand> cmd)
cmd
- the commands to add, must not be null.this
.public List<String> getPushOptions()
public void execute(RevWalk walk, ProgressMonitor monitor, List<String> options) throws IOException
The default implementation of this method performs a sequential reference update over each reference.
Implementations must respect the atomicity requirements of the underlying
database as described in setAtomic(boolean)
and
RefDatabase.performsAtomicTransactions()
.
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.options
- a list of option strings; set null to execute withoutIOException
- 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.public void execute(RevWalk walk, ProgressMonitor monitor) throws IOException
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.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.protected RefUpdate newUpdate(ReceiveCommand cmd) throws IOException
cmd
- specific command the update should be created to copy.IOException
- the reference database cannot make a new update object for
the given reference.Copyright © 2016 Eclipse JGit Project. All rights reserved.