Search in sources :

Example 71 with ObjectId

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

the class SquashOpTest method testSquashWithMergedBranch.

@Test
public void testSquashWithMergedBranch() throws Exception {
    // Try to squash the commits marked (*) in this history
    // o
    // |
    // o - Points 1 added
    // |\
    // | o - branch1 - Points 2 added
    // | |
    // o | - Points 3 added*
    // | |
    // o | - Lines 1 added*
    // |/
    // o - master - HEAD - Merge commit
    insertAndAdd(points1);
    @SuppressWarnings("unused") final RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
    geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch1").call();
    insertAndAdd(points2);
    final RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
    geogig.command(CheckoutOp.class).setSource("master").call();
    insertAndAdd(points3);
    final RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for " + idP3).call();
    insertAndAdd(lines1);
    final RevCommit c4 = geogig.command(CommitOp.class).setMessage("commit for " + idL1).call();
    Ref branch1 = geogig.command(RefParse.class).setName("branch1").call().get();
    geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(branch1.getObjectId())).setMessage("My merge message.").call();
    geogig.command(SquashOp.class).setSince(c3).setUntil(c4).setMessage("Squashed").call();
    // check that the commit added after the squashed has all the parents
    ArrayList<RevCommit> log = Lists.newArrayList(geogig.command(LogOp.class).setFirstParentOnly(true).call());
    assertEquals(3, log.size());
    ImmutableList<ObjectId> parents = log.get(0).getParentIds();
    assertEquals(2, parents.size());
    assertEquals("Squashed", log.get(1).getMessage());
    assertEquals(log.get(1).getId(), parents.get(0));
    assertEquals(c2.getId(), parents.get(1));
}
Also used : Ref(org.locationtech.geogig.api.Ref) BranchCreateOp(org.locationtech.geogig.api.porcelain.BranchCreateOp) ObjectId(org.locationtech.geogig.api.ObjectId) LogOp(org.locationtech.geogig.api.porcelain.LogOp) RefParse(org.locationtech.geogig.api.plumbing.RefParse) MergeOp(org.locationtech.geogig.api.porcelain.MergeOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 72 with ObjectId

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

the class RevertOpTest method testRevertOnlyCommit.

@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();
    RevTree headTree = repo.getTree(headTreeId.get());
    Optional<NodeRef> points1Node = geogig.command(FindTreeChild.class).setChildPath(NodeRef.appendChild(pointsName, idP1)).setParent(headTree).call();
    assertFalse(points1Node.isPresent());
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) Ref(org.locationtech.geogig.api.Ref) NodeRef(org.locationtech.geogig.api.NodeRef) ObjectId(org.locationtech.geogig.api.ObjectId) FindTreeChild(org.locationtech.geogig.api.plumbing.FindTreeChild) RevTree(org.locationtech.geogig.api.RevTree) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 73 with ObjectId

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

the class RevertOpTest method testStillDeletedMergeConflictResolution.

@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();
    } catch (RevertConflictsException e) {
        assertTrue(e.getMessage().contains(idP1));
    }
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) RevertConflictsException(org.locationtech.geogig.api.porcelain.RevertConflictsException) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 74 with ObjectId

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

the class RevertOpTest method testRevertEntireFeatureTypeTree.

@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());
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) Ref(org.locationtech.geogig.api.Ref) NodeRef(org.locationtech.geogig.api.NodeRef) ObjectId(org.locationtech.geogig.api.ObjectId) LogOp(org.locationtech.geogig.api.porcelain.LogOp) FindTreeChild(org.locationtech.geogig.api.plumbing.FindTreeChild) RevTree(org.locationtech.geogig.api.RevTree) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 75 with ObjectId

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

the class RevertOpTest method testRevertWithoutCommit.

@Test
public void testRevertWithoutCommit() throws Exception {
    ObjectId oId1 = 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(points1_modified);
    RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for modified " + idP1).call();
    ObjectId oId3 = insertAndAdd(points3);
    RevCommit c4 = geogig.command(CommitOp.class).setMessage("commit for " + idP3).call();
    deleteAndAdd(points3);
    RevCommit c5 = geogig.command(CommitOp.class).setMessage("commit for deleted " + idP3).call();
    // revert Points.2 add, Points.1 change, and Points.3 delete
    geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c2.getId())).addCommit(Suppliers.ofInstance(c3.getId())).addCommit(Suppliers.ofInstance(c5.getId())).setCreateCommit(false).call();
    final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.WORK_HEAD).call();
    final Optional<ObjectId> headTreeId = geogig.command(ResolveTreeish.class).setTreeish(currHead.get().getObjectId()).call();
    RevTree headTree = repo.getTree(headTreeId.get());
    Optional<NodeRef> points1Node = geogig.command(FindTreeChild.class).setIndex(true).setChildPath(NodeRef.appendChild(pointsName, idP1)).setParent(headTree).call();
    assertTrue(points1Node.isPresent());
    assertEquals(oId1, points1Node.get().getNode().getObjectId());
    Optional<NodeRef> points2Node = geogig.command(FindTreeChild.class).setIndex(true).setChildPath(NodeRef.appendChild(pointsName, idP2)).setParent(headTree).call();
    assertFalse(points2Node.isPresent());
    Optional<NodeRef> points3Node = geogig.command(FindTreeChild.class).setIndex(true).setChildPath(NodeRef.appendChild(pointsName, idP3)).setParent(headTree).call();
    assertTrue(points3Node.isPresent());
    assertEquals(oId3, points3Node.get().getNode().getObjectId());
    Iterator<RevCommit> log = geogig.command(LogOp.class).call();
    // There should only the old commits.
    assertEquals(c5.getId(), log.next().getId());
    assertEquals(c4.getId(), log.next().getId());
    assertEquals(c3.getId(), log.next().getId());
    assertEquals(c2.getId(), log.next().getId());
    assertEquals(c1.getId(), log.next().getId());
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) Ref(org.locationtech.geogig.api.Ref) NodeRef(org.locationtech.geogig.api.NodeRef) RevertOp(org.locationtech.geogig.api.porcelain.RevertOp) ObjectId(org.locationtech.geogig.api.ObjectId) LogOp(org.locationtech.geogig.api.porcelain.LogOp) RevTree(org.locationtech.geogig.api.RevTree) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Aggregations

ObjectId (org.locationtech.geogig.api.ObjectId)361 Test (org.junit.Test)133 RevCommit (org.locationtech.geogig.api.RevCommit)109 NodeRef (org.locationtech.geogig.api.NodeRef)98 RevTree (org.locationtech.geogig.api.RevTree)91 RevObject (org.locationtech.geogig.api.RevObject)53 Ref (org.locationtech.geogig.api.Ref)46 Node (org.locationtech.geogig.api.Node)44 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)38 Feature (org.opengis.feature.Feature)35 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)34 LogOp (org.locationtech.geogig.api.porcelain.LogOp)28 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)27 LinkedList (java.util.LinkedList)26 ArrayList (java.util.ArrayList)25 RevFeature (org.locationtech.geogig.api.RevFeature)25 IOException (java.io.IOException)23 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)23 UpdateRef (org.locationtech.geogig.api.plumbing.UpdateRef)23 SymRef (org.locationtech.geogig.api.SymRef)22