/// <exception cref="System.IO.IOException"></exception> private void ResolveDeltasWithExternalBases(ProgressMonitor progress) { GrowEntries(baseById.Size()); if (needBaseObjectIds) { baseObjectIds = new ObjectIdSubclassMap<ObjectId>(); } IList<PackParser.DeltaChain> missing = new AList<PackParser.DeltaChain>(64); foreach (PackParser.DeltaChain baseId in baseById) { if (baseId.head == null) { continue; } if (needBaseObjectIds) { baseObjectIds.Add(baseId); } ObjectLoader ldr; try { ldr = readCurs.Open(baseId); } catch (MissingObjectException) { missing.AddItem(baseId); continue; } PackParser.DeltaVisit visit = new PackParser.DeltaVisit(); visit.data = ldr.GetCachedBytes(int.MaxValue); visit.id = baseId; int typeCode = ldr.GetType(); PackedObjectInfo oe = NewInfo(baseId, null, null); if (OnAppendBase(typeCode, visit.data, oe)) { entries[entryCount++] = oe; } visit.nextChild = FirstChildOf(oe); ResolveDeltas(visit.Next(), typeCode, new PackParser.ObjectTypeAndSize(), progress ); if (progress.IsCancelled()) { throw new IOException(JGitText.Get().downloadCancelledDuringIndexing); } } foreach (PackParser.DeltaChain @base in missing) { if (@base.head != null) { throw new MissingObjectException(@base, "delta base"); } } OnEndThinPack(); }
internal virtual PackParser.DeltaVisit Next() { // If our parent has no more children, discard it. if (parent != null && parent.nextChild == null) { parent.data = null; parent = parent.parent; } if (nextChild != null) { return new PackParser.DeltaVisit(this); } // If we have no child ourselves, our parent must (if it exists), // due to the discard rule above. With no parent, we are done. if (parent != null) { return new PackParser.DeltaVisit(parent); } return null; }
/// <exception cref="System.IO.IOException"></exception> private void ResolveDeltas(PackedObjectInfo oe, ProgressMonitor progress) { PackParser.UnresolvedDelta children = FirstChildOf(oe); if (children == null) { return; } PackParser.DeltaVisit visit = new PackParser.DeltaVisit(); visit.nextChild = children; PackParser.ObjectTypeAndSize info = OpenDatabase(oe, new PackParser.ObjectTypeAndSize ()); switch (info.type) { case Constants.OBJ_COMMIT: case Constants.OBJ_TREE: case Constants.OBJ_BLOB: case Constants.OBJ_TAG: { visit.data = InflateAndReturn(PackParser.Source.DATABASE, info.size); visit.id = oe; break; } default: { throw new IOException(MessageFormat.Format(JGitText.Get().unknownObjectType, Sharpen.Extensions.ValueOf (info.type))); } } if (!CheckCRC(oe.GetCRC())) { throw new IOException(MessageFormat.Format(JGitText.Get().corruptionDetectedReReadingAt , Sharpen.Extensions.ValueOf(oe.GetOffset()))); } ResolveDeltas(visit.Next(), info.type, info, progress); }
internal DeltaVisit(PackParser.DeltaVisit parent) { // At the root of the stack we have a base. this.parent = parent; this.delta = parent.nextChild; parent.nextChild = delta.next; }