public @Override void findSuccessors(final Object object, final List<Object> successors, ObjectStore database) { ObjectId id = id(object); if (!deduplicator.isDuplicate(id)) { final int oldSize = successors.size(); delegate.findSuccessors(object, successors, database); List<Object> subList = successors.subList(oldSize, successors.size()); deduplicator.removeDuplicates(Lists.transform(subList, (o) -> id(o))); } }
/** * Checks whether the {@code left} has already been compared against {@code right} * * @return {@code true} if the pair of ids weren't already visited and are marked * visited as result to this call, {@code false} if this pair was already * visited. */ private boolean visitPair(ObjectId left, ObjectId right) { return deduplicator.visit(left, right); }
public @Override List<RefDiff> applyTo(PackProcessor target, ProgressListener progress) { checkNotNull(target); checkNotNull(progress); List<RefDiff> result = new ArrayList<>(); List<RefRequest> reqs = Lists.newArrayList(missingCommits.keySet()); Deduplicator deduplicator = DeduplicationService.create(); try { for (RefRequest req : reqs) { RefDiff changedRef = applyToPreOrder(target, req, deduplicator, progress); checkNotNull(changedRef); result.add(changedRef); } } finally { deduplicator.release(); } List<RevTag> tags = this.missingTags; target.putAll(tags.iterator(), NOOP_LISTENER); return result; }
final ObjectId rightRootId = commit.getTreeId(); if (deduplicator.isDuplicate(rightRootId)) { return;
private void visitPreorder(final ObjectId leftTreeId, final ObjectId rightTreeId, Deduplicator deduplicator, ObjectReporter progress, Consumer<ObjectId> consumer) { if (deduplicator.isDuplicate(rightTreeId)) { return;
/** * Checks whether the {@code left} has already been compared against {@code right} * * @return {@code true} if the pair of ids weren't already visited and are marked * visited as result to this call, {@code false} if this pair was already * visited. */ private boolean visitPair(ObjectId left, ObjectId right) { return deduplicator.visit(left, right); }
@Override protected void encode(OutputStream out) { if (packer != null && deduplicator != null) { CountingOutputStream counting = new CountingOutputStream(out); OutputStream output = counting; try { ObjectFunnel funnel; funnel = ObjectFunnels.newFunnel(output, DataStreamSerializationFactoryV1.INSTANCE); packer.write(funnel, want, have, false, deduplicator); counting.flush(); funnel.close(); } catch (Exception e) { throw new RuntimeException(e); } finally { deduplicator.release(); } } }
/** * Calls {@link Consumer#accept consumer.accept(ObjectId}} with this id if it wasn't * already visited and returns {@code true}, or {@code false} if the id was already * visited and hence consumed */ private boolean consume(ObjectId objectId) { if (deduplicator.visit(objectId)) { consumer.accept(objectId); return true; } return false; }
@Override public void pushNewData(final Repository local, Ref ref, String refspec, ProgressListener progress) throws SynchronizationException { Optional<Ref> remoteRef = HttpUtils.getRemoteRef(repositoryURL, refspec); checkPush(local, ref, remoteRef); beginPush(); progress.setDescription("Uploading objects to " + refspec); progress.setProgress(0); CommitTraverser traverser = getPushTraverser(local, remoteRef); traverser.traverse(ref.getObjectId()); List<ObjectId> toSend = new LinkedList<ObjectId>(traverser.commits); Collections.reverse(toSend); Set<ObjectId> have = new HashSet<ObjectId>(traverser.have); Deduplicator deduplicator = createDeduplicator(); try { sendPackedObjects(local, toSend, have, deduplicator, progress); } finally { deduplicator.release(); } ObjectId originalRemoteRefValue = ObjectId.NULL; if (remoteRef.isPresent()) { originalRemoteRefValue = remoteRef.get().getObjectId(); } String nameToSet = remoteRef.isPresent() ? remoteRef.get().getName() : Ref.HEADS_PREFIX + refspec; endPush(nameToSet, ref.getObjectId(), originalRemoteRefValue.toString()); }
/** * Calls {@link Consumer#accept consumer.accept(ObjectId}} with this id if it wasn't * already visited and returns {@code true}, or {@code false} if the id was already * visited and hence consumed */ private boolean consume(ObjectId objectId) { if (deduplicator.visit(objectId)) { consumer.accept(objectId); return true; } return false; }
public boolean previsit(ObjectId id) { return deduplicator.visit(id) && delegate.previsit(id); } };