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

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

Introduction

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

Prototype

public BlameGenerator push(String description, AnyObjectId id) throws IOException 

Source Link

Document

Push a candidate object onto the generator's traversal stack.

Usage

From source file:com.google.gitiles.blame.BlameCacheImpl.java

License:Open Source License

public static List<Region> loadBlame(Key key) throws IOException {
    try {// w  w w  . j  ava2s .co  m
        BlameGenerator gen = new BlameGenerator(key.repo, key.path);
        try {
            gen.push(null, key.commitId);
            return loadRegions(gen);
        } finally {
            gen.release();
        }
    } finally {
        key.repo = null;
    }
}

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

License:Open Source License

private List<BlameCache.Region> loadBlame(Key key) throws IOException {
    try {//  ww w . j av 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;
    }
}