Beispiel #1
0
 /// <exception cref="NGit.Errors.MissingObjectException"></exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
 /// <exception cref="System.IO.IOException"></exception>
 internal override RevCommit Next()
 {
     // Perform a breadth-first descent into the commit graph,
     // marking depths as we go.  This means that if a commit is
     // reachable by more than one route, we are guaranteed to
     // arrive by the shortest route first.
     for (; ;)
     {
         var c = (NGit.Revwalk.Depthwalk.Commit)pending.Next();
         if (c == null)
         {
             return(null);
         }
         if ((c.flags & RevWalk.PARSED) == 0)
         {
             c.ParseHeaders(walk);
         }
         int newDepth = c.depth + 1;
         foreach (RevCommit p in c.parents)
         {
             var dp = (NGit.Revwalk.Depthwalk.Commit)p;
             // If no depth has been assigned to this commit, assign
             // it now.  Since we arrive by the shortest route first,
             // this depth is guaranteed to be the smallest value that
             // any path could produce.
             if (dp.depth == -1)
             {
                 dp.depth = newDepth;
                 // If the parent is not too deep, add it to the queue
                 // so that we can produce it later
                 if (newDepth <= depth)
                 {
                     pending.Add(p);
                 }
             }
             // If the current commit has become unshallowed, everything
             // below us is new to the client.  Mark its parent as
             // re-interesting, and carry that flag downward to all
             // of its ancestors.
             if (c.Has(UNSHALLOW) || c.Has(REINTERESTING))
             {
                 p.Add(REINTERESTING);
                 p.flags &= ~RevWalk.UNINTERESTING;
             }
         }
         // Produce all commits less than the depth cutoff
         bool produce = c.depth <= depth;
         // Unshallow commits are uninteresting, but still need to be sent
         // up to the PackWriter so that it will exclude objects correctly.
         // All other uninteresting commits should be omitted.
         if ((c.flags & RevWalk.UNINTERESTING) != 0 && !c.Has(UNSHALLOW))
         {
             produce = false;
         }
         if (produce)
         {
             return(c);
         }
     }
 }
        public virtual void TestCloneFIFO()
        {
            RevCommit    a   = ParseBody(Commit());
            RevCommit    b   = ParseBody(Commit(200, a));
            RevCommit    c   = ParseBody(Commit(200, b));
            FIFORevQueue src = new FIFORevQueue();

            src.Add(a);
            src.Add(b);
            src.Add(c);
            q = new DateRevQueue(src);
            NUnit.Framework.Assert.IsFalse(q.EverbodyHasFlag(RevWalk.UNINTERESTING));
            NUnit.Framework.Assert.IsFalse(q.AnybodyHasFlag(RevWalk.UNINTERESTING));
            AssertCommit(c, q.Peek());
            AssertCommit(c, q.Peek());
            AssertCommit(c, q.Next());
            AssertCommit(b, q.Next());
            AssertCommit(a, q.Next());
            NUnit.Framework.Assert.IsNull(q.Next());
        }
 /// <summary>Create a new sorter and completely spin the generator.</summary>
 /// <remarks>
 /// Create a new sorter and completely spin the generator.
 /// <p>
 /// When the constructor completes the supplied generator will have no
 /// commits remaining, as all of the commits will be held inside of this
 /// generator's internal buffer.
 /// </remarks>
 /// <param name="s">generator to pull all commits out of, and into this buffer.</param>
 /// <exception cref="NGit.Errors.MissingObjectException">NGit.Errors.MissingObjectException
 ///     </exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException">NGit.Errors.IncorrectObjectTypeException
 ///     </exception>
 /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
 internal TopoSortGenerator(Generator s)
 {
     pending    = new FIFORevQueue();
     outputType = s.OutputType() | SORT_TOPO;
     s.ShareFreeList(pending);
     for (; ;)
     {
         RevCommit c = s.Next();
         if (c == null)
         {
             break;
         }
         foreach (RevCommit p in c.parents)
         {
             p.inDegree++;
         }
         pending.Add(c);
     }
 }
Beispiel #4
0
        /// <exception cref="NGit.Errors.MissingObjectException"></exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        internal override RevCommit Next()
        {
            while (size < OVER_SCAN)
            {
                RevCommit c = pending.Next();
                if (c == null)
                {
                    break;
                }
                delay.Add(c);
                size++;
            }
            RevCommit c_1 = delay.Next();

            if (c_1 == null)
            {
                return(null);
            }
            size--;
            return(c_1);
        }
