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));
}
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());
}
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));
}
}
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());
}
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());
}
Aggregations