示例#1
0
 /// <summary>Configure the generator to compute reverse blame (history of deletes).</summary>
 /// <remarks>
 /// Configure the generator to compute reverse blame (history of deletes).
 /// <p>
 /// This method is expensive as it immediately runs a RevWalk over the
 /// history spanning the expression
 /// <code>start..end</code>
 /// (end being more recent
 /// than start) and then performs the equivalent operation as
 /// <see cref="Push(string, NGit.AnyObjectId)">Push(string, NGit.AnyObjectId)</see>
 /// to begin blame traversal from the
 /// commit named by
 /// <code>start</code>
 /// walking forwards through history until
 /// <code>end</code>
 /// blaming line deletions.
 /// <p>
 /// A reverse blame may produce multiple sources for the same result line,
 /// each of these is a descendant commit that removed the line, typically
 /// this occurs when the same deletion appears in multiple side branches such
 /// as due to a cherry-pick. Applications relying on reverse should use
 /// <see cref="BlameResult">BlameResult</see>
 /// as it filters these duplicate sources and only
 /// remembers the first (oldest) deletion.
 /// </remarks>
 /// <param name="start">
 /// oldest commit to traverse from. The result file will be loaded
 /// from this commit's tree.
 /// </param>
 /// <param name="end">
 /// most recent commits to stop traversal at. Usually an active
 /// branch tip, tag, or HEAD.
 /// </param>
 /// <returns>
 ///
 /// <code>this</code>
 /// </returns>
 /// <exception cref="System.IO.IOException">the repository cannot be read.</exception>
 public virtual NGit.Blame.BlameGenerator Reverse <_T0>(AnyObjectId start, ICollection
                                                        <_T0> end) where _T0 : ObjectId
 {
     InitRevPool(true);
     ReverseWalk.ReverseCommit result = (ReverseWalk.ReverseCommit)revPool.ParseCommit
                                            (start);
     if (!Find(result, resultPath))
     {
         return(this);
     }
     revPool.MarkUninteresting(result);
     foreach (ObjectId id in end)
     {
         revPool.MarkStart(revPool.ParseCommit(id));
     }
     while (revPool.Next() != null)
     {
     }
     // just pump the queue
     Candidate.ReverseCandidate c = new Candidate.ReverseCandidate(result, resultPath);
     c.sourceBlob = idBuf.ToObjectId();
     c.LoadText(reader);
     c.regionList = new Region(0, 0, c.sourceText.Size());
     remaining    = c.sourceText.Size();
     Push(c);
     return(this);
 }
示例#2
0
            internal void AddChild(ReverseWalk.ReverseCommit c)
            {
                // Always put the most recent child onto the front of the list.
                // This works correctly because our ReverseWalk parent (above)
                // runs in COMMIT_TIME_DESC order. Older commits will be popped
                // later and should go in front of the children list so they are
                // visited first by BlameGenerator when considering candidates.
                int cnt = children.Length;

                if (cnt == 0)
                {
                    children = new ReverseWalk.ReverseCommit[] { c };
                }
                else
                {
                    if (cnt == 1)
                    {
                        children = new ReverseWalk.ReverseCommit[] { c, children[0] };
                    }
                    else
                    {
                        ReverseWalk.ReverseCommit[] n = new ReverseWalk.ReverseCommit[1 + cnt];
                        n[0] = c;
                        System.Array.Copy(children, 0, n, 1, cnt);
                        children = n;
                    }
                }
            }
示例#3
0
 /// <exception cref="NGit.Errors.MissingObjectException"></exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
 /// <exception cref="System.IO.IOException"></exception>
 public override RevCommit Next()
 {
     ReverseWalk.ReverseCommit c = (ReverseWalk.ReverseCommit)base.Next();
     if (c == null)
     {
         return(null);
     }
     for (int pIdx = 0; pIdx < c.ParentCount; pIdx++)
     {
         ((ReverseWalk.ReverseCommit)c.GetParent(pIdx)).AddChild(c);
     }
     return(c);
 }
示例#4
0
文件: Candidate.cs 项目: shoff/ngit
 internal ReverseCandidate(ReverseWalk.ReverseCommit commit, PathFilter path) : base
         (commit, path)
 {
 }
示例#5
0
			internal void AddChild(ReverseWalk.ReverseCommit c)
			{
				// Always put the most recent child onto the front of the list.
				// This works correctly because our ReverseWalk parent (above)
				// runs in COMMIT_TIME_DESC order. Older commits will be popped
				// later and should go in front of the children list so they are
				// visited first by BlameGenerator when considering candidates.
				int cnt = children.Length;
				if (cnt == 0)
				{
					children = new ReverseWalk.ReverseCommit[] { c };
				}
				else
				{
					if (cnt == 1)
					{
						children = new ReverseWalk.ReverseCommit[] { c, children[0] };
					}
					else
					{
						ReverseWalk.ReverseCommit[] n = new ReverseWalk.ReverseCommit[1 + cnt];
						n[0] = c;
						System.Array.Copy(children, 0, n, 1, cnt);
						children = n;
					}
				}
			}