Class RepoView
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.
-
Constructor Summary
ConstructorsConstructorDescriptionRepoView
(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectInserter inserter) -
Method Summary
Modifier and TypeMethodDescriptionorg.eclipse.jgit.lib.Config
Get this repo's configuration.Optional<org.eclipse.jgit.lib.ObjectId>
Read a single ref from the repo.Look up refs by prefix.org.eclipse.jgit.revwalk.RevWalk
Get an open revwalk on the repo.
-
Constructor Details
-
RepoView
public RepoView(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectInserter inserter)
-
-
Method Details
-
getConfig
public org.eclipse.jgit.lib.Config getConfig()Get this repo's configuration.This is the storage-level config you would get with
Repository.getConfig()
, not, for example, the Gerrit-level project config.- Returns:
- a defensive copy of the config; modifications have no effect on the underlying config.
-
getRevWalk
public org.eclipse.jgit.revwalk.RevWalk getRevWalk()Get an open revwalk on the repo.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 bygetRef(String)
, even taking into account not-yet-executed commands.- Returns:
- revwalk.
-
getRef
Read a single ref from the repo.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.
- Parameters:
name
- exact ref name.- Returns:
- the value of the ref, if present.
- Throws:
IOException
- if an error occurred.
-
getRefs
Look up refs by prefix.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.- Parameters:
prefix
- ref prefix; must end in '/' or else be empty.- Returns:
- a map of ref suffixes to SHA-1s. The refs are all under
prefix
and have the prefix stripped. - Throws:
IOException
- if an error occurred.
-