Bug: 573770 Change-Id: I78e1c7d3e042eaef64e85bc546af207478f2e334changes/06/182906/3
import java.io.IOException; | import java.io.IOException; | ||||
import java.util.List; | import java.util.List; | ||||
import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | |||||
import org.eclipse.jgit.errors.StoredPackRepresentationNotAvailableException; | |||||
import org.eclipse.jgit.internal.storage.pack.CachedPack; | import org.eclipse.jgit.internal.storage.pack.CachedPack; | ||||
import org.eclipse.jgit.internal.storage.pack.ObjectToPack; | import org.eclipse.jgit.internal.storage.pack.ObjectToPack; | ||||
import org.eclipse.jgit.internal.storage.pack.PackExt; | import org.eclipse.jgit.internal.storage.pack.PackExt; | ||||
} | } | ||||
void copyAsIs(PackOutputStream out, WindowCursor wc) | void copyAsIs(PackOutputStream out, WindowCursor wc) | ||||
throws IOException { | |||||
throws IOException, StoredPackRepresentationNotAvailableException { | |||||
for (Pack pack : getPacks()) | for (Pack pack : getPacks()) | ||||
pack.copyPackAsIs(out, wc); | pack.copyPackAsIs(out, wc); | ||||
} | } |
import org.eclipse.jgit.errors.PackInvalidException; | import org.eclipse.jgit.errors.PackInvalidException; | ||||
import org.eclipse.jgit.errors.PackMismatchException; | import org.eclipse.jgit.errors.PackMismatchException; | ||||
import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | ||||
import org.eclipse.jgit.errors.StoredPackRepresentationNotAvailableException; | |||||
import org.eclipse.jgit.errors.UnpackException; | import org.eclipse.jgit.errors.UnpackException; | ||||
import org.eclipse.jgit.errors.UnsupportedPackIndexVersionException; | import org.eclipse.jgit.errors.UnsupportedPackIndexVersionException; | ||||
import org.eclipse.jgit.errors.UnsupportedPackVersionException; | import org.eclipse.jgit.errors.UnsupportedPackVersionException; | ||||
} | } | ||||
void copyPackAsIs(PackOutputStream out, WindowCursor curs) | void copyPackAsIs(PackOutputStream out, WindowCursor curs) | ||||
throws IOException { | |||||
throws IOException, StoredPackRepresentationNotAvailableException { | |||||
// Pin the first window, this ensures the length is accurate. | // Pin the first window, this ensures the length is accurate. | ||||
curs.pin(this, 0); | curs.pin(this, 0); | ||||
curs.copyPackAsIs(this, length, out); | curs.copyPackAsIs(this, length, out); |
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.errors.StoredObjectRepresentationNotAvailableException; | import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | ||||
import org.eclipse.jgit.errors.StoredPackRepresentationNotAvailableException; | |||||
import org.eclipse.jgit.internal.JGitText; | import org.eclipse.jgit.internal.JGitText; | ||||
import org.eclipse.jgit.internal.storage.pack.CachedPack; | import org.eclipse.jgit.internal.storage.pack.CachedPack; | ||||
import org.eclipse.jgit.internal.storage.pack.ObjectReuseAsIs; | import org.eclipse.jgit.internal.storage.pack.ObjectReuseAsIs; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
@Override | @Override | ||||
public void copyPackAsIs(PackOutputStream out, CachedPack pack) | public void copyPackAsIs(PackOutputStream out, CachedPack pack) | ||||
throws IOException { | |||||
throws IOException, StoredPackRepresentationNotAvailableException { | |||||
((LocalCachedPack) pack).copyAsIs(out, this); | ((LocalCachedPack) pack).copyAsIs(out, this); | ||||
} | } | ||||
void copyPackAsIs(final Pack pack, final long length, | void copyPackAsIs(final Pack pack, final long length, | ||||
final PackOutputStream out) throws IOException { | |||||
final PackOutputStream out) throws IOException, StoredPackRepresentationNotAvailableException { | |||||
long position = 12; | long position = 12; | ||||
long remaining = length - (12 + 20); | long remaining = length - (12 + 20); | ||||
while (0 < remaining) { | while (0 < remaining) { | ||||
pin(pack, position); | |||||
try { | |||||
pin(pack, position); | |||||
int ptr = (int) (position - window.start); | |||||
int n = (int) Math.min(window.size() - ptr, remaining); | |||||
window.write(out, position, n); | |||||
position += n; | |||||
remaining -= n; | |||||
int ptr = (int) (position - window.start); | |||||
int n = (int) Math.min(window.size() - ptr, remaining); | |||||
window.write(out, position, n); | |||||
position += n; | |||||
remaining -= n; | |||||
} catch (Exception e) { | |||||
throw new StoredPackRepresentationNotAvailableException(pack, | |||||
e); | |||||
} | |||||
} | } | ||||
} | } | ||||
import org.eclipse.jgit.errors.MissingObjectException; | import org.eclipse.jgit.errors.MissingObjectException; | ||||
import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | ||||
import org.eclipse.jgit.errors.StoredPackRepresentationNotAvailableException; | |||||
import org.eclipse.jgit.lib.AnyObjectId; | import org.eclipse.jgit.lib.AnyObjectId; | ||||
import org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder; | import org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder; | ||||
import org.eclipse.jgit.lib.ProgressMonitor; | import org.eclipse.jgit.lib.ProgressMonitor; | ||||
* the pack cannot be read, or stream did not accept a write. | * the pack cannot be read, or stream did not accept a write. | ||||
*/ | */ | ||||
void copyPackAsIs(PackOutputStream out, CachedPack pack) | void copyPackAsIs(PackOutputStream out, CachedPack pack) | ||||
throws IOException; | |||||
throws IOException, StoredPackRepresentationNotAvailableException; | |||||
/** | /** | ||||
* Obtain the available cached packs that match the bitmap and update | * Obtain the available cached packs that match the bitmap and update |
import org.eclipse.jgit.errors.MissingObjectException; | import org.eclipse.jgit.errors.MissingObjectException; | ||||
import org.eclipse.jgit.errors.SearchForReuseTimeout; | import org.eclipse.jgit.errors.SearchForReuseTimeout; | ||||
import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | ||||
import org.eclipse.jgit.errors.StoredPackRepresentationNotAvailableException; | |||||
import org.eclipse.jgit.internal.JGitText; | import org.eclipse.jgit.internal.JGitText; | ||||
import org.eclipse.jgit.internal.storage.file.PackBitmapIndexBuilder; | import org.eclipse.jgit.internal.storage.file.PackBitmapIndexBuilder; | ||||
import org.eclipse.jgit.internal.storage.file.PackBitmapIndexWriterV1; | import org.eclipse.jgit.internal.storage.file.PackBitmapIndexWriterV1; | ||||
} | } | ||||
writeChecksum(out); | writeChecksum(out); | ||||
out.flush(); | out.flush(); | ||||
} catch (StoredPackRepresentationNotAvailableException s) { | |||||
//XXX Reload packfiles and try again... | |||||
} finally { | } finally { | ||||
stats.timeWriting = System.currentTimeMillis() - writeStart; | stats.timeWriting = System.currentTimeMillis() - writeStart; | ||||
stats.depth = depth; | stats.depth = depth; |