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; }
@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(); } } }
@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()); }