|
|
@ -64,7 +64,6 @@ import org.eclipse.jgit.lib.AnyObjectId; |
|
|
|
import org.eclipse.jgit.lib.Constants; |
|
|
|
import org.eclipse.jgit.lib.Constants; |
|
|
|
import org.eclipse.jgit.lib.CoreConfig; |
|
|
|
import org.eclipse.jgit.lib.CoreConfig; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.ObjectInserter; |
|
|
|
|
|
|
|
import org.eclipse.jgit.lib.ProgressMonitor; |
|
|
|
import org.eclipse.jgit.lib.ProgressMonitor; |
|
|
|
import org.eclipse.jgit.transport.PackParser; |
|
|
|
import org.eclipse.jgit.transport.PackParser; |
|
|
|
import org.eclipse.jgit.transport.PackedObjectInfo; |
|
|
|
import org.eclipse.jgit.transport.PackedObjectInfo; |
|
|
@ -72,10 +71,11 @@ import org.eclipse.jgit.util.FileUtils; |
|
|
|
import org.eclipse.jgit.util.NB; |
|
|
|
import org.eclipse.jgit.util.NB; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Consumes a pack stream and stores as a pack file in {@link ObjectDirectory}. |
|
|
|
* Consumes a pack stream and stores as a pack file in |
|
|
|
|
|
|
|
* {@link org.eclipse.jgit.internal.storage.file.ObjectDirectory}. |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* To obtain an instance of a parser, applications should use |
|
|
|
* To obtain an instance of a parser, applications should use |
|
|
|
* {@link ObjectInserter#newPackParser(InputStream)}. |
|
|
|
* {@link org.eclipse.jgit.lib.ObjectInserter#newPackParser(InputStream)}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class ObjectDirectoryPackParser extends PackParser { |
|
|
|
public class ObjectDirectoryPackParser extends PackParser { |
|
|
|
private final FileObjectDatabase db; |
|
|
|
private final FileObjectDatabase db; |
|
|
@ -158,7 +158,7 @@ public class ObjectDirectoryPackParser extends PackParser { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get the imported {@link PackFile}. |
|
|
|
* Get the imported {@link org.eclipse.jgit.internal.storage.file.PackFile}. |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* This method is supplied only to support testing; applications shouldn't |
|
|
|
* This method is supplied only to support testing; applications shouldn't |
|
|
|
* be using it directly to access the imported data. |
|
|
|
* be using it directly to access the imported data. |
|
|
@ -169,6 +169,7 @@ public class ObjectDirectoryPackParser extends PackParser { |
|
|
|
return newPack; |
|
|
|
return newPack; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public long getPackSize() { |
|
|
|
public long getPackSize() { |
|
|
|
if (newPack == null) |
|
|
|
if (newPack == null) |
|
|
@ -184,6 +185,7 @@ public class ObjectDirectoryPackParser extends PackParser { |
|
|
|
return size; |
|
|
|
return size; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public PackLock parse(ProgressMonitor receiving, ProgressMonitor resolving) |
|
|
|
public PackLock parse(ProgressMonitor receiving, ProgressMonitor resolving) |
|
|
|
throws IOException { |
|
|
|
throws IOException { |
|
|
@ -218,34 +220,40 @@ public class ObjectDirectoryPackParser extends PackParser { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onPackHeader(long objectCount) throws IOException { |
|
|
|
protected void onPackHeader(long objectCount) throws IOException { |
|
|
|
// Ignored, the count is not required.
|
|
|
|
// Ignored, the count is not required.
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onBeginWholeObject(long streamPosition, int type, |
|
|
|
protected void onBeginWholeObject(long streamPosition, int type, |
|
|
|
long inflatedSize) throws IOException { |
|
|
|
long inflatedSize) throws IOException { |
|
|
|
crc.reset(); |
|
|
|
crc.reset(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onEndWholeObject(PackedObjectInfo info) throws IOException { |
|
|
|
protected void onEndWholeObject(PackedObjectInfo info) throws IOException { |
|
|
|
info.setCRC((int) crc.getValue()); |
|
|
|
info.setCRC((int) crc.getValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onBeginOfsDelta(long streamPosition, |
|
|
|
protected void onBeginOfsDelta(long streamPosition, |
|
|
|
long baseStreamPosition, long inflatedSize) throws IOException { |
|
|
|
long baseStreamPosition, long inflatedSize) throws IOException { |
|
|
|
crc.reset(); |
|
|
|
crc.reset(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onBeginRefDelta(long streamPosition, AnyObjectId baseId, |
|
|
|
protected void onBeginRefDelta(long streamPosition, AnyObjectId baseId, |
|
|
|
long inflatedSize) throws IOException { |
|
|
|
long inflatedSize) throws IOException { |
|
|
|
crc.reset(); |
|
|
|
crc.reset(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected UnresolvedDelta onEndDelta() throws IOException { |
|
|
|
protected UnresolvedDelta onEndDelta() throws IOException { |
|
|
|
UnresolvedDelta delta = new UnresolvedDelta(); |
|
|
|
UnresolvedDelta delta = new UnresolvedDelta(); |
|
|
@ -253,30 +261,35 @@ public class ObjectDirectoryPackParser extends PackParser { |
|
|
|
return delta; |
|
|
|
return delta; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onInflatedObjectData(PackedObjectInfo obj, int typeCode, |
|
|
|
protected void onInflatedObjectData(PackedObjectInfo obj, int typeCode, |
|
|
|
byte[] data) throws IOException { |
|
|
|
byte[] data) throws IOException { |
|
|
|
// ObjectDirectory ignores this event.
|
|
|
|
// ObjectDirectory ignores this event.
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onObjectHeader(Source src, byte[] raw, int pos, int len) |
|
|
|
protected void onObjectHeader(Source src, byte[] raw, int pos, int len) |
|
|
|
throws IOException { |
|
|
|
throws IOException { |
|
|
|
crc.update(raw, pos, len); |
|
|
|
crc.update(raw, pos, len); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onObjectData(Source src, byte[] raw, int pos, int len) |
|
|
|
protected void onObjectData(Source src, byte[] raw, int pos, int len) |
|
|
|
throws IOException { |
|
|
|
throws IOException { |
|
|
|
crc.update(raw, pos, len); |
|
|
|
crc.update(raw, pos, len); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onStoreStream(byte[] raw, int pos, int len) |
|
|
|
protected void onStoreStream(byte[] raw, int pos, int len) |
|
|
|
throws IOException { |
|
|
|
throws IOException { |
|
|
|
out.write(raw, pos, len); |
|
|
|
out.write(raw, pos, len); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onPackFooter(byte[] hash) throws IOException { |
|
|
|
protected void onPackFooter(byte[] hash) throws IOException { |
|
|
|
packEnd = out.getFilePointer(); |
|
|
|
packEnd = out.getFilePointer(); |
|
|
@ -285,6 +298,7 @@ public class ObjectDirectoryPackParser extends PackParser { |
|
|
|
packHash = hash; |
|
|
|
packHash = hash; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected ObjectTypeAndSize seekDatabase(UnresolvedDelta delta, |
|
|
|
protected ObjectTypeAndSize seekDatabase(UnresolvedDelta delta, |
|
|
|
ObjectTypeAndSize info) throws IOException { |
|
|
|
ObjectTypeAndSize info) throws IOException { |
|
|
@ -293,6 +307,7 @@ public class ObjectDirectoryPackParser extends PackParser { |
|
|
|
return readObjectHeader(info); |
|
|
|
return readObjectHeader(info); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected ObjectTypeAndSize seekDatabase(PackedObjectInfo obj, |
|
|
|
protected ObjectTypeAndSize seekDatabase(PackedObjectInfo obj, |
|
|
|
ObjectTypeAndSize info) throws IOException { |
|
|
|
ObjectTypeAndSize info) throws IOException { |
|
|
@ -301,11 +316,13 @@ public class ObjectDirectoryPackParser extends PackParser { |
|
|
|
return readObjectHeader(info); |
|
|
|
return readObjectHeader(info); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected int readDatabase(byte[] dst, int pos, int cnt) throws IOException { |
|
|
|
protected int readDatabase(byte[] dst, int pos, int cnt) throws IOException { |
|
|
|
return out.read(dst, pos, cnt); |
|
|
|
return out.read(dst, pos, cnt); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected boolean checkCRC(int oldCRC) { |
|
|
|
protected boolean checkCRC(int oldCRC) { |
|
|
|
return oldCRC == (int) crc.getValue(); |
|
|
|
return oldCRC == (int) crc.getValue(); |
|
|
@ -323,6 +340,7 @@ public class ObjectDirectoryPackParser extends PackParser { |
|
|
|
tmpPack.deleteOnExit(); |
|
|
|
tmpPack.deleteOnExit(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected boolean onAppendBase(final int typeCode, final byte[] data, |
|
|
|
protected boolean onAppendBase(final int typeCode, final byte[] data, |
|
|
|
final PackedObjectInfo info) throws IOException { |
|
|
|
final PackedObjectInfo info) throws IOException { |
|
|
@ -365,6 +383,7 @@ public class ObjectDirectoryPackParser extends PackParser { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onEndThinPack() throws IOException { |
|
|
|
protected void onEndThinPack() throws IOException { |
|
|
|
final byte[] buf = buffer(); |
|
|
|
final byte[] buf = buffer(); |
|
|
|