/** * @param path the path filter to use during the diff operation, replaces any other filter * previously set * @return {@code this} */ public DiffTree setPathFilter(@Nullable String path) { if (path == null) { setPathFilter((List<String>) null); } else { setPathFilter(ImmutableList.of(path)); } return this; }
/** * @param path the path filter to use during the diff operation, replaces any other filter * previously set * @return {@code this} */ public DiffTree setPathFilter(@Nullable String path) { if (path == null) { setPathFilter((List<String>) null); } else { setPathFilter(ImmutableList.of(path)); } return this; }
/** * Finds differences between the tree pointed to by the given ref and the index. * * @return an iterator to a set of differences between the two trees * @see DiffEntry */ @Override protected AutoCloseableIterator<DiffEntry> _call() { final String oldVersion = Optional.fromNullable(refSpec).or(Ref.HEAD); final Optional<ObjectId> rootTreeId; rootTreeId = command(ResolveTreeish.class).setTreeish(oldVersion).call(); Preconditions.checkArgument(rootTreeId.isPresent(), "refSpec %s did not resolve to a tree", oldVersion); final RevTree rootTree; rootTree = command(RevObjectParse.class).setObjectId(rootTreeId.get()).call(RevTree.class) .get(); final RevTree newTree = stagingArea().getTree(); DiffTree diff = command(DiffTree.class).setPathFilter(this.pathFilters) .setReportTrees(this.reportTrees).setOldTree(rootTree.getId()) .setNewTree(newTree.getId()).setPreserveIterationOrder(preserveIterationOrder) .setMaxDiffs(limit); return diff.call(); }
/** * Finds differences between the tree pointed to by the given ref and the index. * * @return an iterator to a set of differences between the two trees * @see DiffEntry */ @Override protected AutoCloseableIterator<DiffEntry> _call() { final String oldVersion = Optional.fromNullable(refSpec).or(Ref.HEAD); final Optional<ObjectId> rootTreeId; rootTreeId = command(ResolveTreeish.class).setTreeish(oldVersion).call(); Preconditions.checkArgument(rootTreeId.isPresent(), "refSpec %s did not resolve to a tree", oldVersion); final RevTree rootTree; rootTree = command(RevObjectParse.class).setObjectId(rootTreeId.get()).call(RevTree.class) .get(); final RevTree newTree = stagingArea().getTree(); DiffTree diff = command(DiffTree.class).setPathFilter(this.pathFilters) .setReportTrees(this.reportTrees).setOldTree(rootTree.getId()) .setNewTree(newTree.getId()).setPreserveIterationOrder(preserveIterationOrder) .setMaxDiffs(limit); return diff.call(); }
private List<DiffEntry> getExpectedEntries(String layerName, String oldHead, String newHead) { AutoCloseableIterator<DiffEntry> diffs = repo.command(DiffTree.class) .setPathFilter(layerName).setOldVersion(oldHead).setNewVersion(newHead).call(); return Lists.newArrayList(diffs); }
/** * If no {@link #setOldVersion(String) old version} was set, returns the differences between the * working tree and the index, otherwise the differences between the working tree and the * specified revision. * * @return an iterator to a set of differences between the two trees * @see DiffEntry */ @Override protected AutoCloseableIterator<DiffEntry> _call() { final Optional<String> ref = Optional.fromNullable(refSpec); final RevTree oldTree = ref.isPresent() ? getOldTree() : stagingArea().getTree(); final RevTree newTree = workingTree().getTree(); DiffTree diff = command(DiffTree.class).setReportTrees(this.reportTrees) .setOldTree(oldTree.getId()).setNewTree(newTree.getId()).setMaxDiffs(limit) .setPreserveIterationOrder(preserveIterationOrder); if (this.pathFilter != null) { diff.setPathFilter(ImmutableList.of(pathFilter)); } return diff.call(); }
/** * If no {@link #setOldVersion(String) old version} was set, returns the differences between the * working tree and the index, otherwise the differences between the working tree and the * specified revision. * * @return an iterator to a set of differences between the two trees * @see DiffEntry */ @Override protected AutoCloseableIterator<DiffEntry> _call() { final Optional<String> ref = Optional.fromNullable(refSpec); final RevTree oldTree = ref.isPresent() ? getOldTree() : stagingArea().getTree(); final RevTree newTree = workingTree().getTree(); DiffTree diff = command(DiffTree.class).setReportTrees(this.reportTrees) .setOldTree(oldTree.getId()).setNewTree(newTree.getId()).setMaxDiffs(limit) .setPreserveIterationOrder(preserveIterationOrder); if (this.pathFilter != null) { diff.setPathFilter(ImmutableList.of(pathFilter)); } return diff.call(); }
.setPathFilter(new ArrayList<>(strippedPathFilters)).setCustomFilter(null);
.setPathFilter(new ArrayList<>(strippedPathFilters)).setCustomFilter(null);
@Test public void testTreePathFiltering() { ObjectDatabase db = geogig.getContext().objectDatabase(); RevTree tree1 = tree(100, db); RevTree tree2 = tree(50, db); RevTree root = createRoot(db, tree1, tree2); List<String> pathFilters = ImmutableList.of("tree1"); diffTree.setOldTree(ObjectId.NULL).setNewTree(root.getId()).setPathFilter(pathFilters); List<DiffEntry> diffs = ImmutableList.copyOf(diffTree.call()); assertEquals(tree1.size(), diffs.size()); pathFilters = ImmutableList.of("tree2"); diffTree.setOldTree(ObjectId.NULL).setNewTree(root.getId()).setPathFilter(pathFilters); diffs = ImmutableList.copyOf(diffTree.call()); assertEquals(tree2.size(), diffs.size()); pathFilters = ImmutableList.of("tree1/1", "tree1/2", "tree1/3", "tree1/4", "tree2/2", "tree2/3", "tree2/10"); diffTree.setOldTree(ObjectId.NULL).setNewTree(root.getId()).setPathFilter(pathFilters); diffs = ImmutableList.copyOf(diffTree.call()); assertEquals(pathFilters.size(), diffs.size()); }
@Test public void testTreePathFiltering() { ObjectDatabase db = geogig.getContext().objectDatabase(); RevTree tree1 = tree(100, db); RevTree tree2 = tree(50, db); RevTree root = createRoot(db, tree1, tree2); List<String> pathFilters = ImmutableList.of("tree1"); diffTree.setOldTree(ObjectId.NULL).setNewTree(root.getId()).setPathFilter(pathFilters); List<DiffEntry> diffs = ImmutableList.copyOf(diffTree.call()); assertEquals(tree1.size(), diffs.size()); pathFilters = ImmutableList.of("tree2"); diffTree.setOldTree(ObjectId.NULL).setNewTree(root.getId()).setPathFilter(pathFilters); diffs = ImmutableList.copyOf(diffTree.call()); assertEquals(tree2.size(), diffs.size()); pathFilters = ImmutableList.of("tree1/1", "tree1/2", "tree1/3", "tree1/4", "tree2/2", "tree2/3", "tree2/10"); diffTree.setOldTree(ObjectId.NULL).setNewTree(root.getId()).setPathFilter(pathFilters); diffs = ImmutableList.copyOf(diffTree.call()); assertEquals(pathFilters.size(), diffs.size()); }
private AutoCloseableIterator<DiffEntry> buildDiffEntries(GeogigCLI cli) { org.locationtech.geogig.plumbing.DiffTree diff = cli.getGeogig() .command(org.locationtech.geogig.plumbing.DiffTree.class); String oldVersion = resolveOldVersion(); String newVersion = resolveNewVersion(); diff.setOldVersion(oldVersion).setNewVersion(newVersion); AutoCloseableIterator<DiffEntry> diffEntries; if (paths.isEmpty()) { diffEntries = diff.setProgressListener(cli.getProgressListener()).call(); } else { diffEntries = AutoCloseableIterator.emptyIterator(); for (String path : paths) { AutoCloseableIterator<DiffEntry> moreEntries = diff.setPathFilter(path) .setProgressListener(cli.getProgressListener()).call(); diffEntries = AutoCloseableIterator.concat(diffEntries, moreEntries); } } return diffEntries; }
.setPathFilter(pathFilter).setReportTrees(reportTrees) .setPreserveIterationOrder(preserveIterationOrder).call();
private AutoCloseableIterator<DiffEntry> buildDiffEntries(GeogigCLI cli) { org.locationtech.geogig.plumbing.DiffTree diff = cli.getGeogig() .command(org.locationtech.geogig.plumbing.DiffTree.class); String oldVersion = resolveOldVersion(); String newVersion = resolveNewVersion(); diff.setOldVersion(oldVersion).setNewVersion(newVersion); AutoCloseableIterator<DiffEntry> diffEntries; if (paths.isEmpty()) { diffEntries = diff.setProgressListener(cli.getProgressListener()).call(); } else { diffEntries = AutoCloseableIterator.emptyIterator(); for (String path : paths) { AutoCloseableIterator<DiffEntry> moreEntries = diff.setPathFilter(path) .setProgressListener(cli.getProgressListener()).call(); diffEntries = AutoCloseableIterator.concat(diffEntries, moreEntries); } } return diffEntries; }
private AutoCloseableIterator<DiffEntry> buildDiffEntries(GeogigCLI cli) { org.locationtech.geogig.plumbing.DiffTree diff = cli.getGeogig() .command(org.locationtech.geogig.plumbing.DiffTree.class); String oldVersion = resolveOldVersion(); String newVersion = resolveNewVersion(); diff.setOldVersion(oldVersion).setNewVersion(newVersion); AutoCloseableIterator<DiffEntry> diffEntries; if (paths.isEmpty()) { diffEntries = diff.setProgressListener(cli.getProgressListener()).call(); } else { diffEntries = AutoCloseableIterator.emptyIterator(); for (String path : paths) { AutoCloseableIterator<DiffEntry> moreEntries = diff.setPathFilter(path) .setProgressListener(cli.getProgressListener()).call(); diffEntries = AutoCloseableIterator.concat(diffEntries, moreEntries); } } return diffEntries; }
.setPathFilter(pathFilter).setReportTrees(reportTrees) .setPreserveIterationOrder(preserveIterationOrder).call();
DiffTree diffOp = command(DiffTree.class) .setOldTree(repository.index().getTree().getId()) .setNewTree(oldCommit.getTreeId()).setPathFilter(pattern);
protected @Override List<DiffEntry> _call() { TreeChangesCollector collector = new TreeChangesCollector(); DiffTree diffTree = command(DiffTree.class)// .setPreserveIterationOrder(false)// .setReportFeatures(false)// .setReportTrees(true)// .setPathFilter(this.pathFilters)// .setLeftSource(leftSource)// .setRightSource(rightSource); if (oldTree != null) { diffTree.setOldTree(oldTree); } else if (oldTreeId != null) { diffTree.setOldTree(oldTreeId); } else { diffTree.setOldVersion(oldRefSpec); } if (newTree != null) { diffTree.setNewTree(newTree); } else if (newTreeId != null) { diffTree.setNewTree(newTreeId); } else { diffTree.setNewVersion(newRefSpec); } diffTree.call(collector); List<DiffEntry> res = new ArrayList<>(collector.queue); return res; }
diffTree.setPathFilter("tree1"); assertChangeTypeFilter(rootId1, rootId2, 0, 0, 0); assertChangeTypeFilter(rootId2, rootId1, 0, 0, 0); diffTree.setPathFilter("tree2"); assertChangeTypeFilter(rootId1, rootId2, 0, 5, 5); assertChangeTypeFilter(rootId2, rootId1, 5, 0, 5); diffTree.setPathFilter(ImmutableList.of("tree2/0", "tree2/2", "tree2/4", "tree2/12"));
diffTree.setPathFilter("tree1"); assertChangeTypeFilter(rootId1, rootId2, 0, 0, 0); assertChangeTypeFilter(rootId2, rootId1, 0, 0, 0); diffTree.setPathFilter("tree2"); assertChangeTypeFilter(rootId1, rootId2, 0, 5, 5); assertChangeTypeFilter(rootId2, rootId1, 5, 0, 5); diffTree.setPathFilter(ImmutableList.of("tree2/0", "tree2/2", "tree2/4", "tree2/12"));