Ejemplo n.º 1
0
 internal InitialGenerator(BoundaryGenerator _enclosing, RevWalk w, Generator s)
 {
     this._enclosing = _enclosing;
     this.walk       = w;
     this.held       = new FIFORevQueue();
     this.source     = s;
     this.source.ShareFreeList(this.held);
 }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
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);
     }
 }
        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());
        }
Ejemplo n.º 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());
            }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 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);
				}
			}
		}
Ejemplo n.º 8
0
 internal DelayRevQueue(Generator g)
 {
     pending = g;
     delay   = new FIFORevQueue();
 }
Ejemplo n.º 9
0
		/// <exception cref="NGit.Errors.MissingObjectException"></exception>
		/// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		internal override RevCommit Next()
		{
			Generator g;
			RevWalk w = walker;
			RevFilter rf = w.GetRevFilter();
			TreeFilter tf = w.GetTreeFilter();
			AbstractRevQueue q = walker.queue;
			w.reader.WalkAdviceBeginCommits(w, w.roots);
			if (rf == RevFilter.MERGE_BASE)
			{
				// Computing for merge bases is a special case and does not
				// use the bulk of the generator pipeline.
				//
				if (tf != TreeFilter.ALL)
				{
					throw new InvalidOperationException(MessageFormat.Format(JGitText.Get().cannotCombineTreeFilterWithRevFilter
						, tf, rf));
				}
				MergeBaseGenerator mbg = new MergeBaseGenerator(w);
				walker.pending = mbg;
				walker.queue = AbstractRevQueue.EMPTY_QUEUE;
				mbg.Init(q);
				return mbg.Next();
			}
			bool uninteresting = q.AnybodyHasFlag(RevWalk.UNINTERESTING);
			bool boundary = walker.HasRevSort(RevSort.BOUNDARY);
			if (!boundary && walker is ObjectWalk)
			{
				// The object walker requires boundary support to color
				// trees and blobs at the boundary uninteresting so it
				// does not produce those in the result.
				//
				boundary = true;
			}
			if (boundary && !uninteresting)
			{
				// If we were not fed uninteresting commits we will never
				// construct a boundary. There is no reason to include the
				// extra overhead associated with that in our pipeline.
				//
				boundary = false;
			}
			DateRevQueue pending;
			int pendingOutputType = 0;
			if (q is DateRevQueue)
			{
				pending = (DateRevQueue)q;
			}
			else
			{
				pending = new DateRevQueue(q);
			}
			if (tf != TreeFilter.ALL)
			{
				rf = AndRevFilter.Create(rf, new RewriteTreeFilter(w, tf));
				pendingOutputType |= HAS_REWRITE | NEEDS_REWRITE;
			}
			walker.queue = q;
			g = new PendingGenerator(w, pending, rf, pendingOutputType);
			if (boundary)
			{
				// Because the boundary generator may produce uninteresting
				// commits we cannot allow the pending generator to dispose
				// of them early.
				//
				((PendingGenerator)g).canDispose = false;
			}
			if ((g.OutputType() & NEEDS_REWRITE) != 0)
			{
				// Correction for an upstream NEEDS_REWRITE is to buffer
				// fully and then apply a rewrite generator that can
				// pull through the rewrite chain and produce a dense
				// output graph.
				//
				g = new FIFORevQueue(g);
				g = new RewriteGenerator(g);
			}
			if (walker.HasRevSort(RevSort.TOPO) && (g.OutputType() & SORT_TOPO) == 0)
			{
				g = new TopoSortGenerator(g);
			}
			if (walker.HasRevSort(RevSort.REVERSE))
			{
				g = new LIFORevQueue(g);
			}
			if (boundary)
			{
				g = new BoundaryGenerator(w, g);
			}
			else
			{
				if (uninteresting)
				{
					// Try to protect ourselves from uninteresting commits producing
					// due to clock skew in the commit time stamps. Delay such that
					// we have a chance at coloring enough of the graph correctly,
					// and then strip any UNINTERESTING nodes that may have leaked
					// through early.
					//
					if (pending.Peek() != null)
					{
						g = new DelayRevQueue(g);
					}
					g = new FixUninterestingGenerator(g);
				}
			}
			w.pending = g;
			return g.Next();
		}
Ejemplo n.º 10
0
		internal DelayRevQueue(Generator g)
		{
			pending = g;
			delay = new FIFORevQueue();
		}
