Search in sources :

Example 1 with DiffIndex

use of org.locationtech.geogig.api.plumbing.DiffIndex in project GeoGig by boundlessgeo.

the class DiffOp method _call.

/**
     * Executes the diff operation.
     * 
     * @return an iterator to a set of differences between the two trees
     * @see DiffEntry
     */
@Override
protected Iterator<DiffEntry> _call() {
    checkArgument(cached && oldRefSpec == null || !cached, String.format("compare index allows only one revision to check against, got %s / %s", oldRefSpec, newRefSpec));
    checkArgument(newRefSpec == null || oldRefSpec != null, "If new rev spec is specified then old rev spec is mandatory");
    Iterator<DiffEntry> iterator;
    if (cached) {
        // compare the tree-ish (default to HEAD) and the index
        DiffIndex diffIndex = command(DiffIndex.class).addFilter(this.pathFilter).setReportTrees(reportTrees);
        if (oldRefSpec != null) {
            diffIndex.setOldVersion(oldRefSpec);
        }
        iterator = diffIndex.call();
    } else if (newRefSpec == null) {
        DiffWorkTree workTreeIndexDiff = command(DiffWorkTree.class).setFilter(pathFilter).setReportTrees(reportTrees);
        if (oldRefSpec != null) {
            workTreeIndexDiff.setOldVersion(oldRefSpec);
        }
        iterator = workTreeIndexDiff.call();
    } else {
        iterator = command(DiffTree.class).setOldVersion(oldRefSpec).setNewVersion(newRefSpec).setPathFilter(pathFilter).setReportTrees(reportTrees).call();
    }
    return iterator;
}
Also used : DiffTree(org.locationtech.geogig.api.plumbing.DiffTree) DiffIndex(org.locationtech.geogig.api.plumbing.DiffIndex) DiffWorkTree(org.locationtech.geogig.api.plumbing.DiffWorkTree) DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry)

Aggregations

DiffIndex (org.locationtech.geogig.api.plumbing.DiffIndex)1 DiffTree (org.locationtech.geogig.api.plumbing.DiffTree)1 DiffWorkTree (org.locationtech.geogig.api.plumbing.DiffWorkTree)1 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)1