Package org.locationtech.geogig.api.plumbing.diff

Examples of org.locationtech.geogig.api.plumbing.diff.MutableTree


        final ProgressListener progress = getProgressListener();

        TreeDifference treeDifference = computeTreeDifference();

        if (treeDifference.areEqual()) {
            MutableTree leftTree = treeDifference.getLeftTree();
            Node leftNode = leftTree.getNode();
            ObjectId leftOid = leftNode.getObjectId();
            return leftOid;
        }

        final MutableTree oldLeftTree = treeDifference.getLeftTree().clone();
        Preconditions.checkState(oldLeftTree.equals(treeDifference.getLeftTree()));

        // handle renames before new and deleted trees for the computation of new and deleted to be
        // accurate
        Set<String> ignoreList = Sets.newHashSet();
        handleRenames(treeDifference, ignoreList);
        handlePureMetadataChanges(treeDifference, ignoreList);
        handleNewTrees(treeDifference, ignoreList);
        handleDeletedTrees(treeDifference, ignoreList);
        handleRemainingDifferences(treeDifference, ignoreList);

        progress.complete();

        MutableTree newLeftTree = treeDifference.getLeftTree();

        final ObjectDatabase repositoryDatabase = objectDatabase();
        final RevTree newRoot = newLeftTree.build(stagingDatabase(), repositoryDatabase);
        if (newRoot.trees().isPresent()) {
            for (Node n : newRoot.trees().get()) {
                if (n.getMetadataId().isPresent()) deepMove(n.getMetadataId().get());
            }
        }
View Full Code Here


            ignoreList.add(treePath);
            if (!filterMatchesOrIsParent(treePath)) {
                continue;// filter doesn't apply to the changed tree
            }
            deepMove(newValue.getMetadataId());
            MutableTree leftTree = treeDifference.getLeftTree();
            leftTree.setChild(newValue.getParentPath(), newValue.getNode());
        }
    }
View Full Code Here

            if (!filterMatchesOrIsParent(path)) {
                if (filterApplies(path, treeDifference.getRightTree())) {
                    // can't optimize
                    RevTree newTree = applyChanges(ref, null);
                    Node newNode = Node.tree(ref.name(), newTree.getId(), ref.getMetadataId());
                    MutableTree leftTree = treeDifference.getLeftTree();
                    leftTree.forceChild(ref.getParentPath(), newNode);
                }
            } else {
                MutableTree leftTree = treeDifference.getLeftTree();
                leftTree.removeChild(path);
            }
        }
    }
View Full Code Here

                continue;
            }
            ignoreList.add(path);

            if (!filterMatchesOrIsParent(path)) {
                MutableTree rightTree = treeDifference.getRightTree();
                if (filterApplies(path, rightTree)) {
                    // can't optimize
                    RevTree newTree = applyChanges(null, ref);
                    Node newNode = Node.tree(ref.name(), newTree.getId(), ref.getMetadataId());
                    MutableTree leftTree = treeDifference.getLeftTree();
                    leftTree.forceChild(ref.getParentPath(), newNode);
                }
            } else {
                LOGGER.trace("Creating new tree {}", path);
                deepMove(ref.getNode());
                MutableTree leftTree = treeDifference.getLeftTree();
                String parentPath = ref.getParentPath();
                Node node = ref.getNode();
                leftTree.setChild(parentPath, node);
            }
        }
    }
View Full Code Here

            ignoreList.add(newPath);
            if (!filterMatchesOrIsParent(newPath)) {
                continue;// filter doesn't apply to the renamed tree as a whole
            }
            LOGGER.trace("Handling rename of {} as {}", oldValue.path(), newPath);
            MutableTree leftTree = treeDifference.getLeftTree();
            leftTree.removeChild(oldValue.path());
            leftTree.setChild(newValue.getParentPath(), newValue.getNode());
        }
    }
View Full Code Here

            Envelope bounds = SpatialOps.boundsOf(tree);
            Node newTreeNode = Node.create(rightTreeRef.name(), tree.getId(),
                    rightTreeRef.getMetadataId(), TYPE.TREE, bounds);

            MutableTree leftRoot = treeDifference.getLeftTree();
            String parentPath = rightTreeRef.getParentPath();
            leftRoot.setChild(parentPath, newTreeNode);
        }
    }
View Full Code Here

                    Strategy.DEPTHFIRST_ONLY_TREES);
        }
        rightTreeRefs = command(LsTreeOp.class).setReference(rightTreeish).setStrategy(
                Strategy.DEPTHFIRST_ONLY_TREES);

        MutableTree leftTree = MutableTree.createFromRefs(rootTreeId, leftTreeRefs);
        MutableTree rightTree = MutableTree.createFromRefs(stageRootId, rightTreeRefs);

        TreeDifference treeDifference = TreeDifference.create(leftTree, rightTree);
        return treeDifference;
    }
View Full Code Here

        geogig.command(UpdateRef.class).setName(Ref.STAGE_HEAD).setNewValue(root.getId()).call();
        return root;
    }

    private RevTree createFromRefs(ObjectDatabase targetDb, NodeRef... treeRefs) {
        MutableTree mutableTree = MutableTree.createFromRefs(RevTree.EMPTY_TREE_ID, treeRefs);
        RevTree tree = mutableTree.build(indexDb, targetDb);
        return tree;
    }
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.plumbing.diff.MutableTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.