Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.RevCommit


    }

    @Test
    public void testRevertOnlyCommit() throws Exception {
        insertAndAdd(points1);
        RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();

        geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c1.getId())).call();

        final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.HEAD).call();

        final Optional<ObjectId> headTreeId = geogig.command(ResolveTreeish.class)
                .setTreeish(currHead.get().getObjectId()).call();
View Full Code Here


    }

    @Test
    public void testNoUserNameForResolveCommiter() throws Exception {
        insertAndAdd(points1);
        RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
        repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.name")
                .setValue(null).call();
        exception.expect(IllegalStateException.class);
        geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c1.getId())).call();
    }
View Full Code Here

    }

    @Test
    public void testNoUserEmailForResolveCommiterEmail() throws Exception {
        insertAndAdd(points1);
        RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
        repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.email")
                .setValue(null).call();
        exception.expect(IllegalStateException.class);
        geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c1.getId())).call();
    }
View Full Code Here

    }

    @Test
    public void testRevertUsingContinueAndAbort() throws Exception {
        insertAndAdd(points1);
        RevCommit commit = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
        exception.expect(IllegalArgumentException.class);
        geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(commit.getId()))
                .setAbort(true).setContinue(true).call();
    }
View Full Code Here

    }

    @Test
    public void testStillDeletedMergeConflictResolution() throws Exception {
        insertAndAdd(points1);
        @SuppressWarnings("unused")
        RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
        deleteAndAdd(points1);
        RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for removing " + idP1)
                .call();
        @SuppressWarnings("unused")
        ObjectId oId1 = insertAndAdd(points1);
        @SuppressWarnings("unused")
        RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for " + idP1 + " again")
                .call();
        try {
            geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c2.getId())).call();
            fail();
View Full Code Here

    @Test
    public void testRevertToSameFeatureIsNotConflict() throws Exception {
        @SuppressWarnings("unused")
        ObjectId oId1 = insertAndAdd(points1);
        @SuppressWarnings("unused")
        RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
        insertAndAdd(points1_modified);
        RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for modified " + idP1)
                .call();
        insertAndAdd(points1);
        @SuppressWarnings("unused")
        RevCommit c3 = geogig.command(CommitOp.class)
                .setMessage("commit for modified " + idP1 + " again").call();

        geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c2.getId())).call();
View Full Code Here

    }

    @Test
    public void testRevertModifiedFeatureConflictSolveAndContinue() throws Exception {
        ObjectId oId1 = insertAndAdd(points1);
        RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
        insertAndAdd(points1_modified);
        RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for modified " + idP1)
                .call();
        Feature points1_modifiedB = feature(pointsType, idP1, "StringProp1_2", new Integer(2000),
                "POINT(1 1)");
        insertAndAdd(points1_modifiedB);
        RevCommit c3 = geogig.command(CommitOp.class)
                .setMessage("commit for modified " + idP1 + " again").call();
        try {
            geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c2.getId())).call();
            fail();
        } catch (RevertConflictsException e) {
            assertTrue(e.getMessage().contains(idP1));
        }

        Optional<Ref> ref = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call();
        assertTrue(ref.isPresent());
        assertEquals(c3.getId(), ref.get().getObjectId());

        List<Conflict> conflicts = geogig.command(ConflictsReadOp.class).call();
        assertEquals(1, conflicts.size());
        String path = NodeRef.appendChild(pointsName, idP1);
        assertEquals(conflicts.get(0).getPath(), path);
        assertEquals(conflicts.get(0).getOurs(), RevFeatureBuilder.build(points1_modifiedB).getId());
        assertEquals(conflicts.get(0).getTheirs(), RevFeatureBuilder.build(points1).getId());

        // solve, and continue
        insert(points1);
        geogig.command(AddOp.class).call();
        geogig.command(RevertOp.class).setContinue(true).call();

        Iterator<RevCommit> log = geogig.command(LogOp.class).call();
        RevCommit logCommit = log.next();
        assertEquals(c2.getAuthor().getName(), logCommit.getAuthor().getName());
        assertEquals(c2.getCommitter().getName(), logCommit.getCommitter().getName());
        assertEquals("Revert '" + c2.getMessage() + "'\nThis reverts " + c2.getId().toString(),
                logCommit.getMessage());
        assertNotSame(c2.getCommitter().getTimestamp(), logCommit.getCommitter().getTimestamp());
        assertNotSame(c2.getTreeId(), logCommit.getTreeId());

        final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.HEAD).call();

        final Optional<ObjectId> headTreeId = geogig.command(ResolveTreeish.class)
                .setTreeish(currHead.get().getObjectId()).call();