Ejemplo n.º 11
0
        /// <exception cref="NGit.Errors.MissingObjectException"></exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        internal override RevCommit Next()
        {
            Generator        g;
            RevWalk          w  = walker;
            RevFilter        rf = w.GetRevFilter();
            TreeFilter       tf = w.GetTreeFilter();
            AbstractRevQueue q  = walker.queue;

            w.reader.WalkAdviceBeginCommits(w, w.roots);
            if (rf == RevFilter.MERGE_BASE)
            {
                // Computing for merge bases is a special case and does not
                // use the bulk of the generator pipeline.
                //
                if (tf != TreeFilter.ALL)
                {
                    throw new InvalidOperationException(MessageFormat.Format(JGitText.Get().cannotCombineTreeFilterWithRevFilter
                                                                             , tf, rf));
                }
                MergeBaseGenerator mbg = new MergeBaseGenerator(w);
                walker.pending = mbg;
                walker.queue   = AbstractRevQueue.EMPTY_QUEUE;
                mbg.Init(q);
                return(mbg.Next());
            }
            bool uninteresting = q.AnybodyHasFlag(RevWalk.UNINTERESTING);
            bool boundary      = walker.HasRevSort(RevSort.BOUNDARY);

            if (!boundary && walker is ObjectWalk)
            {
                // The object walker requires boundary support to color
                // trees and blobs at the boundary uninteresting so it
                // does not produce those in the result.
                //
                boundary = true;
            }
            if (boundary && !uninteresting)
            {
                // If we were not fed uninteresting commits we will never
                // construct a boundary. There is no reason to include the
                // extra overhead associated with that in our pipeline.
                //
                boundary = false;
            }
            DateRevQueue pending;
            int          pendingOutputType = 0;

            if (q is DateRevQueue)
            {
                pending = (DateRevQueue)q;
            }
            else
            {
                pending = new DateRevQueue(q);
            }
            if (tf != TreeFilter.ALL)
            {
                rf = AndRevFilter.Create(new RewriteTreeFilter(w, tf), rf);
                pendingOutputType |= HAS_REWRITE | NEEDS_REWRITE;
            }
            walker.queue = q;
            if (walker is DepthWalk)
            {
                DepthWalk dw = (DepthWalk)walker;
                g = new DepthGenerator(dw, pending);
            }
            else
            {
                g = new PendingGenerator(w, pending, rf, pendingOutputType);
                if (boundary)
                {
                    // Because the boundary generator may produce uninteresting
                    // commits we cannot allow the pending generator to dispose
                    // of them early.
                    //
                    ((PendingGenerator)g).canDispose = false;
                }
            }
            if ((g.OutputType() & NEEDS_REWRITE) != 0)
            {
                // Correction for an upstream NEEDS_REWRITE is to buffer
                // fully and then apply a rewrite generator that can
                // pull through the rewrite chain and produce a dense
                // output graph.
                //
                g = new FIFORevQueue(g);
                g = new RewriteGenerator(g);
            }
            if (walker.HasRevSort(RevSort.TOPO) && (g.OutputType() & SORT_TOPO) == 0)
            {
                g = new TopoSortGenerator(g);
            }
            if (walker.HasRevSort(RevSort.REVERSE))
            {
                g = new LIFORevQueue(g);
            }
            if (boundary)
            {
                g = new BoundaryGenerator(w, g);
            }
            else
            {
                if (uninteresting)
                {
                    // Try to protect ourselves from uninteresting commits producing
                    // due to clock skew in the commit time stamps. Delay such that
                    // we have a chance at coloring enough of the graph correctly,
                    // and then strip any UNINTERESTING nodes that may have leaked
                    // through early.
                    //
                    if (pending.Peek() != null)
                    {
                        g = new DelayRevQueue(g);
                    }
                    g = new FixUninterestingGenerator(g);
                }
            }
            w.pending = g;
            return(g.Next());
        }
Ejemplo n.º 12
0
			internal InitialGenerator(BoundaryGenerator _enclosing, RevWalk w, Generator s)
			{
				this._enclosing = _enclosing;
				this.walk = w;
				this.held = new FIFORevQueue();
				this.source = s;
				this.source.ShareFreeList(this.held);
			}
Ejemplo n.º 13
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();
			}