Beispiel #5
0
            /// <exception cref="NGit.Errors.MissingObjectException"></exception>
            /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
            /// <exception cref="System.IO.IOException"></exception>
            internal override RevCommit Next()
            {
                RevCommit c = this.source.Next();

                if (c != null)
                {
                    foreach (RevCommit p in c.parents)
                    {
                        if ((p.flags & BoundaryGenerator.UNINTERESTING) != 0)
                        {
                            this.held.Add(p);
                        }
                    }
                    return(c);
                }
                FIFORevQueue boundary = new FIFORevQueue();

                boundary.ShareFreeList(this.held);
                for (; ;)
                {
                    c = this.held.Next();
                    if (c == null)
                    {
                        break;
                    }
                    if ((c.flags & BoundaryGenerator.InitialGenerator.DUPLICATE) != 0)
                    {
                        continue;
                    }
                    if ((c.flags & BoundaryGenerator.InitialGenerator.PARSED) == 0)
                    {
                        c.ParseHeaders(this.walk);
                    }
                    c.flags |= BoundaryGenerator.InitialGenerator.DUPLICATE;
                    boundary.Add(c);
                }
                boundary.RemoveFlag(BoundaryGenerator.InitialGenerator.DUPLICATE);
                this._enclosing.g = boundary;
                return(boundary.Next());
            }
Beispiel #6
0
 /// <param name="w"></param>
 /// <param name="s">Parent generator</param>
 /// <exception cref="NGit.Errors.MissingObjectException">NGit.Errors.MissingObjectException
 ///     </exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException">NGit.Errors.IncorrectObjectTypeException
 ///     </exception>
 /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
 internal DepthGenerator(DepthWalk w, Generator s)
 {
     pending            = new FIFORevQueue();
     walk               = (RevWalk)w;
     this.depth         = w.GetDepth();
     this.UNSHALLOW     = w.GetUnshallowFlag();
     this.REINTERESTING = w.GetReinterestingFlag();
     s.ShareFreeList(pending);
     // Begin by sucking out all of the source's commits, and
     // adding them to the pending queue
     for (; ;)
     {
         RevCommit c = s.Next();
         if (c == null)
         {
             break;
         }
         if (((NGit.Revwalk.Depthwalk.Commit)c).GetDepth() == 0)
         {
             pending.Add(c);
         }
     }
 }
Beispiel #7
0
		/// <param name="w"></param>
		/// <param name="s">Parent generator</param>
		/// <exception cref="NGit.Errors.MissingObjectException">NGit.Errors.MissingObjectException
		/// 	</exception>
		/// <exception cref="NGit.Errors.IncorrectObjectTypeException">NGit.Errors.IncorrectObjectTypeException
		/// 	</exception>
		/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
		internal DepthGenerator(DepthWalk w, Generator s)
		{
			pending = new FIFORevQueue();
			walk = (RevWalk)w;
			this.depth = w.GetDepth();
			this.UNSHALLOW = w.GetUnshallowFlag();
			this.REINTERESTING = w.GetReinterestingFlag();
			s.ShareFreeList(pending);
			// Begin by sucking out all of the source's commits, and
			// adding them to the pending queue
			for (; ; )
			{
				RevCommit c = s.Next();
				if (c == null)
				{
					break;
				}
				if (((NGit.Revwalk.Depthwalk.Commit)c).GetDepth() == 0)
				{
					pending.Add(c);
				}
			}
		}
Beispiel #8
0
 /// <summary>Create a new sorter and completely spin the generator.</summary>
 /// <remarks>
 /// Create a new sorter and completely spin the generator.
 /// <p/>
 /// When the constructor completes the supplied generator will have no
 /// commits remaining, as all of the commits will be held inside of this
 /// generator's internal buffer.
 /// </remarks>
 /// <param name="s">generator to pull all commits out of, and into this buffer.</param>
 /// <exception cref="NGit.Errors.MissingObjectException">NGit.Errors.MissingObjectException
 /// 	</exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException">NGit.Errors.IncorrectObjectTypeException
 /// 	</exception>
 /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
 internal TopoSortGenerator(Generator s)
 {
     pending = new FIFORevQueue();
     outputType = s.OutputType() | SORT_TOPO;
     s.ShareFreeList(pending);
     for (; ; )
     {
         RevCommit c = s.Next();
         if (c == null)
         {
             break;
         }
         foreach (RevCommit p in c.parents)
         {
             p.inDegree++;
         }
         pending.Add(c);
     }
 }
Beispiel #9
0
			/// <exception cref="NGit.Errors.MissingObjectException"></exception>
			/// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
			/// <exception cref="System.IO.IOException"></exception>
			internal override RevCommit Next()
			{
				RevCommit c = this.source.Next();
				if (c != null)
				{
					foreach (RevCommit p in c.parents)
					{
						if ((p.flags & BoundaryGenerator.UNINTERESTING) != 0)
						{
							this.held.Add(p);
						}
					}
					return c;
				}
				FIFORevQueue boundary = new FIFORevQueue();
				boundary.ShareFreeList(this.held);
				for (; ; )
				{
					c = this.held.Next();
					if (c == null)
					{
						break;
					}
					if ((c.flags & BoundaryGenerator.InitialGenerator.DUPLICATE) != 0)
					{
						continue;
					}
					if ((c.flags & BoundaryGenerator.InitialGenerator.PARSED) == 0)
					{
						c.ParseHeaders(this.walk);
					}
					c.flags |= BoundaryGenerator.InitialGenerator.DUPLICATE;
					boundary.Add(c);
				}
				boundary.RemoveFlag(BoundaryGenerator.InitialGenerator.DUPLICATE);
				this._enclosing.g = boundary;
				return boundary.Next();
			}