|
|
|
@ -477,12 +477,13 @@ public class PackWriter {
|
|
|
|
|
* points of graph traversal). |
|
|
|
|
* @throws IOException |
|
|
|
|
* when some I/O problem occur during reading objects. |
|
|
|
|
* @deprecated to be removed in 2.0; use the Set version of this method. |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public void preparePack(ProgressMonitor countingMonitor, |
|
|
|
|
final Collection<? extends ObjectId> want, |
|
|
|
|
final Collection<? extends ObjectId> have) throws IOException { |
|
|
|
|
ObjectWalk ow = new ObjectWalk(reader); |
|
|
|
|
preparePack(countingMonitor, ow, want, have); |
|
|
|
|
preparePack(countingMonitor, ensureSet(want), ensureSet(have)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -509,12 +510,91 @@ public class PackWriter {
|
|
|
|
|
* points of graph traversal). |
|
|
|
|
* @throws IOException |
|
|
|
|
* when some I/O problem occur during reading objects. |
|
|
|
|
* @deprecated to be removed in 2.0; use the Set version of this method. |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public void preparePack(ProgressMonitor countingMonitor, |
|
|
|
|
final ObjectWalk walk, |
|
|
|
|
final Collection<? extends ObjectId> interestingObjects, |
|
|
|
|
final Collection<? extends ObjectId> uninterestingObjects) |
|
|
|
|
throws IOException { |
|
|
|
|
preparePack(countingMonitor, walk, |
|
|
|
|
ensureSet(interestingObjects), |
|
|
|
|
ensureSet(uninterestingObjects)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
private static Set<ObjectId> ensureSet(Collection<? extends ObjectId> objs) { |
|
|
|
|
Set<ObjectId> set; |
|
|
|
|
if (objs instanceof Set<?>) |
|
|
|
|
set = (Set<ObjectId>) objs; |
|
|
|
|
else if (objs == null) |
|
|
|
|
set = Collections.emptySet(); |
|
|
|
|
else |
|
|
|
|
set = new HashSet<ObjectId>(objs); |
|
|
|
|
return set; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Prepare the list of objects to be written to the pack stream. |
|
|
|
|
* <p> |
|
|
|
|
* Basing on these 2 sets, another set of objects to put in a pack file is |
|
|
|
|
* created: this set consists of all objects reachable (ancestors) from |
|
|
|
|
* interesting objects, except uninteresting objects and their ancestors. |
|
|
|
|
* This method uses class {@link ObjectWalk} extensively to find out that |
|
|
|
|
* appropriate set of output objects and their optimal order in output pack. |
|
|
|
|
* Order is consistent with general git in-pack rules: sort by object type, |
|
|
|
|
* recency, path and delta-base first. |
|
|
|
|
* </p> |
|
|
|
|
* |
|
|
|
|
* @param countingMonitor |
|
|
|
|
* progress during object enumeration. |
|
|
|
|
* @param want |
|
|
|
|
* collection of objects to be marked as interesting (start |
|
|
|
|
* points of graph traversal). |
|
|
|
|
* @param have |
|
|
|
|
* collection of objects to be marked as uninteresting (end |
|
|
|
|
* points of graph traversal). |
|
|
|
|
* @throws IOException |
|
|
|
|
* when some I/O problem occur during reading objects. |
|
|
|
|
*/ |
|
|
|
|
public void preparePack(ProgressMonitor countingMonitor, |
|
|
|
|
Set<? extends ObjectId> want, |
|
|
|
|
Set<? extends ObjectId> have) throws IOException { |
|
|
|
|
ObjectWalk ow = new ObjectWalk(reader); |
|
|
|
|
preparePack(countingMonitor, ow, want, have); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Prepare the list of objects to be written to the pack stream. |
|
|
|
|
* <p> |
|
|
|
|
* Basing on these 2 sets, another set of objects to put in a pack file is |
|
|
|
|
* created: this set consists of all objects reachable (ancestors) from |
|
|
|
|
* interesting objects, except uninteresting objects and their ancestors. |
|
|
|
|
* This method uses class {@link ObjectWalk} extensively to find out that |
|
|
|
|
* appropriate set of output objects and their optimal order in output pack. |
|
|
|
|
* Order is consistent with general git in-pack rules: sort by object type, |
|
|
|
|
* recency, path and delta-base first. |
|
|
|
|
* </p> |
|
|
|
|
* |
|
|
|
|
* @param countingMonitor |
|
|
|
|
* progress during object enumeration. |
|
|
|
|
* @param walk |
|
|
|
|
* ObjectWalk to perform enumeration. |
|
|
|
|
* @param interestingObjects |
|
|
|
|
* collection of objects to be marked as interesting (start |
|
|
|
|
* points of graph traversal). |
|
|
|
|
* @param uninterestingObjects |
|
|
|
|
* collection of objects to be marked as uninteresting (end |
|
|
|
|
* points of graph traversal). |
|
|
|
|
* @throws IOException |
|
|
|
|
* when some I/O problem occur during reading objects. |
|
|
|
|
*/ |
|
|
|
|
public void preparePack(ProgressMonitor countingMonitor, |
|
|
|
|
final ObjectWalk walk, |
|
|
|
|
final Set<? extends ObjectId> interestingObjects, |
|
|
|
|
final Set<? extends ObjectId> uninterestingObjects) |
|
|
|
|
throws IOException { |
|
|
|
|
if (countingMonitor == null) |
|
|
|
|
countingMonitor = NullProgressMonitor.INSTANCE; |
|
|
|
|
findObjectsToPack(countingMonitor, walk, interestingObjects, |
|
|
|
@ -566,10 +646,10 @@ public class PackWriter {
|
|
|
|
|
/** |
|
|
|
|
* Create an index file to match the pack file just written. |
|
|
|
|
* <p> |
|
|
|
|
* This method can only be invoked after {@link #preparePack(Iterator)} or |
|
|
|
|
* {@link #preparePack(ProgressMonitor, Collection, Collection)} has been |
|
|
|
|
* invoked and completed successfully. Writing a corresponding index is an |
|
|
|
|
* optional feature that not all pack users may require. |
|
|
|
|
* This method can only be invoked after |
|
|
|
|
* {@link #writePack(ProgressMonitor, ProgressMonitor, OutputStream)} has |
|
|
|
|
* been invoked and completed successfully. Writing a corresponding index is |
|
|
|
|
* an optional feature that not all pack users may require. |
|
|
|
|
* |
|
|
|
|
* @param indexStream |
|
|
|
|
* output for the index data. Caller is responsible for closing |
|
|
|
@ -1256,8 +1336,8 @@ public class PackWriter {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void findObjectsToPack(final ProgressMonitor countingMonitor, |
|
|
|
|
final ObjectWalk walker, final Collection<? extends ObjectId> want, |
|
|
|
|
Collection<? extends ObjectId> have) |
|
|
|
|
final ObjectWalk walker, final Set<? extends ObjectId> want, |
|
|
|
|
Set<? extends ObjectId> have) |
|
|
|
|
throws MissingObjectException, IOException, |
|
|
|
|
IncorrectObjectTypeException { |
|
|
|
|
final long countingStart = System.currentTimeMillis(); |
|
|
|
|