public abstract class VersionedMetaData extends 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,
String refName)
Creates a new commit and a new ref based on this commit.
|
protected org.eclipse.jgit.lib.ObjectId |
getObjectId(String fileName) |
List<VersionedMetaData.PathInfo> |
getPathInfos(boolean recursive) |
protected abstract 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(String fileName) |
protected byte[] |
readFile(String fileName) |
protected org.eclipse.jgit.dircache.DirCache |
readTree(org.eclipse.jgit.revwalk.RevTree tree) |
protected String |
readUTF8(String fileName) |
protected void |
saveConfig(String fileName,
org.eclipse.jgit.lib.Config cfg) |
protected void |
saveFile(String fileName,
byte[] raw) |
protected void |
saveUTF8(String fileName,
String text) |
protected static void |
set(org.eclipse.jgit.lib.Config rc,
String section,
String subsection,
String name,
boolean value) |
protected static <E extends Enum<?>> |
set(org.eclipse.jgit.lib.Config rc,
String section,
String subsection,
String name,
E value,
E defaultValue) |
protected static void |
set(org.eclipse.jgit.lib.Config rc,
String section,
String subsection,
String name,
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 String getRefName()
protected abstract void onLoad() throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
IOException
org.eclipse.jgit.errors.ConfigInvalidException
protected abstract boolean onSave(org.eclipse.jgit.lib.CommitBuilder commit) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
IOException
org.eclipse.jgit.errors.ConfigInvalidException
public org.eclipse.jgit.lib.ObjectId getRevision()
public void load(org.eclipse.jgit.lib.Repository db) throws 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.IOException
org.eclipse.jgit.errors.ConfigInvalidException
public void load(org.eclipse.jgit.lib.Repository db, org.eclipse.jgit.lib.ObjectId id) throws 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.IOException
org.eclipse.jgit.errors.ConfigInvalidException
public void load(org.eclipse.jgit.revwalk.RevWalk walk, org.eclipse.jgit.lib.ObjectId id) throws 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.IOException
org.eclipse.jgit.errors.ConfigInvalidException
public void load(MetaDataUpdate update) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
IOException
org.eclipse.jgit.errors.ConfigInvalidException
public void load(MetaDataUpdate update, org.eclipse.jgit.lib.ObjectId id) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
IOException
org.eclipse.jgit.errors.ConfigInvalidException
public org.eclipse.jgit.revwalk.RevCommit commit(MetaDataUpdate update) throws IOException
update
- helper information to define the update that will occur.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, String refName) throws IOException
update
- helper information to define the update that will occur.refName
- name of the ref that should be createdIOException
- 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 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.IOException
- if the update failed.protected org.eclipse.jgit.dircache.DirCache readTree(org.eclipse.jgit.revwalk.RevTree tree) throws IOException, org.eclipse.jgit.errors.MissingObjectException, org.eclipse.jgit.errors.IncorrectObjectTypeException
IOException
org.eclipse.jgit.errors.MissingObjectException
org.eclipse.jgit.errors.IncorrectObjectTypeException
protected org.eclipse.jgit.lib.Config readConfig(String fileName) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
IOException
org.eclipse.jgit.errors.ConfigInvalidException
protected String readUTF8(String fileName) throws IOException
IOException
protected byte[] readFile(String fileName) throws IOException
IOException
protected org.eclipse.jgit.lib.ObjectId getObjectId(String fileName) throws IOException
IOException
public List<VersionedMetaData.PathInfo> getPathInfos(boolean recursive) throws IOException
IOException
protected static void set(org.eclipse.jgit.lib.Config rc, String section, String subsection, String name, String value)
protected static void set(org.eclipse.jgit.lib.Config rc, String section, String subsection, String name, boolean value)
protected static <E extends Enum<?>> void set(org.eclipse.jgit.lib.Config rc, String section, String subsection, String name, E value, E defaultValue)
protected void saveConfig(String fileName, org.eclipse.jgit.lib.Config cfg) throws IOException
IOException
protected void saveUTF8(String fileName, String text) throws IOException
IOException
protected void saveFile(String fileName, byte[] raw) throws IOException
IOException