/// <summary>Apply a flag to all commits matching the specified filter.</summary> /// <remarks> /// Apply a flag to all commits matching the specified filter. /// <p> /// 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. /// </remarks> /// <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> /// <exception cref="System.IO.IOException"> /// revision filter needed to read additional objects, but an /// error occurred while reading the pack files or loose objects /// of the repository. /// </exception> /// <exception cref="NGit.Errors.IncorrectObjectTypeException"> /// revision filter needed to read additional objects, but an /// object was not of the correct type. Repository corruption may /// have occurred. /// </exception> /// <exception cref="NGit.Errors.MissingObjectException"> /// revision filter needed to read additional objects, but an /// object that should be present was not found. Repository /// corruption may have occurred. /// </exception> public virtual void ApplyFlag(RevFilter matching, RevFlag flag, int rangeBegin, int rangeEnd) { RevWalk w = flag.GetRevWalk(); rangeEnd = Math.Min(rangeEnd, Count); while (rangeBegin < rangeEnd) { int index = rangeBegin; RevObjectListBlock s = contents; while (s.shift > 0) { int i = index >> s.shift; index -= i << s.shift; s = (RevObjectListBlock)s.contents[i]; } while (rangeBegin++ < rangeEnd && index < BLOCK_SIZE) { RevCommit c = (RevCommit)s.contents[index++]; if (matching.Include(w, c)) { c.Add(flag); } else { c.Remove(flag); } } } }
/// <exception cref="NGit.Errors.MissingObjectException"></exception> /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception> /// <exception cref="System.IO.IOException"></exception> internal override RevCommit Next() { try { for (; ;) { RevCommit c = pending.Next(); if (c == null) { walker.reader.WalkAdviceEnd(); return(null); } bool produce; if ((c.flags & UNINTERESTING) != 0) { produce = false; } else { if (filter.RequiresCommitBody()) { c.ParseBody(walker); } produce = 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); } else { if (canDispose) { c.DisposeBody(); } } } } catch (StopWalkException) { walker.reader.WalkAdviceEnd(); pending.Clear(); return(null); } }