/// <summary>Push a candidate object onto the generator's traversal stack.</summary> /// <remarks> /// Push a candidate object onto the generator's traversal stack. /// <p> /// Candidates should be pushed in history order from oldest-to-newest. /// Applications should push the starting commit first, then the index /// revision (if the index is interesting), and finally the working tree copy /// (if the working tree is interesting). /// </remarks> /// <param name="description">description of the blob revision, such as "Working Tree". /// </param> /// <param name="id">may be a commit or a blob.</param> /// <returns> /// /// <code>this</code> /// </returns> /// <exception cref="System.IO.IOException">the repository cannot be read.</exception> public virtual NGit.Blame.BlameGenerator Push(string description, AnyObjectId id) { ObjectLoader ldr = reader.Open(id); if (ldr.GetType() == Constants.OBJ_BLOB) { if (description == null) { description = JGitText.Get().blameNotCommittedYet; } Candidate.BlobCandidate c = new Candidate.BlobCandidate(description, resultPath); c.sourceBlob = id.ToObjectId(); c.sourceText = new RawText(ldr.GetCachedBytes(int.MaxValue)); c.regionList = new Region(0, 0, c.sourceText.Size()); remaining = c.sourceText.Size(); Push(c); return(this); } RevCommit commit = revPool.ParseCommit(id); if (!Find(commit, resultPath)) { return(this); } Candidate c_1 = new Candidate(commit, resultPath); c_1.sourceBlob = idBuf.ToObjectId(); c_1.LoadText(reader); c_1.regionList = new Region(0, 0, c_1.sourceText.Size()); remaining = c_1.sourceText.Size(); Push(c_1); return(this); }
/// <exception cref="System.IO.IOException"></exception> private bool ProcessOne(Candidate n) { RevCommit parent = n.GetParent(0); if (parent == null) { return(Split(n.GetNextCandidate(0), n)); } if (parent.Has(SEEN)) { return(false); } revPool.ParseHeaders(parent); if (Find(parent, n.sourcePath)) { if (idBuf.Equals(n.sourceBlob)) { // The common case of the file not being modified in // a simple string-of-pearls history. Blame parent. n.sourceCommit = parent; Push(n); return(false); } Candidate next = n.Create(parent, n.sourcePath); next.sourceBlob = idBuf.ToObjectId(); next.LoadText(reader); return(Split(next, n)); } if (n.sourceCommit == null) { return(Result(n)); } DiffEntry r = FindRename(parent, n.sourceCommit, n.sourcePath); if (r == null) { return(Result(n)); } if (0 == r.GetOldId().PrefixCompare(n.sourceBlob)) { // A 100% rename without any content change can also // skip directly to the parent. n.sourceCommit = parent; n.sourcePath = PathFilter.Create(r.GetOldPath()); Push(n); return(false); } Candidate next_1 = n.Create(parent, PathFilter.Create(r.GetOldPath())); next_1.sourceBlob = r.GetOldId().ToObjectId(); next_1.renameScore = r.GetScore(); next_1.LoadText(reader); return(Split(next_1, n)); }