aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/storage
diff options
context:
space:
mode:
authorColby Ranger <cranger@google.com>2012-08-27 16:08:42 -0700
committerColby Ranger <cranger@google.com>2013-03-04 14:43:22 -0800
commitbe7a135e94d9c71da3e9cd28edfd10ba7be3747d (patch)
tree81b568ea51d6ff687149c9c6173263796508147f /org.eclipse.jgit/src/org/eclipse/jgit/storage
parent8d4f227c138bf3ccf13cf83ab63fde2fc49d3756 (diff)
downloadjgit-be7a135e94d9c71da3e9cd28edfd10ba7be3747d.tar.gz
jgit-be7a135e94d9c71da3e9cd28edfd10ba7be3747d.zip
Break the dependency on RevObject when creating a newObjectToPack().
Update the ObjectReuseAsIs API to support creating new ObjectToPack with only the AnyObjectId and Git object type. This is needed to support the future pack index bitmaps, which only contain this information and do not want the overhead of creating a temporary object for every ObjectId. Change-Id: I906360b471412688bf429ecef74fd988f47875dc
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/storage')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjectToPack.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsReader.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LocalObjectToPack.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCursor.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/ObjectReuseAsIs.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/ObjectToPack.java13
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java11
7 files changed, 24 insertions, 34 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjectToPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjectToPack.java
index c5243d9945..7efa96668e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjectToPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjectToPack.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.storage.dfs;
-import org.eclipse.jgit.revwalk.RevObject;
+import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.storage.pack.ObjectToPack;
import org.eclipse.jgit.storage.pack.StoredObjectRepresentation;
@@ -61,8 +61,8 @@ class DfsObjectToPack extends ObjectToPack {
/** Length of the data section of the object. */
long length;
- DfsObjectToPack(RevObject obj) {
- super(obj);
+ DfsObjectToPack(AnyObjectId src, final int type) {
+ super(src, type);
}
@Override
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsReader.java
index 393fa3fce2..e22e13eaf9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsReader.java
@@ -83,7 +83,6 @@ import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.revwalk.ObjectWalk;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.revwalk.RevObject;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.storage.pack.CachedPack;
import org.eclipse.jgit.storage.pack.ObjectReuseAsIs;
@@ -433,8 +432,8 @@ public final class DfsReader extends ObjectReader implements ObjectReuseAsIs {
throw new MissingObjectException(objectId.copy(), typeHint);
}
- public DfsObjectToPack newObjectToPack(RevObject obj) {
- return new DfsObjectToPack(obj);
+ public DfsObjectToPack newObjectToPack(AnyObjectId objectId, int type) {
+ return new DfsObjectToPack(objectId, type);
}
private static final Comparator<DfsObjectRepresentation> REPRESENTATION_SORT = new Comparator<DfsObjectRepresentation>() {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LocalObjectToPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LocalObjectToPack.java
index c7ef2c9133..c7d822c976 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LocalObjectToPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LocalObjectToPack.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.storage.file;
-import org.eclipse.jgit.revwalk.RevObject;
+import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.storage.pack.ObjectToPack;
import org.eclipse.jgit.storage.pack.StoredObjectRepresentation;
@@ -58,8 +58,8 @@ class LocalObjectToPack extends ObjectToPack {
/** Length of the data section of the object. */
long length;
- LocalObjectToPack(RevObject obj) {
- super(obj);
+ LocalObjectToPack(AnyObjectId src, final int type) {
+ super(src, type);
}
@Override
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCursor.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCursor.java
index 5555a3c404..350f981b25 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCursor.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCursor.java
@@ -68,7 +68,6 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectLoader;
import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.ProgressMonitor;
-import org.eclipse.jgit.revwalk.RevObject;
import org.eclipse.jgit.storage.pack.CachedPack;
import org.eclipse.jgit.storage.pack.ObjectReuseAsIs;
import org.eclipse.jgit.storage.pack.ObjectToPack;
@@ -148,8 +147,8 @@ final class WindowCursor extends ObjectReader implements ObjectReuseAsIs {
return sz;
}
- public LocalObjectToPack newObjectToPack(RevObject obj) {
- return new LocalObjectToPack(obj);
+ public LocalObjectToPack newObjectToPack(AnyObjectId objectId, int type) {
+ return new LocalObjectToPack(objectId, type);
}
public void selectObjectRepresentation(PackWriter packer,
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/ObjectReuseAsIs.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/ObjectReuseAsIs.java
index 795b004e82..ed0294ed30 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/ObjectReuseAsIs.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/ObjectReuseAsIs.java
@@ -49,9 +49,9 @@ import java.util.List;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException;
+import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.ProgressMonitor;
-import org.eclipse.jgit.revwalk.RevObject;
/**
* Extension of {@link ObjectReader} that supports reusing objects in packs.
@@ -71,13 +71,13 @@ public interface ObjectReuseAsIs {
* object state, such as to remember what file and offset contains the
* object's pack encoded data.
*
- * @param obj
- * identity of the object that will be packed. The object's
- * parsed status is undefined here. Implementers must not rely on
- * the object being parsed.
+ * @param objectId
+ * the id of the object that will be packed.
+ * @param type
+ * the Git type of the object that will be packed.
* @return a new instance for this object.
*/
- public ObjectToPack newObjectToPack(RevObject obj);
+ public ObjectToPack newObjectToPack(AnyObjectId objectId, int type);
/**
* Select the best object representation for a packer.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/ObjectToPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/ObjectToPack.java
index 1b8a9bf600..b42d4a5e4e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/ObjectToPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/ObjectToPack.java
@@ -47,7 +47,6 @@ package org.eclipse.jgit.storage.pack;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
-import org.eclipse.jgit.revwalk.RevObject;
import org.eclipse.jgit.transport.PackedObjectInfo;
/**
@@ -121,18 +120,6 @@ public class ObjectToPack extends PackedObjectInfo {
}
/**
- * Construct for the specified object.
- *
- * @param obj
- * identity of the object that will be packed. The object's
- * parsed status is undefined here. Implementers must not rely on
- * the object being parsed.
- */
- public ObjectToPack(RevObject obj) {
- this(obj, obj.getType());
- }
-
- /**
* @return delta base object id if object is going to be packed in delta
* representation; null otherwise - if going to be packed as a
* whole object.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
index 1cf1781289..77ebaf618b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
@@ -1826,13 +1826,18 @@ public class PackWriter {
}
private void addObject(final RevObject object, final int pathHashCode) {
+ addObject(object, object.getType(), pathHashCode);
+ }
+
+ private void addObject(
+ final AnyObjectId src, final int type, final int pathHashCode) {
final ObjectToPack otp;
if (reuseSupport != null)
- otp = reuseSupport.newObjectToPack(object);
+ otp = reuseSupport.newObjectToPack(src, type);
else
- otp = new ObjectToPack(object);
+ otp = new ObjectToPack(src, type);
otp.setPathHash(pathHashCode);
- objectsLists[object.getType()].add(otp);
+ objectsLists[type].add(otp);
objectsMap.add(otp);
}