示例#1
0
        /// <summary>
        /// Apply a flag to all commits matching the specified filter.
        ///
        /// This version allows incremental testing and application, such as from a
        /// background thread that needs to periodically halt processing and send
        /// updates to the UI.
        /// </summary>
        /// <param name="matching">
        /// the filter to test commits with. If the filter includes a
        /// commit it will have the flag set; if the filter does not
        /// include the commit the flag will be unset.
        /// </param>
        /// <param name="flag">
        /// the flag to Apply (or remove). Applications are responsible
        /// for allocating this flag from the source RevWalk.
        /// </param>
        /// <param name="rangeBegin">
        /// first commit within the list to begin testing at, inclusive.
        /// Must not be negative, but may be beyond the end of the list.
        /// </param>
        /// <param name="rangeEnd">
        /// last commit within the list to end testing at, exclusive. If
        /// smaller than or equal to <code>rangeBegin</code> then no
        /// commits will be tested.
        /// </param>
        /// <remarks>
        /// Revision filter needed to Read additional objects, but an
        /// error occurred while reading the pack files or loose objects
        /// of the repository.
        /// </remarks>
        public void applyFlag(RevFilter matching, RevFlag flag, int rangeBegin, int rangeEnd)
        {
            RevWalk w = flag.Walker;

            rangeEnd = Math.Min(rangeEnd, Size);
            while (rangeBegin < rangeEnd)
            {
                int   index = rangeBegin;
                Block s     = Contents;

                while (s.Shift > 0)
                {
                    int i = index >> s.Shift;
                    index -= i << s.Shift;
                    s      = (Block)s.Contents[i];
                }

                while (rangeBegin++ < rangeEnd && index < BLOCK_SIZE)
                {
                    var c = (RevCommit)s.Contents[index++];

                    if (matching.include(w, c))
                    {
                        c.add(flag);
                    }
                    else
                    {
                        c.remove(flag);
                    }
                }
            }
        }
示例#2
0
 public override bool include(RevWalk walker, RevCommit c)
 {
     return(!_a.include(walker, c));
 }
示例#3
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);
            }
        }