/** * Enter into the current subtree. * <para /> * If the current entry is a subtree this method arranges for its children * to be returned before the next sibling following the subtree is returned. * * @throws MissingObjectException * a subtree was found, but the subtree object does not exist in * this repository. The repository may be missing objects. * @throws IncorrectObjectTypeException * a subtree was found, and the subtree id does not denote a * tree, but instead names some other non-tree type of object. * The repository may have data corruption. * @throws CorruptObjectException * the contents of a tree did not appear to be a tree. The * repository may have data corruption. * @throws IOException * a loose object or pack file could not be Read. */ public void enterSubtree() { AbstractTreeIterator ch = CurrentHead; var tmp = new AbstractTreeIterator[_trees.Length]; for (int i = 0; i < _trees.Length; i++) { AbstractTreeIterator treeIterator = _trees[i]; AbstractTreeIterator newIterator; if (treeIterator.Matches == ch && !treeIterator.eof() && FileMode.Tree == treeIterator.EntryFileMode) { newIterator = treeIterator.createSubtreeIterator(_db, _idBuffer, _cursor); } else { newIterator = treeIterator.createEmptyTreeIterator(); } tmp[i] = newIterator; } _depth++; _advance = false; Array.Copy(tmp, 0, _trees, 0, _trees.Length); }
/** * Advance this walker to the next relevant entry. * * @return true if there is an entry available; false if all entries have * been walked and the walk of this set of tree iterators is over. * @throws MissingObjectException * {@link #isRecursive()} was enabled, a subtree was found, but * the subtree object does not exist in this repository. The * repository may be missing objects. * @throws IncorrectObjectTypeException * {@link #isRecursive()} was enabled, a subtree was found, and * the subtree id does not denote a tree, but instead names some * other non-tree type of object. The repository may have data * corruption. * @throws CorruptObjectException * the contents of a tree did not appear to be a tree. The * repository may have data corruption. * @throws IOException * a loose object or pack file could not be Read. */ public bool next() { try { if (_advance) { _advance = false; _postChildren = false; popEntriesEqual(); } while (true) { AbstractTreeIterator t = min(); if (t.eof()) { if (_depth > 0) { ExitSubtree(); if (PostOrderTraversal) { _advance = true; _postChildren = true; return(true); } popEntriesEqual(); continue; } return(false); } _currentHead = t; if (!_filter.include(this)) { skipEntriesEqual(); continue; } if (Recursive && FileMode.Tree == t.EntryFileMode) { enterSubtree(); continue; } _advance = true; return(true); } } catch (StopWalkException) { foreach (AbstractTreeIterator t in _trees) { t.stopWalk(); } return(false); } }
public virtual AbstractTreeIterator min() { int i = 0; AbstractTreeIterator minRef = _trees[i]; while (minRef.eof() && ++i < _trees.Length) { minRef = _trees[i]; } if (minRef.eof()) { return(minRef); } minRef.Matches = minRef; while (++i < _trees.Length) { AbstractTreeIterator t = _trees[i]; if (t.eof()) { continue; } int cmp = t.pathCompare(minRef); if (cmp < 0) { t.Matches = t; minRef = t; } else if (cmp == 0) { t.Matches = minRef; } } return(minRef); }