|
|
@ -63,10 +63,11 @@ import org.eclipse.jgit.revwalk.RevTree; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Index of notes from a note branch. |
|
|
|
* Index of notes from a note branch. |
|
|
|
* |
|
|
|
* |
|
|
|
* This class is not thread-safe, and relies on an {@link ObjectReader} that it |
|
|
|
* This class is not thread-safe, and relies on an |
|
|
|
* borrows/shares with the caller. The reader can be used during any call, and |
|
|
|
* {@link org.eclipse.jgit.lib.ObjectReader} that it borrows/shares with the |
|
|
|
* is not released by this class. The caller should arrange for releasing the |
|
|
|
* caller. The reader can be used during any call, and is not released by this |
|
|
|
* shared {@code ObjectReader} at the proper times. |
|
|
|
* class. The caller should arrange for releasing the shared |
|
|
|
|
|
|
|
* {@code ObjectReader} at the proper times. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class NoteMap implements Iterable<Note> { |
|
|
|
public class NoteMap implements Iterable<Note> { |
|
|
|
/** |
|
|
|
/** |
|
|
@ -81,10 +82,11 @@ public class NoteMap implements Iterable<Note> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Shorten the note ref name by trimming off the {@link Constants#R_NOTES} |
|
|
|
* Shorten the note ref name by trimming off the |
|
|
|
* prefix if it exists. |
|
|
|
* {@link org.eclipse.jgit.lib.Constants#R_NOTES} prefix if it exists. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param noteRefName |
|
|
|
* @param noteRefName |
|
|
|
|
|
|
|
* a {@link java.lang.String} object. |
|
|
|
* @return a more user friendly note name |
|
|
|
* @return a more user friendly note name |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static String shortenRefName(String noteRefName) { |
|
|
|
public static String shortenRefName(String noteRefName) { |
|
|
@ -103,13 +105,13 @@ public class NoteMap implements Iterable<Note> { |
|
|
|
* @param commit |
|
|
|
* @param commit |
|
|
|
* the revision of the note branch to read. |
|
|
|
* the revision of the note branch to read. |
|
|
|
* @return the note map read from the commit. |
|
|
|
* @return the note map read from the commit. |
|
|
|
* @throws IOException |
|
|
|
* @throws java.io.IOException |
|
|
|
* the repository cannot be accessed through the reader. |
|
|
|
* the repository cannot be accessed through the reader. |
|
|
|
* @throws CorruptObjectException |
|
|
|
* @throws org.eclipse.jgit.errors.CorruptObjectException |
|
|
|
* a tree object is corrupt and cannot be read. |
|
|
|
* a tree object is corrupt and cannot be read. |
|
|
|
* @throws IncorrectObjectTypeException |
|
|
|
* @throws org.eclipse.jgit.errors.IncorrectObjectTypeException |
|
|
|
* a tree object wasn't actually a tree. |
|
|
|
* a tree object wasn't actually a tree. |
|
|
|
* @throws MissingObjectException |
|
|
|
* @throws org.eclipse.jgit.errors.MissingObjectException |
|
|
|
* a reference tree object doesn't exist. |
|
|
|
* a reference tree object doesn't exist. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static NoteMap read(ObjectReader reader, RevCommit commit) |
|
|
|
public static NoteMap read(ObjectReader reader, RevCommit commit) |
|
|
@ -128,13 +130,13 @@ public class NoteMap implements Iterable<Note> { |
|
|
|
* @param tree |
|
|
|
* @param tree |
|
|
|
* the note tree to read. |
|
|
|
* the note tree to read. |
|
|
|
* @return the note map read from the tree. |
|
|
|
* @return the note map read from the tree. |
|
|
|
* @throws IOException |
|
|
|
* @throws java.io.IOException |
|
|
|
* the repository cannot be accessed through the reader. |
|
|
|
* the repository cannot be accessed through the reader. |
|
|
|
* @throws CorruptObjectException |
|
|
|
* @throws org.eclipse.jgit.errors.CorruptObjectException |
|
|
|
* a tree object is corrupt and cannot be read. |
|
|
|
* a tree object is corrupt and cannot be read. |
|
|
|
* @throws IncorrectObjectTypeException |
|
|
|
* @throws org.eclipse.jgit.errors.IncorrectObjectTypeException |
|
|
|
* a tree object wasn't actually a tree. |
|
|
|
* a tree object wasn't actually a tree. |
|
|
|
* @throws MissingObjectException |
|
|
|
* @throws org.eclipse.jgit.errors.MissingObjectException |
|
|
|
* a reference tree object doesn't exist. |
|
|
|
* a reference tree object doesn't exist. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static NoteMap read(ObjectReader reader, RevTree tree) |
|
|
|
public static NoteMap read(ObjectReader reader, RevTree tree) |
|
|
@ -153,13 +155,13 @@ public class NoteMap implements Iterable<Note> { |
|
|
|
* @param treeId |
|
|
|
* @param treeId |
|
|
|
* the note tree to read. |
|
|
|
* the note tree to read. |
|
|
|
* @return the note map read from the tree. |
|
|
|
* @return the note map read from the tree. |
|
|
|
* @throws IOException |
|
|
|
* @throws java.io.IOException |
|
|
|
* the repository cannot be accessed through the reader. |
|
|
|
* the repository cannot be accessed through the reader. |
|
|
|
* @throws CorruptObjectException |
|
|
|
* @throws org.eclipse.jgit.errors.CorruptObjectException |
|
|
|
* a tree object is corrupt and cannot be read. |
|
|
|
* a tree object is corrupt and cannot be read. |
|
|
|
* @throws IncorrectObjectTypeException |
|
|
|
* @throws org.eclipse.jgit.errors.IncorrectObjectTypeException |
|
|
|
* a tree object wasn't actually a tree. |
|
|
|
* a tree object wasn't actually a tree. |
|
|
|
* @throws MissingObjectException |
|
|
|
* @throws org.eclipse.jgit.errors.MissingObjectException |
|
|
|
* a reference tree object doesn't exist. |
|
|
|
* a reference tree object doesn't exist. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static NoteMap readTree(ObjectReader reader, ObjectId treeId) |
|
|
|
public static NoteMap readTree(ObjectReader reader, ObjectId treeId) |
|
|
@ -197,10 +199,7 @@ public class NoteMap implements Iterable<Note> { |
|
|
|
this.reader = reader; |
|
|
|
this.reader = reader; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** {@inheritDoc} */ |
|
|
|
* @return an iterator that iterates over notes of this NoteMap. Non note |
|
|
|
|
|
|
|
* entries are ignored by this iterator. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Iterator<Note> iterator() { |
|
|
|
public Iterator<Note> iterator() { |
|
|
|
try { |
|
|
|
try { |
|
|
@ -216,7 +215,7 @@ public class NoteMap implements Iterable<Note> { |
|
|
|
* @param id |
|
|
|
* @param id |
|
|
|
* the object to look for. |
|
|
|
* the object to look for. |
|
|
|
* @return the note's blob ObjectId, or null if no note exists. |
|
|
|
* @return the note's blob ObjectId, or null if no note exists. |
|
|
|
* @throws IOException |
|
|
|
* @throws java.io.IOException |
|
|
|
* a portion of the note space is not accessible. |
|
|
|
* a portion of the note space is not accessible. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ObjectId get(AnyObjectId id) throws IOException { |
|
|
|
public ObjectId get(AnyObjectId id) throws IOException { |
|
|
@ -230,7 +229,7 @@ public class NoteMap implements Iterable<Note> { |
|
|
|
* @param id |
|
|
|
* @param id |
|
|
|
* the object to look for. |
|
|
|
* the object to look for. |
|
|
|
* @return the note for the given object id, or null if no note exists. |
|
|
|
* @return the note for the given object id, or null if no note exists. |
|
|
|
* @throws IOException |
|
|
|
* @throws java.io.IOException |
|
|
|
* a portion of the note space is not accessible. |
|
|
|
* a portion of the note space is not accessible. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Note getNote(AnyObjectId id) throws IOException { |
|
|
|
public Note getNote(AnyObjectId id) throws IOException { |
|
|
@ -243,7 +242,7 @@ public class NoteMap implements Iterable<Note> { |
|
|
|
* @param id |
|
|
|
* @param id |
|
|
|
* the object to look for. |
|
|
|
* the object to look for. |
|
|
|
* @return true if a note exists; false if there is no note. |
|
|
|
* @return true if a note exists; false if there is no note. |
|
|
|
* @throws IOException |
|
|
|
* @throws java.io.IOException |
|
|
|
* a portion of the note space is not accessible. |
|
|
|
* a portion of the note space is not accessible. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean contains(AnyObjectId id) throws IOException { |
|
|
|
public boolean contains(AnyObjectId id) throws IOException { |
|
|
@ -269,11 +268,11 @@ public class NoteMap implements Iterable<Note> { |
|
|
|
* larger than this limit, LargeObjectException will be thrown. |
|
|
|
* larger than this limit, LargeObjectException will be thrown. |
|
|
|
* @return if a note is defined for {@code id}, the note content. If no note |
|
|
|
* @return if a note is defined for {@code id}, the note content. If no note |
|
|
|
* is defined, null. |
|
|
|
* is defined, null. |
|
|
|
* @throws LargeObjectException |
|
|
|
* @throws org.eclipse.jgit.errors.LargeObjectException |
|
|
|
* the note data is larger than {@code sizeLimit}. |
|
|
|
* the note data is larger than {@code sizeLimit}. |
|
|
|
* @throws MissingObjectException |
|
|
|
* @throws org.eclipse.jgit.errors.MissingObjectException |
|
|
|
* the note's blob does not exist in the repository. |
|
|
|
* the note's blob does not exist in the repository. |
|
|
|
* @throws IOException |
|
|
|
* @throws java.io.IOException |
|
|
|
* the note's blob cannot be read from the repository |
|
|
|
* the note's blob cannot be read from the repository |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public byte[] getCachedBytes(AnyObjectId id, int sizeLimit) |
|
|
|
public byte[] getCachedBytes(AnyObjectId id, int sizeLimit) |
|
|
@ -306,7 +305,7 @@ public class NoteMap implements Iterable<Note> { |
|
|
|
* data to associate with the note. This must be the ObjectId of |
|
|
|
* data to associate with the note. This must be the ObjectId of |
|
|
|
* a blob that already exists in the repository. If null the note |
|
|
|
* a blob that already exists in the repository. If null the note |
|
|
|
* will be deleted, if present. |
|
|
|
* will be deleted, if present. |
|
|
|
* @throws IOException |
|
|
|
* @throws java.io.IOException |
|
|
|
* a portion of the note space is not accessible. |
|
|
|
* a portion of the note space is not accessible. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void set(AnyObjectId noteOn, ObjectId noteData) throws IOException { |
|
|
|
public void set(AnyObjectId noteOn, ObjectId noteData) throws IOException { |
|
|
@ -337,7 +336,7 @@ public class NoteMap implements Iterable<Note> { |
|
|
|
* inserter to write the encoded {@code noteData} out as a blob. |
|
|
|
* inserter to write the encoded {@code noteData} out as a blob. |
|
|
|
* The caller must ensure the inserter is flushed before the |
|
|
|
* The caller must ensure the inserter is flushed before the |
|
|
|
* updated note map is made available for reading. |
|
|
|
* updated note map is made available for reading. |
|
|
|
* @throws IOException |
|
|
|
* @throws java.io.IOException |
|
|
|
* the note data could not be stored in the repository. |
|
|
|
* the note data could not be stored in the repository. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void set(AnyObjectId noteOn, String noteData, ObjectInserter ins) |
|
|
|
public void set(AnyObjectId noteOn, String noteData, ObjectInserter ins) |
|
|
@ -361,7 +360,7 @@ public class NoteMap implements Iterable<Note> { |
|
|
|
* |
|
|
|
* |
|
|
|
* @param noteOn |
|
|
|
* @param noteOn |
|
|
|
* the object to remove the note from. |
|
|
|
* the object to remove the note from. |
|
|
|
* @throws IOException |
|
|
|
* @throws java.io.IOException |
|
|
|
* a portion of the note space is not accessible. |
|
|
|
* a portion of the note space is not accessible. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void remove(AnyObjectId noteOn) throws IOException { |
|
|
|
public void remove(AnyObjectId noteOn) throws IOException { |
|
|
@ -376,7 +375,7 @@ public class NoteMap implements Iterable<Note> { |
|
|
|
* Caller is responsible for flushing the inserter before trying |
|
|
|
* Caller is responsible for flushing the inserter before trying |
|
|
|
* to read the objects, or exposing them through a reference. |
|
|
|
* to read the objects, or exposing them through a reference. |
|
|
|
* @return the top level tree. |
|
|
|
* @return the top level tree. |
|
|
|
* @throws IOException |
|
|
|
* @throws java.io.IOException |
|
|
|
* a tree could not be written. |
|
|
|
* a tree could not be written. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ObjectId writeTree(ObjectInserter inserter) throws IOException { |
|
|
|
public ObjectId writeTree(ObjectInserter inserter) throws IOException { |
|
|
|