Beispiel #1
0
        public override RevCommit next()
        {
            while (true)
            {
                RevCommit c = _pending.next();
                if (c == null)
                {
                    _walker.WindowCursor.Release();
                    return(null);
                }

                foreach (RevCommit p in c.Parents)
                {
                    if ((p.Flags & InPending) != 0)
                    {
                        continue;
                    }
                    if ((p.Flags & Parsed) == 0)
                    {
                        p.parseHeaders(_walker);
                    }
                    p.Flags |= InPending;
                    _pending.add(p);
                }

                int  carry = c.Flags & _branchMask;
                bool mb    = carry == _branchMask;
                if (mb)
                {
                    // If we are a merge base make sure our ancestors are
                    // also flagged as being popped, so that they do not
                    // generate to the caller.
                    //
                    carry |= MergeBase;
                }
                CarryOntoHistory(c, carry);

                if ((c.Flags & MergeBase) != 0)
                {
                    // This commit is an ancestor of a merge base we already
                    // popped back to the caller. If everyone in pending is
                    // that way we are done traversing; if not we just need
                    // to move to the next available commit and try again.
                    //
                    if (_pending.everbodyHasFlag(MergeBase))
                    {
                        return(null);
                    }
                    continue;
                }
                c.Flags |= Popped;

                if (!mb)
                {
                    continue;
                }
                c.Flags |= MergeBase;
                return(c);
            }
        }
Beispiel #2
0
        public override RevCommit next()
        {
            try
            {
                while (true)
                {
                    RevCommit c = _pending.next();
                    if (c == null)
                    {
                        _walker.WindowCursor.Release();
                        return(null);
                    }

                    bool produce = !((c.Flags & UNINTERESTING) != 0) && _filter.include(_walker, c);

                    foreach (RevCommit p in c.Parents)
                    {
                        if ((p.Flags & SEEN) != 0)
                        {
                            continue;
                        }
                        if ((p.Flags & PARSED) == 0)
                        {
                            p.parseHeaders(_walker);
                        }
                        p.Flags |= SEEN;
                        _pending.add(p);
                    }
                    _walker.carryFlagsImpl(c);

                    if ((c.Flags & UNINTERESTING) != 0)
                    {
                        if (_pending.everbodyHasFlag(UNINTERESTING))
                        {
                            RevCommit n = _pending.peek();
                            if (n != null && n.CommitTime >= _last.CommitTime)
                            {
                                // This is too close to call. The Next commit we
                                // would pop is dated After the last one produced.
                                // We have to keep going to ensure that we carry
                                // flags as much as necessary.
                                //
                                _overScan = OVER_SCAN;
                            }
                            else if (--_overScan == 0)
                            {
                                throw StopWalkException.INSTANCE;
                            }
                        }
                        else
                        {
                            _overScan = OVER_SCAN;
                        }
                        if (CanDispose)
                        {
                            c.DisposeBody();
                        }
                        continue;
                    }

                    if (produce)
                    {
                        return(_last = c);
                    }

                    if (CanDispose)
                    {
                        c.DisposeBody();
                    }
                }
            }
            catch (StopWalkException)
            {
                _walker.WindowCursor.Release();
                _pending.clear();
                return(null);
            }
        }