View Full Code Here

    }

    @Test
    public void testRevertModifiedFeatureConflictAndAbort() throws Exception {
        insertAndAdd(points1);
        @SuppressWarnings("unused")
        RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
        insertAndAdd(points1_modified);
        RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for modified " + idP1)
                .call();
        Feature points1_modifiedB = feature(pointsType, idP1, "StringProp1_2", new Integer(2000),
                "POINT(1 1)");
        ObjectId oId = insertAndAdd(points1_modifiedB);
        RevCommit c3 = geogig.command(CommitOp.class)
                .setMessage("commit for modified " + idP1 + " again").call();
        try {
            geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c2.getId())).call();
            fail();
        } catch (RevertConflictsException e) {
            assertTrue(e.getMessage().contains(idP1));
        }

        Optional<Ref> ref = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call();
        assertTrue(ref.isPresent());
        assertEquals(c3.getId(), ref.get().getObjectId());

        List<Conflict> conflicts = geogig.command(ConflictsReadOp.class).call();
        assertEquals(1, conflicts.size());
        String path = NodeRef.appendChild(pointsName, idP1);
        assertEquals(conflicts.get(0).getPath(), path);
View Full Code Here

    }

    @Test
    public void testRevertEntireFeatureTypeTree() throws Exception {
        insertAndAdd(points1);
        RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
        insertAndAdd(points2);
        RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
        insertAndAdd(points3);
        RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for " + idP3).call();
        insertAndAdd(lines1);
        RevCommit c4 = geogig.command(CommitOp.class).setMessage("commit for " + idL1).call();

        geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c4.getId())).call();

        final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.HEAD).call();

        final Optional<ObjectId> headTreeId = geogig.command(ResolveTreeish.class)
                .setTreeish(currHead.get().getObjectId()).call();

        RevTree headTree = repo.getTree(headTreeId.get());

        Optional<NodeRef> lines1Node = geogig.command(FindTreeChild.class)
                .setChildPath(NodeRef.appendChild(linesName, idL1)).setParent(headTree).call();

        assertFalse(lines1Node.isPresent());

        @SuppressWarnings("unused")
        Optional<NodeRef> linesNode = geogig.command(FindTreeChild.class).setChildPath(linesName)
                .setParent(headTree).call();

        // assertFalse(linesNode.isPresent());

        Iterator<RevCommit> log = geogig.command(LogOp.class).call();
        log.next();
        assertEquals(c4.getId(), log.next().getId());
        assertEquals(c3.getId(), log.next().getId());
        assertEquals(c2.getId(), log.next().getId());
        assertEquals(c1.getId(), log.next().getId());
        assertFalse(log.hasNext());
    }
View Full Code Here

        }

        insertAndAdd(points1);

        geogig.command(AddOp.class).addPattern(".").call();
        RevCommit commit = geogig.command(CommitOp.class).call();

        ObjectId oid = insertAndAdd(points1_modified);

        CommitOp commitCommand = geogig.command(CommitOp.class);
        commit = commitCommand.setAll(true).call();
        assertNotNull(commit);
        assertNotNull(commit.getParentIds());
        assertEquals(1, commit.getParentIds().size());
        assertNotNull(commit.getId());

        ObjectId treeId = commit.getTreeId();

        assertNotNull(treeId);
        RevTree root = repo.getTree(treeId);
        assertNotNull(root);

        Optional<Node> typeTreeId = repo.getTreeChild(root, pointsName);
        assertTrue(typeTreeId.isPresent());

        RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId());
        assertNotNull(typeTree);

        String featureId = points1.getIdentifier().getID();
        Optional<Node> featureBlobId = repo.getTreeChild(root,
                NodeRef.appendChild(pointsName, featureId));
        assertTrue(featureBlobId.isPresent());
        assertEquals(oid, featureBlobId.get().getObjectId());

        ObjectId commitId = geogig.command(RevParse.class).setRefSpec(Ref.HEAD).call().get();
        assertEquals(commit.getId(), commitId);
    }
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.RevCommit

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.