@Test public void testMergeNoCommits() throws Exception { exception.expect(IllegalArgumentException.class); geogig.command(MergeOp.class).call(); }
@Test public void testMergeNoCommits() throws Exception { exception.expect(IllegalArgumentException.class); geogig.command(MergeOp.class).call(); }
@Test public void testMergeNullCommit() throws Exception { exception.expect(IllegalArgumentException.class); geogig.command(MergeOp.class).addCommit(ObjectId.NULL).call(); }
@Test public void testMergeNullCommit() throws Exception { exception.expect(IllegalArgumentException.class); geogig.command(MergeOp.class).addCommit(ObjectId.NULL).call(); }
public TestData mergeNoFF(String branchToMerge, String mergeCommitMessage) { ObjectId branchHead = getContext().command(RefParse.class).setName(branchToMerge).call() .get().getObjectId(); MergeReport report = getContext().command(MergeOp.class).setNoFastForward(true) .setMessage(mergeCommitMessage).addCommit(branchHead).call(); RevCommit mergeCommit = report.getMergeCommit(); checkState(mergeCommit.getParentIds().size() == 2); LOG.debug(mergeCommit.toString()); return this; }
public TestData mergeNoFF(String branchToMerge, String mergeCommitMessage) { ObjectId branchHead = getContext().command(RefParse.class).setName(branchToMerge).call() .get().getObjectId(); MergeReport report = getContext().command(MergeOp.class).setNoFastForward(true) .setMessage(mergeCommitMessage).addCommit(branchHead).call(); RevCommit mergeCommit = report.getMergeCommit(); checkState(mergeCommit.getParentIds().size() == 2); LOG.debug(mergeCommit.toString()); return this; }
@Given("^I have a merge conflict state$") public void I_have_a_merge_conflict_state() throws Throwable { I_have_conflicting_branches(); Ref branch = localRepo.geogigCLI.getGeogig(Hints.readOnly()).command(RefParse.class) .setName("branch1").call().get(); try { localRepo.geogigCLI.getGeogig(Hints.readWrite()).command(MergeOp.class) .addCommit(branch.getObjectId()).call(); fail(); } catch (MergeConflictsException e) { } }
@Given("^I have a merge conflict state$") public void I_have_a_merge_conflict_state() throws Throwable { I_have_conflicting_branches(); Ref branch = localRepo.geogigCLI.getGeogig(Hints.readOnly()).command(RefParse.class) .setName("branch1").call().get(); try { localRepo.geogigCLI.getGeogig(Hints.readWrite()).command(MergeOp.class) .addCommit(branch.getObjectId()).call(); fail(); } catch (MergeConflictsException e) { } }
@Given("^I have a merge conflict state$") public void I_have_a_merge_conflict_state() throws Throwable { I_have_conflicting_branches(); Ref branch = localRepo.geogigCLI.getGeogig(Hints.readOnly()).command(RefParse.class) .setName("branch1").call().get(); try { localRepo.geogigCLI.getGeogig(Hints.readWrite()).command(MergeOp.class) .addCommit(branch.getObjectId()).call(); fail(); } catch (MergeConflictsException e) { } }
@Test public void testMergeTwoBranchesWithNewFeatureType() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).call(); geogig.command(BranchCreateOp.class).setName("branch1").call(); insertAndAdd(lines1); geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("branch1").call(); insertAndAdd(poly1); RevCommit commit2 = geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("master").call(); geogig.command(MergeOp.class).addCommit(commit2.getId()).call(); Optional<NodeRef> ref = geogig.command(FindTreeChild.class).setChildPath(polyName).call(); assertTrue(ref.isPresent()); assertFalse(ref.get().getMetadataId().equals(ObjectId.NULL)); }
@Test public void testMergeTwoBranchesWithNewFeatureType() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).call(); geogig.command(BranchCreateOp.class).setName("branch1").call(); insertAndAdd(lines1); geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("branch1").call(); insertAndAdd(poly1); RevCommit commit2 = geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("master").call(); geogig.command(MergeOp.class).addCommit(commit2.getId()).call(); Optional<NodeRef> ref = geogig.command(FindTreeChild.class).setChildPath(polyName).call(); assertTrue(ref.isPresent()); assertFalse(ref.get().getMetadataId().equals(ObjectId.NULL)); }
@Test public void testOursAndTheirs() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).call(); geogig.command(BranchCreateOp.class).setName("TestBranch").call(); Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)"); insertAndAdd(points1Modified); geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("TestBranch").call(); Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(2000), "POINT(1 1)"); insertAndAdd(points1ModifiedB); geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("master").call(); Ref branch = geogig.command(RefParse.class).setName("TestBranch").call().get(); try { geogig.command(MergeOp.class).addCommit(branch.getObjectId()).setTheirs(true) .setOurs(true).call(); fail(); } catch (IllegalArgumentException e) { assertTrue(true); } }
@Test public void testOursAndTheirs() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).call(); geogig.command(BranchCreateOp.class).setName("TestBranch").call(); Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)"); insertAndAdd(points1Modified); geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("TestBranch").call(); Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(2000), "POINT(1 1)"); insertAndAdd(points1ModifiedB); geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("master").call(); Ref branch = geogig.command(RefParse.class).setName("TestBranch").call().get(); try { geogig.command(MergeOp.class).addCommit(branch.getObjectId()).setTheirs(true) .setOurs(true).call(); fail(); } catch (IllegalArgumentException e) { assertTrue(true); } }
private void createConflictedState() throws Exception { // Create the following revision graph // o // | // o - Points 1 added // |\ // | o - TestBranch - Points 1 modified and points 2 added // | // o - master - HEAD - Points 1 modifiedB insertAndAdd(points1); geogig.command(CommitOp.class).call(); geogig.command(BranchCreateOp.class).setName("TestBranch").call(); insertAndAdd(points1Modified); geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("TestBranch").call(); insertAndAdd(points1ModifiedB); insertAndAdd(points2); geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("master").call(); Ref branch = geogig.command(RefParse.class).setName("TestBranch").call().get(); try { geogig.command(MergeOp.class).addCommit(branch.getObjectId()).call(); fail(); } catch (MergeConflictsException e) { assertTrue(e.getMessage().contains("conflict")); } }
@Test public void testConflictIsolation() throws Exception { insertAndAdd(points2); geogig.command(CommitOp.class).setMessage("foo").call(); geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch1").call(); insertAndAdd(points1); RevCommit mainCommit = geogig.command(CommitOp.class).setMessage("Commit1").call(); geogig.command(CheckoutOp.class).setSource("master").call(); insertAndAdd(points1_modified); RevCommit modifiedCommit = geogig.command(CommitOp.class).setMessage("Commit2").call(); GeogigTransaction tx = geogig.command(TransactionBegin.class).call(); try { tx.command(MergeOp.class).addCommit(mainCommit.getId()).call(); fail("Expected a merge conflict!"); } catch (org.locationtech.geogig.porcelain.MergeConflictsException e) { // expected. } long txConflicts = tx.command(ConflictsCountOp.class).call().longValue(); long baseConflicts = geogig.command(ConflictsCountOp.class).call().longValue(); assertTrue("There should be no conflicts outside the transaction", baseConflicts == 0); assertTrue("There should be conflicts in the transaction", txConflicts > 0); }
@Test public void testConflictIsolation() throws Exception { insertAndAdd(points2); geogig.command(CommitOp.class).setMessage("foo").call(); geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch1").call(); insertAndAdd(points1); RevCommit mainCommit = geogig.command(CommitOp.class).setMessage("Commit1").call(); geogig.command(CheckoutOp.class).setSource("master").call(); insertAndAdd(points1_modified); RevCommit modifiedCommit = geogig.command(CommitOp.class).setMessage("Commit2").call(); assertNotNull(modifiedCommit); GeogigTransaction tx = geogig.command(TransactionBegin.class).call(); try { tx.command(MergeOp.class).addCommit(mainCommit.getId()).call(); fail("Expected a merge conflict!"); } catch (org.locationtech.geogig.porcelain.MergeConflictsException e) { // expected. } long txConflicts = tx.command(ConflictsCountOp.class).call().longValue(); long baseConflicts = geogig.command(ConflictsCountOp.class).call().longValue(); assertTrue("There should be no conflicts outside the transaction", baseConflicts == 0); assertTrue("There should be conflicts in the transaction", txConflicts > 0); }
@Test public void testMergeConflictingPolygon() throws Exception { String polyId = "polyId"; String polygonTypeSpec = "poly:Polygon:srid=4326"; SimpleFeatureType polygonType = DataUtilities.createType("http://geogig.polygon", "polygons", polygonTypeSpec); Feature polygonOriginal = feature(polygonType, polyId, "POLYGON((0 0,1 0,2 0,3 0,4 0,5 0,5 1,4 1,3 1,2 1,1 1,1 0,0 0))"); insertAndAdd(polygonOriginal); geogig.command(CommitOp.class).call(); geogig.command(BranchCreateOp.class).setName("TestBranch").call(); Feature polygonMaster = feature(polygonType, polyId, "POLYGON((0 0,1 0,2 0.2,3 0.2,4 0,5 0,5 1,4 1,3 1,2 1,1 1,1 0,0 0))"); insertAndAdd(polygonMaster); geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("TestBranch").call(); Feature polygonBranch = feature(polygonType, polyId, "POLYGON((0 0,1 0,2 0,3 0,4 0,5 0,5 1,4 1,3 0.8,2 0.8,1 1,1 0,0 0))"); insertAndAdd(polygonBranch); geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("master").call(); Ref branch = geogig.command(RefParse.class).setName("TestBranch").call().get(); exception.expect(MergeConflictsException.class); exception.expectMessage("Merge conflict in polygons/polyId"); geogig.command(MergeOp.class).addCommit(branch.getObjectId()).call(); }
@Test public void testMergeConflictingPolygon() throws Exception { String polyId = "polyId"; String polygonTypeSpec = "poly:Polygon:srid=4326"; SimpleFeatureType polygonType = DataUtilities.createType("http://geogig.polygon", "polygons", polygonTypeSpec); Feature polygonOriginal = feature(polygonType, polyId, "POLYGON((0 0,1 0,2 0,3 0,4 0,5 0,5 1,4 1,3 1,2 1,1 1,1 0,0 0))"); insertAndAdd(polygonOriginal); geogig.command(CommitOp.class).call(); geogig.command(BranchCreateOp.class).setName("TestBranch").call(); Feature polygonMaster = feature(polygonType, polyId, "POLYGON((0 0,1 0,2 0.2,3 0.2,4 0,5 0,5 1,4 1,3 1,2 1,1 1,1 0,0 0))"); insertAndAdd(polygonMaster); geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("TestBranch").call(); Feature polygonBranch = feature(polygonType, polyId, "POLYGON((0 0,1 0,2 0,3 0,4 0,5 0,5 1,4 1,3 0.8,2 0.8,1 1,1 0,0 0))"); insertAndAdd(polygonBranch); geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("master").call(); Ref branch = geogig.command(RefParse.class).setName("TestBranch").call().get(); exception.expect(MergeConflictsException.class); exception.expectMessage("Merge conflict in polygons/polyId"); geogig.command(MergeOp.class).addCommit(branch.getObjectId()).call(); }
@Test public void testBothBranchesSameGeometryChange() throws Exception { String ancestorLine = "LINESTRING (-75.1195282 38.7801263, -75.1195626 38.7806208, -75.1195701 38.780762, -75.1195916 38.7816402, -75.1195154 38.7820072)"; String leftLine = "LINESTRING (-75.1195282 38.7801263, -75.1195626 38.7806208, -75.1195645 38.7807768, -75.1195916 38.7816402, -75.1195841 38.7817429, -75.1195702 38.7818159, -75.1195333 38.7819121, -75.119487 38.7819971)"; String rightLine = "LINESTRING (-75.1195282 38.7801263, -75.1195626 38.7806208, -75.1195645 38.7807768, -75.1195916 38.7816402, -75.1195841 38.7817429, -75.1195702 38.7818159, -75.1195333 38.7819121, -75.119487 38.7819971)"; final String fid = "112233"; final Feature ancestor = super.feature(linesType, fid, "secondary", 1, ancestorLine); final Feature left = super.feature(linesType, fid, "secondary", 1, leftLine); final Feature right = super.feature(linesType, fid, "primary", 1, rightLine); super.insertAndAdd(ancestor); super.commit("common ancestor"); geogig.command(BranchCreateOp.class).setName("branch").call(); super.insertAndAdd(left); super.commit("master change"); assertEquals("branch", geogig.command(CheckoutOp.class).setSource("branch").call() .getNewRef().localName()); super.insertAndAdd(right); final RevCommit branchCommit = super.commit("branch change"); geogig.command(CheckoutOp.class).setSource("master").call(); geogig.command(MergeOp.class).addCommit(branchCommit.getId()).call(); }
@Test public void testBothBranchesSameGeometryChange() throws Exception { String ancestorLine = "LINESTRING (-75.1195282 38.7801263, -75.1195626 38.7806208, -75.1195701 38.780762, -75.1195916 38.7816402, -75.1195154 38.7820072)"; String leftLine = "LINESTRING (-75.1195282 38.7801263, -75.1195626 38.7806208, -75.1195645 38.7807768, -75.1195916 38.7816402, -75.1195841 38.7817429, -75.1195702 38.7818159, -75.1195333 38.7819121, -75.119487 38.7819971)"; String rightLine = "LINESTRING (-75.1195282 38.7801263, -75.1195626 38.7806208, -75.1195645 38.7807768, -75.1195916 38.7816402, -75.1195841 38.7817429, -75.1195702 38.7818159, -75.1195333 38.7819121, -75.119487 38.7819971)"; final String fid = "112233"; final Feature ancestor = super.feature(linesType, fid, "secondary", 1, ancestorLine); final Feature left = super.feature(linesType, fid, "secondary", 1, leftLine); final Feature right = super.feature(linesType, fid, "primary", 1, rightLine); super.insertAndAdd(ancestor); super.commit("common ancestor"); geogig.command(BranchCreateOp.class).setName("branch").call(); super.insertAndAdd(left); super.commit("master change"); assertEquals("branch", geogig.command(CheckoutOp.class).setSource("branch").call() .getNewRef().localName()); super.insertAndAdd(right); final RevCommit branchCommit = super.commit("branch change"); geogig.command(CheckoutOp.class).setSource("master").call(); geogig.command(MergeOp.class).addCommit(branchCommit.getId()).call(); }