/** * @return the differences between the given right tree(staged) and the resulting tree after * running {@link WriteTree2} with the given filters. The result's left refs are the * ones in the new tree, and the right refs the same as given in the rightTree */ private MapDifference<String, NodeRef> runWithPathFilter(RevTree leftTree, RevTree rightTree, String... filters) { // print(leftTree.getId()); // print(rightTree.getId()); final ObjectId newRepoRoot = command.setPathFilter(Arrays.asList(filters)).call(); assertNotNull(newRepoRoot); // print(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); final boolean includeFeatures = true; ImmutableMap<String, NodeRef> stagedRefs = getRefsByPath(rightTree.getId(), includeFeatures); ImmutableMap<String, NodeRef> resultRefs = getRefsByPath(newRepoRoot, includeFeatures); MapDifference<String, NodeRef> difference = Maps.difference(resultRefs, stagedRefs); return difference; }
/** * @return the differences between the given right tree(staged) and the resulting tree after * running {@link WriteTree2} with the given filters. The result's left refs are the * ones in the new tree, and the right refs the same as given in the rightTree */ private MapDifference<String, NodeRef> runWithPathFilter(RevTree leftTree, RevTree rightTree, String... filters) { // print(leftTree.getId()); // print(rightTree.getId()); final ObjectId newRepoRoot = command.setPathFilter(Arrays.asList(filters)).call(); assertNotNull(newRepoRoot); // print(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); final boolean includeFeatures = true; ImmutableMap<String, NodeRef> stagedRefs = getRefsByPath(rightTree.getId(), includeFeatures); ImmutableMap<String, NodeRef> resultRefs = getRefsByPath(newRepoRoot, includeFeatures); MapDifference<String, NodeRef> difference = Maps.difference(resultRefs, stagedRefs); return difference; }
@Test public void testSimpleChanges() { leftTree = createHeadTree(// repoTree("roads", "a1", "d1", 1), // repoTree("buildings", EMPTY_ID, null, 0)// ); rightTree = createStageHeadTree(// repoTree("roads", "a11", "d1", 2), // repoTree("buildings", "a41", null, 1)// ); // print(leftTree.getId()); // print(rightTree.getId()); final ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getRefsByPath(newRepoRoot, true); Set<String> expected = set("roads", "roads/roads.0", "roads/roads.1", "buildings", "buildings/buildings.0"); ImmutableSet<String> actual = refsByPath.keySet(); assertEquals(expected, actual); }
@Test public void testSimpleChanges() { leftTree = createHeadTree(// repoTree("roads", "a1", "d1", 1), // repoTree("buildings", EMPTY_ID, null, 0)// ); rightTree = createStageHeadTree(// repoTree("roads", "a11", "d1", 2), // repoTree("buildings", "a41", null, 1)// ); // print(leftTree.getId()); // print(rightTree.getId()); final ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getRefsByPath(newRepoRoot, true); Set<String> expected = set("roads", "roads/roads.0", "roads/roads.1", "buildings", "buildings/buildings.0"); ImmutableSet<String> actual = refsByPath.keySet(); assertEquals(expected, actual); }
ImmutableMap<String, NodeRef> refsByPath = getRefsByPath(newRepoRoot, true); Set<String> paths = Sets.newTreeSet(); paths.addAll(refsByPath.keySet());
ImmutableMap<String, NodeRef> refsByPath = getRefsByPath(newRepoRoot, true); Set<String> paths = Sets.newTreeSet(); paths.addAll(refsByPath.keySet());
@Test public void testNestedChanges() { leftTree = createHeadTree(// repoTree("roads", EMPTY_ID, null, 0), // repoTree("roads/highways", EMPTY_ID, "d1", 0), // repoTree("roads/streets", "a3", "d2", 1), // repoTree("buildings", EMPTY_ID, null, 0), // repoTree("buildings/stores", EMPTY_ID, "d3", 0), // repoTree("buildings/unknown", "a6", "d4", 1)// ); rightTree = createStageHeadTree(// indexTree("roads", EMPTY_ID, null, 0), // indexTree("roads/highways", "a21", "d1", 1), // 1 added indexTree("roads/streets", EMPTY_ID, "d2", 0), // 1 removed indexTree("buildings", EMPTY_ID, null, 0), // indexTree("buildings/stores", "a51", "d3", 2), // 2 added indexTree("buildings/unknown", "a6", "d4", 1)// not changed ); final ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getRefsByPath(newRepoRoot, true); Set<String> expected = set("roads", "roads/highways", "roads/highways/highways.0", "roads/streets", "buildings", "buildings/stores", "buildings/stores/stores.0", "buildings/stores/stores.1", "buildings/unknown", "buildings/unknown/unknown.0"); ImmutableSet<String> actual = refsByPath.keySet(); assertEquals(expected, actual); }
@Test public void testNestedChanges() { leftTree = createHeadTree(// repoTree("roads", EMPTY_ID, null, 0), // repoTree("roads/highways", EMPTY_ID, "d1", 0), // repoTree("roads/streets", "a3", "d2", 1), // repoTree("buildings", EMPTY_ID, null, 0), // repoTree("buildings/stores", EMPTY_ID, "d3", 0), // repoTree("buildings/unknown", "a6", "d4", 1)// ); rightTree = createStageHeadTree(// indexTree("roads", EMPTY_ID, null, 0), // indexTree("roads/highways", "a21", "d1", 1), // 1 added indexTree("roads/streets", EMPTY_ID, "d2", 0), // 1 removed indexTree("buildings", EMPTY_ID, null, 0), // indexTree("buildings/stores", "a51", "d3", 2), // 2 added indexTree("buildings/unknown", "a6", "d4", 1)// not changed ); final ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getRefsByPath(newRepoRoot, true); Set<String> expected = set("roads", "roads/highways", "roads/highways/highways.0", "roads/streets", "buildings", "buildings/stores", "buildings/stores/stores.0", "buildings/stores/stores.1", "buildings/unknown", "buildings/unknown/unknown.0"); ImmutableSet<String> actual = refsByPath.keySet(); assertEquals(expected, actual); }