public abstract class VersionedMetaData
extends java.lang.Object
Implementors are responsible for supplying implementations of the onLoad and onSave methods to read from the repository, or format an update that can later be written back to the repository.
Modifier and Type | Class and Description |
---|---|
static interface |
VersionedMetaData.BatchMetaDataUpdate |
static class |
VersionedMetaData.PathInfo
Path information that does not hold references to any repository
data structures, allowing the application to retain this object
for long periods of time.
|
Modifier and Type | Field and Description |
---|---|
protected org.eclipse.jgit.lib.ObjectInserter |
inserter |
protected org.eclipse.jgit.dircache.DirCache |
newTree |
protected org.eclipse.jgit.lib.ObjectReader |
reader |
protected org.eclipse.jgit.revwalk.RevCommit |
revision |
Constructor and Description |
---|
VersionedMetaData() |
Modifier and Type | Method and Description |
---|---|
org.eclipse.jgit.revwalk.RevCommit |
commit(MetaDataUpdate update)
Update this metadata branch, recording a new commit on its reference.
|
org.eclipse.jgit.revwalk.RevCommit |
commitToNewRef(MetaDataUpdate update,
java.lang.String refName)
Creates a new commit and a new ref based on this commit.
|
protected org.eclipse.jgit.lib.ObjectId |
getObjectId(java.lang.String fileName) |
java.util.List<VersionedMetaData.PathInfo> |
getPathInfos(boolean recursive) |
protected abstract java.lang.String |
getRefName() |
org.eclipse.jgit.lib.ObjectId |
getRevision() |
void |
load(MetaDataUpdate update) |
void |
load(MetaDataUpdate update,
org.eclipse.jgit.lib.ObjectId id) |
void |
load(org.eclipse.jgit.lib.Repository db)
Load the current version from the branch.
|
void |
load(org.eclipse.jgit.lib.Repository db,
org.eclipse.jgit.lib.ObjectId id)
Load a specific version from the repository.
|
void |
load(org.eclipse.jgit.revwalk.RevWalk walk,
org.eclipse.jgit.lib.ObjectId id)
Load a specific version from an open walk.
|
protected abstract void |
onLoad()
Set up the metadata, parsing any state from the loaded revision.
|
protected abstract boolean |
onSave(org.eclipse.jgit.lib.CommitBuilder commit)
Save any changes to the metadata in a commit.
|
VersionedMetaData.BatchMetaDataUpdate |
openUpdate(MetaDataUpdate update)
Open a batch of updates to the same metadata ref.
|
protected org.eclipse.jgit.lib.Config |
readConfig(java.lang.String fileName) |
protected byte[] |
readFile(java.lang.String fileName) |
protected org.eclipse.jgit.dircache.DirCache |
readTree(org.eclipse.jgit.revwalk.RevTree tree) |
protected java.lang.String |
readUTF8(java.lang.String fileName) |
protected void |
saveConfig(java.lang.String fileName,
org.eclipse.jgit.lib.Config cfg) |
protected void |
saveFile(java.lang.String fileName,
byte[] raw) |
protected void |
saveUTF8(java.lang.String fileName,
java.lang.String text) |
protected static void |
set(org.eclipse.jgit.lib.Config rc,
java.lang.String section,
java.lang.String subsection,
java.lang.String name,
boolean value) |
protected static <E extends java.lang.Enum<?>> |
set(org.eclipse.jgit.lib.Config rc,
java.lang.String section,
java.lang.String subsection,
java.lang.String name,
E value,
E defaultValue) |
protected static void |
set(org.eclipse.jgit.lib.Config rc,
java.lang.String section,
java.lang.String subsection,
java.lang.String name,
java.lang.String value) |
protected org.eclipse.jgit.revwalk.RevCommit revision
protected org.eclipse.jgit.lib.ObjectReader reader
protected org.eclipse.jgit.lib.ObjectInserter inserter
protected org.eclipse.jgit.dircache.DirCache newTree
protected abstract java.lang.String getRefName()
protected abstract void onLoad() throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
protected abstract boolean onSave(org.eclipse.jgit.lib.CommitBuilder commit) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
public org.eclipse.jgit.lib.ObjectId getRevision()
public void load(org.eclipse.jgit.lib.Repository db) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException
The repository is not held after the call completes, allowing the application to retain this object for long periods of time.
db
- repository to access.java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
public void load(org.eclipse.jgit.lib.Repository db, org.eclipse.jgit.lib.ObjectId id) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException
This method is primarily useful for applying updates to a specific revision that was shown to an end-user in the user interface. If there are conflicts with another user's concurrent changes, these will be automatically detected at commit time.
The repository is not held after the call completes, allowing the application to retain this object for long periods of time.
db
- repository to access.id
- revision to load.java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
public void load(org.eclipse.jgit.revwalk.RevWalk walk, org.eclipse.jgit.lib.ObjectId id) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException
This method is primarily useful for applying updates to a specific revision that was shown to an end-user in the user interface. If there are conflicts with another user's concurrent changes, these will be automatically detected at commit time.
The caller retains ownership of the walk and is responsible for closing it. However, this instance does not hold a reference to the walk or the repository after the call completes, allowing the application to retain this object for long periods of time.
walk
- open walk to access to access.id
- revision to load.java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
public void load(MetaDataUpdate update) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
public void load(MetaDataUpdate update, org.eclipse.jgit.lib.ObjectId id) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
public org.eclipse.jgit.revwalk.RevCommit commit(MetaDataUpdate update) throws java.io.IOException
update
- helper information to define the update that will occur.java.io.IOException
- if there is a storage problem and the update cannot be
executed as requested or if it failed because of a concurrent
update to the same referencepublic org.eclipse.jgit.revwalk.RevCommit commitToNewRef(MetaDataUpdate update, java.lang.String refName) throws java.io.IOException
update
- helper information to define the update that will occur.refName
- name of the ref that should be createdjava.io.IOException
- if there is a storage problem and the update cannot be
executed as requested or if it failed because of a concurrent
update to the same referencepublic VersionedMetaData.BatchMetaDataUpdate openUpdate(MetaDataUpdate update) throws java.io.IOException
This allows making multiple commits to a single metadata ref, at the end of
which is a single ref update. For batching together updates to multiple
refs (each consisting of one or more commits against their respective
refs), create the MetaDataUpdate
with a BatchRefUpdate
.
A ref update produced by this VersionedMetaData.BatchMetaDataUpdate
is only committed
if there is no associated BatchRefUpdate
. As a result, the
configured ref updated event is not fired if there is an associated batch.
update
- helper info about the update.java.io.IOException
- if the update failed.protected org.eclipse.jgit.dircache.DirCache readTree(org.eclipse.jgit.revwalk.RevTree tree) throws java.io.IOException, org.eclipse.jgit.errors.MissingObjectException, org.eclipse.jgit.errors.IncorrectObjectTypeException
java.io.IOException
org.eclipse.jgit.errors.MissingObjectException
org.eclipse.jgit.errors.IncorrectObjectTypeException
protected org.eclipse.jgit.lib.Config readConfig(java.lang.String fileName) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
protected java.lang.String readUTF8(java.lang.String fileName) throws java.io.IOException
java.io.IOException
protected byte[] readFile(java.lang.String fileName) throws java.io.IOException
java.io.IOException
protected org.eclipse.jgit.lib.ObjectId getObjectId(java.lang.String fileName) throws java.io.IOException
java.io.IOException
public java.util.List<VersionedMetaData.PathInfo> getPathInfos(boolean recursive) throws java.io.IOException
java.io.IOException
protected static void set(org.eclipse.jgit.lib.Config rc, java.lang.String section, java.lang.String subsection, java.lang.String name, java.lang.String value)
protected static void set(org.eclipse.jgit.lib.Config rc, java.lang.String section, java.lang.String subsection, java.lang.String name, boolean value)
protected static <E extends java.lang.Enum<?>> void set(org.eclipse.jgit.lib.Config rc, java.lang.String section, java.lang.String subsection, java.lang.String name, E value, E defaultValue)
protected void saveConfig(java.lang.String fileName, org.eclipse.jgit.lib.Config cfg) throws java.io.IOException
java.io.IOException
protected void saveUTF8(java.lang.String fileName, java.lang.String text) throws java.io.IOException
java.io.IOException
protected void saveFile(java.lang.String fileName, byte[] raw) throws java.io.IOException
java.io.IOException