use of com.google.gitiles.blame.Region in project gerrit by GerritCodeReview.
the class GetBlame method blame.
private List<BlameInfo> blame(ObjectId id, String path, Repository repository, RevWalk revWalk) throws IOException {
ListMultimap<BlameInfo, RangeInfo> ranges = MultimapBuilder.hashKeys().arrayListValues().build();
List<BlameInfo> result = new ArrayList<>();
if (blameCache.findLastCommit(repository, id, path) == null) {
return result;
}
List<Region> blameRegions = blameCache.get(repository, id, path);
int from = 1;
for (Region region : blameRegions) {
RevCommit commit = revWalk.parseCommit(region.getSourceCommit());
BlameInfo blameInfo = toBlameInfo(commit, region.getSourceAuthor());
ranges.put(blameInfo, new RangeInfo(from, from + region.getCount() - 1));
from += region.getCount();
}
for (BlameInfo key : ranges.keySet()) {
key.ranges = ranges.get(key);
result.add(key);
}
return result;
}