コード例 #1
0
        public virtual void TestRevFilterReceivesParsedCommits()
        {
            RevCommit     a          = Commit();
            RevCommit     b          = Commit(a);
            RevCommit     c          = Commit(b);
            AtomicBoolean filterRan  = new AtomicBoolean();
            RevFilter     testFilter = new _RevFilter_68(filterRan);

            // Do an initial run through the walk
            filterRan.Set(false);
            rw.SetRevFilter(testFilter);
            MarkStart(c);
            rw.MarkUninteresting(b);
            for (RevCommit cmit = rw.Next(); cmit != null; cmit = rw.Next())
            {
            }
            // Don't dispose the body here, because we want to test the effect
            // of marking 'b' as uninteresting.
            NUnit.Framework.Assert.IsTrue(filterRan.Get(), "filter ran");
            // Run through the walk again, this time disposing of all commits.
            filterRan.Set(false);
            rw.Reset();
            MarkStart(c);
            for (RevCommit cmit_1 = rw.Next(); cmit_1 != null; cmit_1 = rw.Next())
            {
                cmit_1.DisposeBody();
            }
            NUnit.Framework.Assert.IsTrue(filterRan.Get(), "filter ran");
            // Do the third run through the reused walk. Test that the explicitly
            // disposed commits are parsed on this walk.
            filterRan.Set(false);
            rw.Reset();
            MarkStart(c);
            for (RevCommit cmit_2 = rw.Next(); cmit_2 != null; cmit_2 = rw.Next())
            {
            }
            // spin through the walk.
            NUnit.Framework.Assert.IsTrue(filterRan.Get(), "filter ran");
        }
コード例 #2
0
 /// <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);
     }
 }