Class VersionedMetaData

    • Field Detail

      • revision

        protected org.eclipse.jgit.revwalk.RevCommit revision
        The revision at which the data was loaded. Is null for data yet to be created.
      • rw

        protected org.eclipse.jgit.revwalk.RevWalk rw
      • reader

        protected org.eclipse.jgit.lib.ObjectReader reader
      • inserter

        protected org.eclipse.jgit.lib.ObjectInserter inserter
      • newTree

        protected org.eclipse.jgit.dircache.DirCache newTree
    • Constructor Detail

      • VersionedMetaData

        public VersionedMetaData()
    • Method Detail

      • getRefName

        protected abstract String getRefName()
        Returns name of the reference storing this configuration.
      • onLoad

        protected abstract void onLoad()
                                throws IOException,
                                       org.eclipse.jgit.errors.ConfigInvalidException
        Set up the metadata, parsing any state from the loaded revision.
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • onSave

        protected abstract boolean onSave​(org.eclipse.jgit.lib.CommitBuilder commit)
                                   throws IOException,
                                          org.eclipse.jgit.errors.ConfigInvalidException
        Save any changes to the metadata in a commit.
        Returns:
        true if the commit should proceed, false to abort.
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • getRevision

        public org.eclipse.jgit.lib.ObjectId getRevision()
        Returns revision of the metadata that was loaded.
      • load

        public void load​(Project.NameKey projectName,
                         org.eclipse.jgit.lib.Repository db)
                  throws IOException,
                         org.eclipse.jgit.errors.ConfigInvalidException
        Load the current version from the branch.

        The repository is not held after the call completes, allowing the application to retain this object for long periods of time.

        Parameters:
        projectName - the name of the project
        db - repository to access.
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • load

        public void load​(Project.NameKey projectName,
                         org.eclipse.jgit.lib.Repository db,
                         org.eclipse.jgit.lib.ObjectId id)
                  throws IOException,
                         org.eclipse.jgit.errors.ConfigInvalidException
        Load a specific version from the repository.

        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.

        Parameters:
        projectName - the name of the project
        db - repository to access.
        id - revision to load.
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • load

        public void load​(Project.NameKey projectName,
                         org.eclipse.jgit.revwalk.RevWalk walk,
                         org.eclipse.jgit.lib.ObjectId id)
                  throws IOException,
                         org.eclipse.jgit.errors.ConfigInvalidException
        Load a specific version from an open walk.

        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.

        Parameters:
        projectName - the name of the project
        walk - open walk to access to access.
        id - revision to load.
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • load

        public void load​(MetaDataUpdate update)
                  throws IOException,
                         org.eclipse.jgit.errors.ConfigInvalidException
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • load

        public void load​(MetaDataUpdate update,
                         org.eclipse.jgit.lib.ObjectId id)
                  throws IOException,
                         org.eclipse.jgit.errors.ConfigInvalidException
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • commit

        public org.eclipse.jgit.revwalk.RevCommit commit​(MetaDataUpdate update)
                                                  throws IOException
        Update this metadata branch, recording a new commit on its reference. This method mutates its receiver.
        Parameters:
        update - helper information to define the update that will occur.
        Returns:
        the commit that was created
        Throws:
        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 reference
      • commit

        public org.eclipse.jgit.revwalk.RevCommit commit​(MetaDataUpdate update,
                                                         org.eclipse.jgit.lib.ObjectInserter objInserter,
                                                         org.eclipse.jgit.lib.ObjectReader objReader,
                                                         org.eclipse.jgit.revwalk.RevWalk revWalk)
                                                  throws IOException
        Update this metadata branch, recording a new commit on its reference. This method mutates its receiver.
        Parameters:
        update - helper information to define the update that will occur.
        objInserter - Shared object inserter.
        objReader - Shared object reader.
        revWalk - Shared rev walk.
        Returns:
        the commit that was created
        Throws:
        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 reference
      • commitToNewRef

        public org.eclipse.jgit.revwalk.RevCommit commitToNewRef​(MetaDataUpdate update,
                                                                 String refName)
                                                          throws IOException
        Creates a new commit and a new ref based on this commit. This method mutates its receiver.
        Parameters:
        update - helper information to define the update that will occur.
        refName - name of the ref that should be created
        Returns:
        the commit that was created
        Throws:
        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 reference
      • openUpdate

        public VersionedMetaData.BatchMetaDataUpdate openUpdate​(MetaDataUpdate update)
                                                         throws IOException
        Open a batch of updates to the same metadata ref.

        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.

        Parameters:
        update - helper info about the update.
        Throws:
        IOException - if the update failed.
      • openUpdate

        public VersionedMetaData.BatchMetaDataUpdate openUpdate​(MetaDataUpdate update,
                                                                org.eclipse.jgit.lib.ObjectInserter objInserter,
                                                                org.eclipse.jgit.lib.ObjectReader objReader,
                                                                org.eclipse.jgit.revwalk.RevWalk revWalk)
                                                         throws IOException
        Open a batch of updates to the same metadata ref.

        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.

        If object inserter, reader and revwalk are provided, then the updates are not flushed, allowing callers the flexibility to flush only once after several updates.

        Parameters:
        update - helper info about the update.
        objInserter - Shared object inserter.
        objReader - Shared object reader.
        revWalk - Shared rev walk.
        Throws:
        IOException - if the update failed.
      • readTree

        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
        Throws:
        IOException
        org.eclipse.jgit.errors.MissingObjectException
        org.eclipse.jgit.errors.IncorrectObjectTypeException
      • readConfig

        protected org.eclipse.jgit.lib.Config readConfig​(String fileName)
                                                  throws IOException,
                                                         org.eclipse.jgit.errors.ConfigInvalidException
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • readConfig

        protected org.eclipse.jgit.lib.Config readConfig​(String fileName,
                                                         Optional<? extends org.eclipse.jgit.lib.Config> baseConfig)
                                                  throws IOException,
                                                         org.eclipse.jgit.errors.ConfigInvalidException
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • set

        protected static void set​(org.eclipse.jgit.lib.Config rc,
                                  String section,
                                  String subsection,
                                  String name,
                                  String value)
      • set

        protected static void set​(org.eclipse.jgit.lib.Config rc,
                                  String section,
                                  String subsection,
                                  String name,
                                  boolean value)
      • set

        protected static <E extends Enum<?>> void set​(org.eclipse.jgit.lib.Config rc,
                                                      String section,
                                                      String subsection,
                                                      String name,
                                                      E value,
                                                      E defaultValue)