Example usage for org.eclipse.jgit.blame BlameGenerator computeBlameResult

List of usage examples for org.eclipse.jgit.blame BlameGenerator computeBlameResult

Introduction

In this page you can find the example usage for org.eclipse.jgit.blame BlameGenerator computeBlameResult.

Prototype

public BlameResult computeBlameResult() throws IOException 

Source Link

Document

Execute the generator in a blocking fashion until all data is ready.

Usage

From source file:com.google.gitiles.BlameCache.java

License:Open Source License

private List<BlameCache.Region> loadBlame(Key key) throws IOException {
    try {/*from www.  jav a2  s.c  o  m*/
        BlameGenerator gen = new BlameGenerator(key.repo, key.path);
        BlameResult blame;
        try {
            gen.push(null, key.commitId);
            blame = gen.computeBlameResult();
        } finally {
            gen.release();
        }
        if (blame == null) {
            return ImmutableList.of();
        }
        int lineCount = blame.getResultContents().size();
        blame.discardResultContents();

        List<BlameCache.Region> regions = Lists.newArrayList();
        for (int i = 0; i < lineCount; i++) {
            if (regions.isEmpty() || !regions.get(regions.size() - 1).growFrom(blame, i)) {
                regions.add(new BlameCache.Region(blame, i));
            }
        }
        return Collections.unmodifiableList(regions);
    } finally {
        key.repo = null;
    }
}