Browse Source

Fix javadoc in org.eclipse.jgit storage/reftree package

Change-Id: Ie206b5340ad2019a1e0bd2bcede2c1e5a279f2d5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-4.10
Matthias Sohn 7 years ago
parent
commit
d0342be42d
  1. 7
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/AlwaysFailUpdate.java
  2. 45
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/Command.java
  3. 36
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTree.java
  4. 1
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeBatch.java
  5. 41
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeDatabase.java
  6. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeNames.java
  7. 1
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeRename.java
  8. 7
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeUpdate.java

7
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/AlwaysFailUpdate.java

@ -61,36 +61,43 @@ class AlwaysFailUpdate extends RefUpdate {
setCheckConflicting(false); setCheckConflicting(false);
} }
/** {@inheritDoc} */
@Override @Override
protected RefDatabase getRefDatabase() { protected RefDatabase getRefDatabase() {
return refdb; return refdb;
} }
/** {@inheritDoc} */
@Override @Override
protected Repository getRepository() { protected Repository getRepository() {
return refdb.getRepository(); return refdb.getRepository();
} }
/** {@inheritDoc} */
@Override @Override
protected boolean tryLock(boolean deref) throws IOException { protected boolean tryLock(boolean deref) throws IOException {
return false; return false;
} }
/** {@inheritDoc} */
@Override @Override
protected void unlock() { protected void unlock() {
// No locks are held here. // No locks are held here.
} }
/** {@inheritDoc} */
@Override @Override
protected Result doUpdate(Result desiredResult) { protected Result doUpdate(Result desiredResult) {
return Result.LOCK_FAILURE; return Result.LOCK_FAILURE;
} }
/** {@inheritDoc} */
@Override @Override
protected Result doDelete(Result desiredResult) { protected Result doDelete(Result desiredResult) {
return Result.LOCK_FAILURE; return Result.LOCK_FAILURE;
} }
/** {@inheritDoc} */
@Override @Override
protected Result doLink(String target) { protected Result doLink(String target) {
return Result.LOCK_FAILURE; return Result.LOCK_FAILURE;

45
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/Command.java

@ -69,25 +69,31 @@ import org.eclipse.jgit.transport.ReceiveCommand;
import org.eclipse.jgit.transport.ReceiveCommand.Result; import org.eclipse.jgit.transport.ReceiveCommand.Result;
/** /**
* Command to create, update or delete an entry inside a {@link RefTree}. * Command to create, update or delete an entry inside a
* {@link org.eclipse.jgit.internal.storage.reftree.RefTree}.
* <p> * <p>
* Unlike {@link ReceiveCommand} (which can only update a reference to an * Unlike {@link org.eclipse.jgit.transport.ReceiveCommand} (which can only
* {@link ObjectId}), a RefTree Command can also create, modify or delete * update a reference to an {@link org.eclipse.jgit.lib.ObjectId}), a RefTree
* symbolic references to a target reference. * Command can also create, modify or delete symbolic references to a target
* reference.
* <p> * <p>
* RefTree Commands may wrap a {@code ReceiveCommand} to allow callers to * RefTree Commands may wrap a {@code ReceiveCommand} to allow callers to
* process an existing ReceiveCommand against a RefTree. * process an existing ReceiveCommand against a RefTree.
* <p> * <p>
* Commands should be passed into {@link RefTree#apply(java.util.Collection)} * Commands should be passed into
* {@link org.eclipse.jgit.internal.storage.reftree.RefTree#apply(java.util.Collection)}
* for processing. * for processing.
*/ */
public class Command { public class Command {
/** /**
* Set unprocessed commands as failed due to transaction aborted. * Set unprocessed commands as failed due to transaction aborted.
* <p> * <p>
* If a command is still {@link Result#NOT_ATTEMPTED} it will be set to * If a command is still
* {@link Result#REJECTED_OTHER_REASON}. If {@code why} is non-null its * {@link org.eclipse.jgit.transport.ReceiveCommand.Result#NOT_ATTEMPTED} it
* contents will be used as the message for the first command status. * will be set to
* {@link org.eclipse.jgit.transport.ReceiveCommand.Result#REJECTED_OTHER_REASON}.
* If {@code why} is non-null its contents will be used as the message for
* the first command status.
* *
* @param commands * @param commands
* commands to mark as failed. * commands to mark as failed.
@ -147,9 +153,9 @@ public class Command {
* walk instance to peel the {@code newId}. * walk instance to peel the {@code newId}.
* @param cmd * @param cmd
* command received from a push client. * command received from a push client.
* @throws MissingObjectException * @throws org.eclipse.jgit.errors.MissingObjectException
* {@code oldId} or {@code newId} is missing. * {@code oldId} or {@code newId} is missing.
* @throws IOException * @throws java.io.IOException
* {@code oldId} or {@code newId} cannot be peeled. * {@code oldId} or {@code newId} cannot be peeled.
*/ */
public Command(RevWalk rw, ReceiveCommand cmd) public Command(RevWalk rw, ReceiveCommand cmd)
@ -186,7 +192,11 @@ public class Command {
} }
} }
/** @return name of the reference affected by this command. */ /**
* Get name of the reference affected by this command.
*
* @return name of the reference affected by this command.
*/
public String getRefName() { public String getRefName() {
if (cmd != null) { if (cmd != null) {
return cmd.getRefName(); return cmd.getRefName();
@ -222,12 +232,20 @@ public class Command {
} }
} }
/** @return result of executing this command. */ /**
* Get result of executing this command.
*
* @return result of executing this command.
*/
public Result getResult() { public Result getResult() {
return cmd != null ? cmd.getResult() : result; return cmd != null ? cmd.getResult() : result;
} }
/** @return optional message explaining command failure. */ /**
* Get optional message explaining command failure.
*
* @return optional message explaining command failure.
*/
@Nullable @Nullable
public String getMessage() { public String getMessage() {
return cmd != null ? cmd.getMessage() : null; return cmd != null ? cmd.getMessage() : null;
@ -253,6 +271,7 @@ public class Command {
return newRef; return newRef;
} }
/** {@inheritDoc} */
@Override @Override
public String toString() { public String toString() {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();

36
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTree.java

@ -74,7 +74,6 @@ import org.eclipse.jgit.errors.DirCacheNameConflictException;
import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectIdRef; import org.eclipse.jgit.lib.ObjectIdRef;
import org.eclipse.jgit.lib.ObjectInserter; import org.eclipse.jgit.lib.ObjectInserter;
@ -92,11 +91,13 @@ import org.eclipse.jgit.util.RawParseUtils;
* default reference {@code "refs/heads/master"} is stored at path * default reference {@code "refs/heads/master"} is stored at path
* {@code "heads/master"} in a {@code RefTree}. * {@code "heads/master"} in a {@code RefTree}.
* <p> * <p>
* Normal references are stored as {@link FileMode#GITLINK} tree entries. The * Normal references are stored as {@link org.eclipse.jgit.lib.FileMode#GITLINK}
* ObjectId in the tree entry is the ObjectId the reference refers to. * tree entries. The ObjectId in the tree entry is the ObjectId the reference
* refers to.
* <p> * <p>
* Symbolic references are stored as {@link FileMode#SYMLINK} entries, with the * Symbolic references are stored as
* blob storing the name of the target reference. * {@link org.eclipse.jgit.lib.FileMode#SYMLINK} entries, with the blob storing
* the name of the target reference.
* <p> * <p>
* Annotated tags also store the peeled object using a {@code GITLINK} entry * Annotated tags also store the peeled object using a {@code GITLINK} entry
* with the suffix <code>" ^"</code> (space carrot), for example * with the suffix <code>" ^"</code> (space carrot), for example
@ -127,13 +128,13 @@ public class RefTree {
* @param tree * @param tree
* the tree to read. * the tree to read.
* @return the ref tree read from the commit. * @return the ref tree 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 RefTree read(ObjectReader reader, RevTree tree) public static RefTree read(ObjectReader reader, RevTree tree)
@ -152,9 +153,10 @@ public class RefTree {
/** /**
* Read one reference. * Read one reference.
* <p> * <p>
* References are always returned peeled ({@link Ref#isPeeled()} is true). * References are always returned peeled
* If the reference points to an annotated tag, the returned reference will * ({@link org.eclipse.jgit.lib.Ref#isPeeled()} is true). If the reference
* be peeled and contain {@link Ref#getPeeledObjectId()}. * points to an annotated tag, the returned reference will be peeled and
* contain {@link org.eclipse.jgit.lib.Ref#getPeeledObjectId()}.
* <p> * <p>
* If the reference is a symbolic reference and the chain depth is less than * If the reference is a symbolic reference and the chain depth is less than
* {@link org.eclipse.jgit.lib.RefDatabase#MAX_SYMBOLIC_REF_DEPTH} the * {@link org.eclipse.jgit.lib.RefDatabase#MAX_SYMBOLIC_REF_DEPTH} the
@ -166,7 +168,7 @@ public class RefTree {
* @param name * @param name
* name of the reference to read. * name of the reference to read.
* @return the reference; null if it does not exist. * @return the reference; null if it does not exist.
* @throws IOException * @throws java.io.IOException
* cannot read a symbolic reference target. * cannot read a symbolic reference target.
*/ */
@Nullable @Nullable
@ -378,7 +380,7 @@ public class RefTree {
* 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 {
@ -391,7 +393,11 @@ public class RefTree {
return contents.writeTree(inserter); return contents.writeTree(inserter);
} }
/** @return a deep copy of this RefTree. */ /**
* Create a deep copy of this RefTree.
*
* @return a deep copy of this RefTree.
*/
public RefTree copy() { public RefTree copy() {
RefTree r = new RefTree(DirCache.newInCore()); RefTree r = new RefTree(DirCache.newInCore());
DirCacheBuilder b = r.contents.builder(); DirCacheBuilder b = r.contents.builder();

1
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeBatch.java

@ -87,6 +87,7 @@ class RefTreeBatch extends BatchRefUpdate {
this.refdb = refdb; this.refdb = refdb;
} }
/** {@inheritDoc} */
@Override @Override
public void execute(RevWalk rw, ProgressMonitor monitor) public void execute(RevWalk rw, ProgressMonitor monitor)
throws IOException { throws IOException {

41
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeDatabase.java

@ -74,13 +74,15 @@ import org.eclipse.jgit.util.RefList;
import org.eclipse.jgit.util.RefMap; import org.eclipse.jgit.util.RefMap;
/** /**
* Reference database backed by a {@link RefTree}. * Reference database backed by a
* {@link org.eclipse.jgit.internal.storage.reftree.RefTree}.
* <p> * <p>
* The storage for RefTreeDatabase has two parts. The main part is a native Git * The storage for RefTreeDatabase has two parts. The main part is a native Git
* tree object stored under the {@code refs/txn} namespace. To avoid cycles, * tree object stored under the {@code refs/txn} namespace. To avoid cycles,
* references to {@code refs/txn} are not stored in that tree object, but * references to {@code refs/txn} are not stored in that tree object, but
* instead in a "bootstrap" layer, which is a separate {@link RefDatabase} such * instead in a "bootstrap" layer, which is a separate
* as {@link org.eclipse.jgit.internal.storage.file.RefDirectory} using local * {@link org.eclipse.jgit.lib.RefDatabase} such as
* {@link org.eclipse.jgit.internal.storage.file.RefDirectory} using local
* reference files inside of {@code $GIT_DIR/refs}. * reference files inside of {@code $GIT_DIR/refs}.
*/ */
public class RefTreeDatabase extends RefDatabase { public class RefTreeDatabase extends RefDatabase {
@ -99,7 +101,8 @@ public class RefTreeDatabase extends RefDatabase {
* the repository using references in this database. * the repository using references in this database.
* @param bootstrap * @param bootstrap
* bootstrap reference database storing the references that * bootstrap reference database storing the references that
* anchor the {@link RefTree}. * anchor the
* {@link org.eclipse.jgit.internal.storage.reftree.RefTree}.
*/ */
public RefTreeDatabase(Repository repo, RefDatabase bootstrap) { public RefTreeDatabase(Repository repo, RefDatabase bootstrap) {
Config cfg = repo.getConfig(); Config cfg = repo.getConfig();
@ -121,7 +124,8 @@ public class RefTreeDatabase extends RefDatabase {
* the repository using references in this database. * the repository using references in this database.
* @param bootstrap * @param bootstrap
* bootstrap reference database storing the references that * bootstrap reference database storing the references that
* anchor the {@link RefTree}. * anchor the
* {@link org.eclipse.jgit.internal.storage.reftree.RefTree}.
* @param txnCommitted * @param txnCommitted
* name of the bootstrap reference holding the committed RefTree. * name of the bootstrap reference holding the committed RefTree.
*/ */
@ -146,6 +150,8 @@ public class RefTreeDatabase extends RefDatabase {
} }
/** /**
* Get the bootstrap reference database
*
* @return the bootstrap reference database, which must be used to access * @return the bootstrap reference database, which must be used to access
* {@link #getTxnCommitted()}, {@link #getTxnNamespace()}. * {@link #getTxnCommitted()}, {@link #getTxnNamespace()}.
*/ */
@ -153,41 +159,52 @@ public class RefTreeDatabase extends RefDatabase {
return bootstrap; return bootstrap;
} }
/** @return name of bootstrap reference anchoring committed RefTree. */ /**
* Get name of bootstrap reference anchoring committed RefTree.
*
* @return name of bootstrap reference anchoring committed RefTree.
*/
public String getTxnCommitted() { public String getTxnCommitted() {
return txnCommitted; return txnCommitted;
} }
/** /**
* @return namespace used by bootstrap layer, e.g. {@code refs/txn/}. * Get namespace used by bootstrap layer.
* Always ends in {@code '/'}. *
* @return namespace used by bootstrap layer, e.g. {@code refs/txn/}. Always
* ends in {@code '/'}.
*/ */
@Nullable @Nullable
public String getTxnNamespace() { public String getTxnNamespace() {
return txnNamespace; return txnNamespace;
} }
/** {@inheritDoc} */
@Override @Override
public void create() throws IOException { public void create() throws IOException {
bootstrap.create(); bootstrap.create();
} }
/** {@inheritDoc} */
@Override @Override
public boolean performsAtomicTransactions() { public boolean performsAtomicTransactions() {
return true; return true;
} }
/** {@inheritDoc} */
@Override @Override
public void refresh() { public void refresh() {
bootstrap.refresh(); bootstrap.refresh();
} }
/** {@inheritDoc} */
@Override @Override
public void close() { public void close() {
refs = null; refs = null;
bootstrap.close(); bootstrap.close();
} }
/** {@inheritDoc} */
@Override @Override
public Ref getRef(String name) throws IOException { public Ref getRef(String name) throws IOException {
String[] needle = new String[SEARCH_PATH.length]; String[] needle = new String[SEARCH_PATH.length];
@ -197,6 +214,7 @@ public class RefTreeDatabase extends RefDatabase {
return firstExactRef(needle); return firstExactRef(needle);
} }
/** {@inheritDoc} */
@Override @Override
public Ref exactRef(String name) throws IOException { public Ref exactRef(String name) throws IOException {
if (!repo.isBare() && name.indexOf('/') < 0 && !HEAD.equals(name)) { if (!repo.isBare() && name.indexOf('/') < 0 && !HEAD.equals(name)) {
@ -235,6 +253,7 @@ public class RefTreeDatabase extends RefDatabase {
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
} }
/** {@inheritDoc} */
@Override @Override
public Map<String, Ref> getRefs(String prefix) throws IOException { public Map<String, Ref> getRefs(String prefix) throws IOException {
if (!prefix.isEmpty() && prefix.charAt(prefix.length() - 1) != '/') { if (!prefix.isEmpty() && prefix.charAt(prefix.length() - 1) != '/') {
@ -258,6 +277,7 @@ public class RefTreeDatabase extends RefDatabase {
: ObjectId.zeroId(); : ObjectId.zeroId();
} }
/** {@inheritDoc} */
@Override @Override
public List<Ref> getAdditionalRefs() throws IOException { public List<Ref> getAdditionalRefs() throws IOException {
Collection<Ref> txnRefs; Collection<Ref> txnRefs;
@ -279,6 +299,7 @@ public class RefTreeDatabase extends RefDatabase {
return all; return all;
} }
/** {@inheritDoc} */
@Override @Override
public Ref peel(Ref ref) throws IOException { public Ref peel(Ref ref) throws IOException {
Ref i = ref.getLeaf(); Ref i = ref.getLeaf();
@ -306,17 +327,20 @@ public class RefTreeDatabase extends RefDatabase {
return leaf; return leaf;
} }
/** {@inheritDoc} */
@Override @Override
public boolean isNameConflicting(String name) throws IOException { public boolean isNameConflicting(String name) throws IOException {
return conflictsWithBootstrap(name) return conflictsWithBootstrap(name)
|| !getConflictingNames(name).isEmpty(); || !getConflictingNames(name).isEmpty();
} }
/** {@inheritDoc} */
@Override @Override
public BatchRefUpdate newBatchUpdate() { public BatchRefUpdate newBatchUpdate() {
return new RefTreeBatch(this); return new RefTreeBatch(this);
} }
/** {@inheritDoc} */
@Override @Override
public RefUpdate newUpdate(String name, boolean detach) throws IOException { public RefUpdate newUpdate(String name, boolean detach) throws IOException {
if (!repo.isBare() && name.indexOf('/') < 0 && !HEAD.equals(name)) { if (!repo.isBare() && name.indexOf('/') < 0 && !HEAD.equals(name)) {
@ -343,6 +367,7 @@ public class RefTreeDatabase extends RefDatabase {
return u; return u;
} }
/** {@inheritDoc} */
@Override @Override
public RefRename newRename(String fromName, String toName) public RefRename newRename(String fromName, String toName)
throws IOException { throws IOException {

4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeNames.java

@ -45,7 +45,9 @@ package org.eclipse.jgit.internal.storage.reftree;
import org.eclipse.jgit.lib.RefDatabase; import org.eclipse.jgit.lib.RefDatabase;
/** Magic reference name logic for RefTrees. */ /**
* Magic reference name logic for RefTrees.
*/
public class RefTreeNames { public class RefTreeNames {
/** /**
* Suffix used on a {@link RefTreeDatabase#getTxnNamespace()} for user data. * Suffix used on a {@link RefTreeDatabase#getTxnNamespace()} for user data.

1
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeRename.java

@ -69,6 +69,7 @@ class RefTreeRename extends RefRename {
this.refdb = refdb; this.refdb = refdb;
} }
/** {@inheritDoc} */
@Override @Override
protected Result doRename() throws IOException { protected Result doRename() throws IOException {
try (RevWalk rw = new RevWalk(refdb.getRepository())) { try (RevWalk rw = new RevWalk(refdb.getRepository())) {

7
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeUpdate.java

@ -76,16 +76,19 @@ class RefTreeUpdate extends RefUpdate {
setCheckConflicting(false); // Done automatically by doUpdate. setCheckConflicting(false); // Done automatically by doUpdate.
} }
/** {@inheritDoc} */
@Override @Override
protected RefDatabase getRefDatabase() { protected RefDatabase getRefDatabase() {
return refdb; return refdb;
} }
/** {@inheritDoc} */
@Override @Override
protected Repository getRepository() { protected Repository getRepository() {
return refdb.getRepository(); return refdb.getRepository();
} }
/** {@inheritDoc} */
@Override @Override
protected boolean tryLock(boolean deref) throws IOException { protected boolean tryLock(boolean deref) throws IOException {
rw = new RevWalk(getRepository()); rw = new RevWalk(getRepository());
@ -100,6 +103,7 @@ class RefTreeUpdate extends RefUpdate {
return true; return true;
} }
/** {@inheritDoc} */
@Override @Override
protected void unlock() { protected void unlock() {
batch = null; batch = null;
@ -109,6 +113,7 @@ class RefTreeUpdate extends RefUpdate {
} }
} }
/** {@inheritDoc} */
@Override @Override
protected Result doUpdate(Result desiredResult) throws IOException { protected Result doUpdate(Result desiredResult) throws IOException {
return run(newRef(getName(), getNewObjectId()), desiredResult); return run(newRef(getName(), getNewObjectId()), desiredResult);
@ -124,11 +129,13 @@ class RefTreeUpdate extends RefUpdate {
return new ObjectIdRef.PeeledNonTag(LOOSE, name, id); return new ObjectIdRef.PeeledNonTag(LOOSE, name, id);
} }
/** {@inheritDoc} */
@Override @Override
protected Result doDelete(Result desiredResult) throws IOException { protected Result doDelete(Result desiredResult) throws IOException {
return run(null, desiredResult); return run(null, desiredResult);
} }
/** {@inheritDoc} */
@Override @Override
protected Result doLink(String target) throws IOException { protected Result doLink(String target) throws IOException {
Ref dst = new ObjectIdRef.Unpeeled(NEW, target, null); Ref dst = new ObjectIdRef.Unpeeled(NEW, target, null);

Loading…
Cancel
Save