/// <summary> /// Pop the next most recent object. /// </summary> /// <returns>next most recent object; null if traversal is over.</returns> /// <exception cref="MissingObjectException"> /// One or or more of the next objects are not available from the /// object database, but were thought to be candidates for /// traversal. This usually indicates a broken link. /// </exception> /// <exception cref="IncorrectObjectTypeException"> /// One or or more of the objects in a tree do not match the type indicated. /// </exception> /// <exception cref="Exception"> /// A pack file or loose object could not be Read. /// </exception> public RevObject nextObject() { _fromTreeWalk = false; if (_nextSubtree != null) { _treeWalk = _treeWalk.createSubtreeIterator0(Repository, _nextSubtree, WindowCursor); _nextSubtree = null; } while (!_treeWalk.eof()) { FileMode mode = _treeWalk.EntryFileMode; var sType = (int)mode.ObjectType; switch (sType) { case Constants.OBJ_BLOB: _treeWalk.getEntryObjectId(IdBuffer); RevBlob blob = lookupBlob(IdBuffer); if ((blob.Flags & SEEN) != 0) break; blob.Flags |= SEEN; if (ShouldSkipObject(blob)) break; _fromTreeWalk = true; return blob; case Constants.OBJ_TREE: _treeWalk.getEntryObjectId(IdBuffer); RevTree tree = lookupTree(IdBuffer); if ((tree.Flags & SEEN) != 0) break; tree.Flags |= SEEN; if (ShouldSkipObject(tree)) break; _nextSubtree = tree; _fromTreeWalk = true; return tree; default: if (FileMode.GitLink.Equals(mode.Bits)) break; _treeWalk.getEntryObjectId(IdBuffer); throw new CorruptObjectException("Invalid mode " + mode + " for " + IdBuffer + " " + _treeWalk.EntryPathString + " in " + _currentTree + "."); } _treeWalk = _treeWalk.next(); } while (true) { RevObject obj = _pendingObjects.next(); if (obj == null) return null; if ((obj.Flags & SEEN) != 0) continue; obj.Flags |= SEEN; if (ShouldSkipObject(obj)) continue; if (obj is RevTree) { _currentTree = (RevTree)obj; _treeWalk = _treeWalk.resetRoot(Repository, _currentTree, WindowCursor); } return obj; } }
/** * Pop the next most recent object. * * @return next most recent object; null if traversal is over. * @throws MissingObjectException * one or or more of the next objects are not available from the * object database, but were thought to be candidates for * traversal. This usually indicates a broken link. * @throws IncorrectObjectTypeException * one or or more of the objects in a tree do not match the type * indicated. * @ * a pack file or loose object could not be read. */ public RevObject nextObject() { fromTreeWalk = false; if (nextSubtree != null) { treeWalk = treeWalk.createSubtreeIterator0(db, nextSubtree, curs); nextSubtree = null; } while (!treeWalk.eof()) { FileMode mode = treeWalk.getEntryFileMode(); int sType = (int)mode.ObjectType; switch (sType) { case Constants.OBJ_BLOB: { treeWalk.getEntryObjectId(idBuffer); RevBlob o = lookupBlob(idBuffer); if ((o.flags & SEEN) != 0) break; o.flags |= SEEN; if (shouldSkipObject(o)) break; fromTreeWalk = true; return o; } case Constants.OBJ_TREE: { treeWalk.getEntryObjectId(idBuffer); RevTree o = lookupTree(idBuffer); if ((o.flags & SEEN) != 0) break; o.flags |= SEEN; if (shouldSkipObject(o)) break; nextSubtree = o; fromTreeWalk = true; return o; } default: if (FileMode.GitLink.Equals(mode.Bits)) break; treeWalk.getEntryObjectId(idBuffer); throw new CorruptObjectException("Invalid mode " + mode + " for " + idBuffer.ToString() + " " + treeWalk.getEntryPathString() + " in " + currentTree + "."); } treeWalk = treeWalk.next(); } for (; ; ) { RevObject o = pendingObjects.next(); if (o == null) return null; if ((o.flags & SEEN) != 0) continue; o.flags |= SEEN; if (shouldSkipObject(o)) continue; if (o is RevTree) { currentTree = (RevTree)o; treeWalk = treeWalk.resetRoot(db, currentTree, curs); } return o; } }