public class RepoView
extends java.lang.Object
Repository
for use by BatchUpdateOp
implementations.
This class serves two purposes in the context of BatchUpdate
. First, the subset of
normal Repository functionality is purely read-only, which prevents implementors from modifying
the repository outside of RepoOnlyOp.updateRepo(com.google.gerrit.server.update.RepoContext)
. Write operations can only be
performed by calling methods on RepoContext
.
Second, the read methods take into account any pending operations on the repository that
implementations have staged using the write methods on RepoContext
. Callers do not have
to worry about whether operations have been performed yet.
Modifier and Type | Method and Description |
---|---|
org.eclipse.jgit.lib.Config |
getConfig()
Get this repo's configuration.
|
java.util.Optional<org.eclipse.jgit.lib.ObjectId> |
getRef(java.lang.String name)
Read a single ref from the repo.
|
java.util.Map<java.lang.String,org.eclipse.jgit.lib.ObjectId> |
getRefs(java.lang.String prefix)
Look up refs by prefix.
|
org.eclipse.jgit.revwalk.RevWalk |
getRevWalk()
Get an open revwalk on the repo.
|
public org.eclipse.jgit.lib.Config getConfig()
This is the storage-level config you would get with Repository.getConfig()
, not, for
example, the Gerrit-level project config.
public org.eclipse.jgit.revwalk.RevWalk getRevWalk()
Guaranteed to be able to read back any objects inserted in the repository via RepoContext.getInserter()
, even if objects have not been flushed to the underlying repo. In
particular this includes any object returned by getRef(String)
, even taking into
account not-yet-executed commands.
public java.util.Optional<org.eclipse.jgit.lib.ObjectId> getRef(java.lang.String name) throws java.io.IOException
Takes into account any ref update commands added during the course of the update using
RepoContext.addRefUpdate(org.eclipse.jgit.transport.ReceiveCommand)
, even if they have not yet been executed on the underlying
repo.
The results of individual ref lookups are cached: calling this method multiple times with the same ref name will return the same result (unless a command was added in the meantime). The repo is not reread.
name
- exact ref name.java.io.IOException
- if an error occurred.public java.util.Map<java.lang.String,org.eclipse.jgit.lib.ObjectId> getRefs(java.lang.String prefix) throws java.io.IOException
Takes into account any ref update commands added during the course of the update using
RepoContext.addRefUpdate(org.eclipse.jgit.transport.ReceiveCommand)
, even if they have not yet been executed on the underlying
repo.
For any ref that has previously been accessed with getRef(String)
, the value in the
result map will be that same cached value. Any refs that have not been previously
accessed are re-scanned from the repo on each call.
prefix
- ref prefix; must end in '/' or else be empty.prefix
and have the
prefix stripped.java.io.IOException
- if an error occurred.