Candidate create(Repository repo, RevCommit commit, PathFilter path) { return new Candidate(repo, commit, path); }
private void push(Candidate toInsert) { if (toInsert.has(SEEN)) { if (p.canMergeRegions(toInsert)) { p.mergeRegions(toInsert); return; toInsert.add(SEEN); int time = toInsert.getTime(); Candidate n = queue; if (n == null || time >= n.getTime()) { toInsert.queueNext = n; queue = toInsert; if (n == null || time >= n.getTime()) { toInsert.queueNext = n; p.queueNext = toInsert;
private boolean result(Candidate n) throws IOException { n.beginResult(revPool); outCandidate = n; outRegion = n.regionList; return outRegion != null; }
void mergeRegions(Candidate other) { // regionList is always sorted by resultStart. Merge join two // linked lists, preserving the ordering. Combine neighboring // regions to reduce the number of results seen by callers. Region a = clearRegionList(); Region b = other.clearRegionList(); Region t = null; while (a != null && b != null) { if (a.resultStart < b.resultStart) { Region n = a.next; t = add(t, this, a); a = n; } else { Region n = b.next; t = add(t, this, b); b = n; } } if (a != null) { Region n = a.next; t = add(t, this, a); t.next = n; } else /* b != null */{ Region n = b.next; t = add(t, this, b); t.next = n; } }
private boolean processMerge(Candidate n) throws IOException { int pCnt = n.getParentCount(); RevCommit parent = n.getParent(pIdx); revPool.parseHeaders(parent); if (!find(parent, n.sourcePath)) renames = new DiffEntry[pCnt]; for (int pIdx = 0; pIdx < pCnt; pIdx++) { RevCommit parent = n.getParent(pIdx); if (ids != null && ids[pIdx] != null) continue; RevCommit parent = n.getParent(pIdx); p = n.create(getRepository(), parent, PathFilter.create(renames[pIdx].getOldPath())); p.renameScore = renames[pIdx].getScore(); p.sourceBlob = renames[pIdx].getOldId().toObjectId(); } else if (ids != null && ids[pIdx] != null) { p = n.create(getRepository(), parent, n.sourcePath); p.sourceBlob = ids[pIdx]; } else { editList = new EditList(0); } else { p.loadText(reader); editList = diffAlgorithm.diff(textComparator, p.sourceText, n.sourceText);
private boolean processOne(Candidate n) throws IOException { RevCommit parent = n.getParent(0); if (parent == null) return split(n.getNextCandidate(0), n); revPool.parseHeaders(parent); if (find(parent, n.sourcePath)) { if (idBuf.equals(n.sourceBlob)) return blameEntireRegionOnParent(n, parent); return splitBlameWithParent(n, parent); } 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 = n.create(getRepository(), parent, PathFilter.create(r.getOldPath())); next.sourceBlob = r.getOldId().toObjectId(); next.renameScore = r.getScore(); next.loadText(reader); return split(next, n); }
private boolean reverseResult(Candidate parent, Candidate source) throws IOException { // On a reverse blame present the application the parent // (as this is what did the removals), however the region // list to enumerate is the source's surviving list. Candidate res = parent.copy(parent.sourceCommit); res.regionList = source.regionList; return result(res); }
/** * Get source author * * @return current author being blamed */ public PersonIdent getSourceAuthor() { return outCandidate.getAuthor(); }
Candidate copy(RevCommit commit) { Candidate r = create(sourceRepository, commit, sourcePath); r.sourceBlob = sourceBlob; r.sourceText = sourceText; r.regionList = regionList; r.renameScore = renameScore; return r; }
void takeBlame(EditList editList, Candidate child) { blame(editList, this, child); }
private boolean processMerge(Candidate n) throws IOException { int pCnt = n.getParentCount(); RevCommit parent = n.getParent(pIdx); revPool.parseHeaders(parent); if (!find(parent, n.sourcePath)) renames = new DiffEntry[pCnt]; for (int pIdx = 0; pIdx < pCnt; pIdx++) { RevCommit parent = n.getParent(pIdx); if (ids != null && ids[pIdx] != null) continue; RevCommit parent = n.getParent(pIdx); p = n.create(parent, PathFilter.create(renames[pIdx].getOldPath())); p.renameScore = renames[pIdx].getScore(); p.sourceBlob = renames[pIdx].getOldId().toObjectId(); } else if (ids != null && ids[pIdx] != null) { p = n.create(parent, n.sourcePath); p.sourceBlob = ids[pIdx]; } else { editList = new EditList(0); } else { p.loadText(reader); editList = diffAlgorithm.diff(textComparator, p.sourceText, n.sourceText);
private boolean processOne(Candidate n) throws IOException { RevCommit parent = n.getParent(0); if (parent == null) return split(n.getNextCandidate(0), n); revPool.parseHeaders(parent); if (find(parent, n.sourcePath)) { if (idBuf.equals(n.sourceBlob)) return blameEntireRegionOnParent(n, parent); return splitBlameWithParent(n, parent); } 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 = n.create(parent, PathFilter.create(r.getOldPath())); next.sourceBlob = r.getOldId().toObjectId(); next.renameScore = r.getScore(); next.loadText(reader); return split(next, n); }
private static void blame(EditList editList, Candidate a, Candidate b) { Region r = b.clearRegionList(); Region aTail = null; Region bTail = null; aTail = add(aTail, a, r); r = next; continue; aTail = add(aTail, a, r.splitFirst(e.getBeginA() - d, d)); r.slideAndShrink(d); if (rEnd <= e.getEndB()) { Region next = r.next; bTail = add(bTail, b, r); r = next; if (rEnd == e.getEndB()) bTail = add(bTail, b, r.splitFirst(r.sourceStart, len)); r.slideAndShrink(len); eIdx++;
private boolean reverseResult(Candidate parent, Candidate source) throws IOException { // On a reverse blame present the application the parent // (as this is what did the removals), however the region // list to enumerate is the source's surviving list. Candidate res = parent.copy(parent.sourceCommit); res.regionList = source.regionList; return result(res); }
/** * Get source author * * @return current author being blamed */ public PersonIdent getSourceAuthor() { return outCandidate.getAuthor(); }
Candidate copy(RevCommit commit) { Candidate r = create(commit, sourcePath); r.sourceBlob = sourceBlob; r.sourceText = sourceText; r.regionList = regionList; r.renameScore = renameScore; return r; }