use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class MergeOpTest method testMerge.
@Test
public void testMerge() throws Exception {
// Create the following revision graph
// o
// |
// o - Points 1 added
// |\
// | o - branch1 - Points 2 added
// |
// o - Points 3 added
// |
// o - master - HEAD - Lines 1 added
insertAndAdd(points1);
final RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
// create branch1 and checkout
geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch1").call();
insertAndAdd(points2);
final RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
// checkout master
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();
// Merge branch1 into master to create the following revision graph
// o
// |
// o - Points 1 added
// |\
// | o - branch1 - Points 2 added
// | |
// o | - Points 3 added
// | |
// o | - Lines 1 added
// |/
// o - master - HEAD - Merge commit
Ref branch1 = geogig.command(RefParse.class).setName("branch1").call().get();
MergeReport mergeReport = geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(branch1.getObjectId())).setMessage("My merge message.").call();
RevTree mergedTree = repo.getTree(mergeReport.getMergeCommit().getTreeId());
String path = appendChild(pointsName, points2.getIdentifier().getID());
assertTrue(repo.command(FindTreeChild.class).setParent(mergedTree).setChildPath(path).call().isPresent());
path = appendChild(pointsName, points1.getIdentifier().getID());
assertTrue(repo.command(FindTreeChild.class).setParent(mergedTree).setChildPath(path).call().isPresent());
path = appendChild(pointsName, points3.getIdentifier().getID());
assertTrue(repo.command(FindTreeChild.class).setParent(mergedTree).setChildPath(path).call().isPresent());
path = appendChild(linesName, lines1.getIdentifier().getID());
assertTrue(repo.command(FindTreeChild.class).setParent(mergedTree).setChildPath(path).call().isPresent());
Iterator<RevCommit> log = geogig.command(LogOp.class).call();
// Merge Commit
RevCommit logCmerge = log.next();
assertEquals("My merge message.", logCmerge.getMessage());
assertEquals(2, logCmerge.getParentIds().size());
assertEquals(c4.getId(), logCmerge.getParentIds().get(0));
assertEquals(c2.getId(), logCmerge.getParentIds().get(1));
// Commit 4
RevCommit logC4 = log.next();
assertEquals(c4.getAuthor(), logC4.getAuthor());
assertEquals(c4.getCommitter(), logC4.getCommitter());
assertEquals(c4.getMessage(), logC4.getMessage());
assertEquals(c4.getTreeId(), logC4.getTreeId());
// Commit 3
RevCommit logC3 = log.next();
assertEquals(c3.getAuthor(), logC3.getAuthor());
assertEquals(c3.getCommitter(), logC3.getCommitter());
assertEquals(c3.getMessage(), logC3.getMessage());
assertEquals(c3.getTreeId(), logC3.getTreeId());
// Commit 2
RevCommit logC2 = log.next();
assertEquals(c2.getAuthor(), logC2.getAuthor());
assertEquals(c2.getCommitter(), logC2.getCommitter());
assertEquals(c2.getMessage(), logC2.getMessage());
assertEquals(c2.getTreeId(), logC2.getTreeId());
// Commit 1
RevCommit logC1 = log.next();
assertEquals(c1.getAuthor(), logC1.getAuthor());
assertEquals(c1.getCommitter(), logC1.getCommitter());
assertEquals(c1.getMessage(), logC1.getMessage());
assertEquals(c1.getTreeId(), logC1.getTreeId());
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class MergeOpTest method testMergeFastForward.
@Test
public void testMergeFastForward() throws Exception {
// Create the following revision graph
// o
// |
// o - master - HEAD - Points 1 added
// .\
// . o - branch1 - Points 2 added
insertAndAdd(points1);
final RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
// create branch1 and checkout
geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch1").call();
insertAndAdd(points2);
final RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
// checkout master
geogig.command(CheckoutOp.class).setSource("master").call();
// Merge branch1 into master to create the following revision graph
// o
// |
// o - Points 1 added
// |
// o - master - HEAD - branch1 - Points 2 added
Ref branch1 = geogig.command(RefParse.class).setName("branch1").call().get();
final MergeReport mergeReport = geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(branch1.getObjectId())).call();
RevTree mergedTree = repo.getTree(mergeReport.getMergeCommit().getTreeId());
String path = appendChild(pointsName, points1.getIdentifier().getID());
assertTrue(repo.command(FindTreeChild.class).setParent(mergedTree).setChildPath(path).call().isPresent());
path = appendChild(pointsName, points2.getIdentifier().getID());
assertTrue(repo.command(FindTreeChild.class).setParent(mergedTree).setChildPath(path).call().isPresent());
Iterator<RevCommit> log = geogig.command(LogOp.class).call();
// Commit 2
RevCommit logC2 = log.next();
assertEquals(c2.getAuthor(), logC2.getAuthor());
assertEquals(c2.getCommitter(), logC2.getCommitter());
assertEquals(c2.getMessage(), logC2.getMessage());
assertEquals(c2.getTreeId(), logC2.getTreeId());
// Commit 1
RevCommit logC1 = log.next();
assertEquals(c1.getAuthor(), logC1.getAuthor());
assertEquals(c1.getCommitter(), logC1.getCommitter());
assertEquals(c1.getMessage(), logC1.getMessage());
assertEquals(c1.getTreeId(), logC1.getTreeId());
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class OSMExportSLTest method testExportWithMapping.
@Test
public void testExportWithMapping() throws Exception {
String filename = OSMImportOp.class.getResource("ways.xml").getFile();
File file = new File(filename);
cli.execute("osm", "import", file.getAbsolutePath());
cli.execute("add");
cli.execute("commit", "-m", "message");
Optional<RevTree> tree = cli.getGeogig().command(RevObjectParse.class).setRefSpec("HEAD:node").call(RevTree.class);
assertTrue(tree.isPresent());
assertTrue(tree.get().size() > 0);
tree = cli.getGeogig().command(RevObjectParse.class).setRefSpec("HEAD:way").call(RevTree.class);
assertTrue(tree.isPresent());
assertTrue(tree.get().size() > 0);
String mappingFilename = OSMMap.class.getResource("mapping.json").getFile();
File mappingFile = new File(mappingFilename);
File exportFile = new File(tempFolder.getRoot(), "export.sqlite");
cli.execute("osm", "export-sl", "--database", exportFile.getAbsolutePath(), "--mapping", mappingFile.getAbsolutePath());
assertTrue(exportFile.exists());
cli.execute("sl", "import", "-t", "onewaystreets", "--database", exportFile.getAbsolutePath());
long unstaged = cli.getGeogig().getRepository().workingTree().countUnstaged("onewaystreets").count();
assertTrue(unstaged > 0);
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class OSMExportShpTest method testExportToShapefileWithMappingWithoutGeometry.
@Test
public void testExportToShapefileWithMappingWithoutGeometry() throws Exception {
String filename = OSMImportOp.class.getResource("ways.xml").getFile();
File file = new File(filename);
cli.execute("osm", "import", file.getAbsolutePath());
cli.execute("add");
cli.execute("commit", "-m", "message");
Optional<RevTree> tree = cli.getGeogig().command(RevObjectParse.class).setRefSpec("HEAD:node").call(RevTree.class);
assertTrue(tree.isPresent());
assertTrue(tree.get().size() > 0);
tree = cli.getGeogig().command(RevObjectParse.class).setRefSpec("HEAD:way").call(RevTree.class);
assertTrue(tree.isPresent());
assertTrue(tree.get().size() > 0);
String mappingFilename = OSMMap.class.getResource("no_geometry_mapping.json").getFile();
File mappingFile = new File(mappingFilename);
File exportFile = new File(tempFolder.getRoot(), "export.shp");
cli.execute("osm", "export-shp", exportFile.getAbsolutePath(), "--mapping", mappingFile.getAbsolutePath());
assertNotNull(cli.exception);
assertTrue(cli.exception.getMessage().startsWith("The mapping rule does not define a geometry field"));
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class OSMExportShpTest method testExportToShapefileWithMapping.
@Test
public void testExportToShapefileWithMapping() throws Exception {
String filename = OSMImportOp.class.getResource("ways.xml").getFile();
File file = new File(filename);
cli.execute("osm", "import", file.getAbsolutePath());
cli.execute("add");
cli.execute("commit", "-m", "message");
Optional<RevTree> tree = cli.getGeogig().command(RevObjectParse.class).setRefSpec("HEAD:node").call(RevTree.class);
assertTrue(tree.isPresent());
assertTrue(tree.get().size() > 0);
tree = cli.getGeogig().command(RevObjectParse.class).setRefSpec("HEAD:way").call(RevTree.class);
assertTrue(tree.isPresent());
assertTrue(tree.get().size() > 0);
String mappingFilename = OSMMap.class.getResource("mapping.json").getFile();
File mappingFile = new File(mappingFilename);
File exportFile = new File(tempFolder.getRoot(), "export.shp");
cli.execute("osm", "export-shp", exportFile.getAbsolutePath(), "--mapping", mappingFile.getAbsolutePath());
assertTrue(exportFile.exists());
cli.execute("shp", "import", "-d", "mapped", exportFile.getAbsolutePath());
long unstaged = cli.getGeogig().getRepository().workingTree().countUnstaged("mapped").count();
assertTrue(unstaged > 0);
}
Aggregations