Search in sources :

Example 6 with MergeConflictsException

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

the class AddOpTest method testAdditionFixesConflict.

@Test
public void testAdditionFixesConflict() throws Exception {
    Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)");
    Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(2000), "POINT(1 1)");
    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(Suppliers.ofInstance(branch.getObjectId())).call();
        fail();
    } catch (MergeConflictsException e) {
        assertTrue(true);
    }
    geogig.command(AddOp.class).call();
    List<Conflict> conflicts = geogig.getRepository().stagingDatabase().getConflicts(null, null);
    assertTrue(conflicts.isEmpty());
    geogig.command(CommitOp.class).call();
    Optional<Ref> ref = geogig.command(RefParse.class).setName(Ref.MERGE_HEAD).call();
    assertFalse(ref.isPresent());
}
Also used : AddOp(org.locationtech.geogig.api.porcelain.AddOp) Ref(org.locationtech.geogig.api.Ref) NodeRef(org.locationtech.geogig.api.NodeRef) MergeConflictsException(org.locationtech.geogig.api.porcelain.MergeConflictsException) Conflict(org.locationtech.geogig.api.plumbing.merge.Conflict) RefParse(org.locationtech.geogig.api.plumbing.RefParse) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) Feature(org.opengis.feature.Feature) Test(org.junit.Test)

Example 7 with MergeConflictsException

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

the class ResetOpTest method testResetPathToHeadVersionFixesConflict.

@Test
public void testResetPathToHeadVersionFixesConflict() throws Exception {
    Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)");
    Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(2000), "POINT(1 1)");
    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(Suppliers.ofInstance(branch.getObjectId())).call();
        fail();
    } catch (MergeConflictsException e) {
        assertTrue(e.getMessage().contains("conflict"));
    }
    geogig.command(ResetOp.class).addPattern(pointsName + "/" + idP1).call();
    List<Conflict> conflicts = geogig.getRepository().stagingDatabase().getConflicts(null, null);
    assertTrue(conflicts.isEmpty());
}
Also used : Ref(org.locationtech.geogig.api.Ref) MergeConflictsException(org.locationtech.geogig.api.porcelain.MergeConflictsException) Conflict(org.locationtech.geogig.api.plumbing.merge.Conflict) RefParse(org.locationtech.geogig.api.plumbing.RefParse) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) Feature(org.opengis.feature.Feature) Test(org.junit.Test)

Example 8 with MergeConflictsException

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

the class ResetOpTest method testResetPathFixesConflict.

@Test
public void testResetPathFixesConflict() throws Exception {
    Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)");
    Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(2000), "POINT(1 1)");
    insertAndAdd(points1);
    RevCommit resetCommit = 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(Suppliers.ofInstance(branch.getObjectId())).call();
        fail();
    } catch (MergeConflictsException e) {
        assertTrue(e.getMessage().contains("conflict"));
    }
    geogig.command(ResetOp.class).addPattern(pointsName + "/" + idP1).setCommit(Suppliers.ofInstance(resetCommit.getId())).call();
    List<Conflict> conflicts = geogig.getRepository().stagingDatabase().getConflicts(null, null);
    assertTrue(conflicts.isEmpty());
}
Also used : Ref(org.locationtech.geogig.api.Ref) MergeConflictsException(org.locationtech.geogig.api.porcelain.MergeConflictsException) Conflict(org.locationtech.geogig.api.plumbing.merge.Conflict) RefParse(org.locationtech.geogig.api.plumbing.RefParse) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) ResetOp(org.locationtech.geogig.api.porcelain.ResetOp) Feature(org.opengis.feature.Feature) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 9 with MergeConflictsException

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

the class AddOpTest method testInsertionAndAdditionFixesConflict.

@Test
public void testInsertionAndAdditionFixesConflict() throws Exception {
    Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)");
    Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(2000), "POINT(1 1)");
    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(Suppliers.ofInstance(branch.getObjectId())).call();
        fail();
    } catch (MergeConflictsException e) {
        assertTrue(e.getMessage().contains("conflict"));
    }
    insert(points1);
    geogig.command(AddOp.class).call();
    List<Conflict> conflicts = geogig.getRepository().stagingDatabase().getConflicts(null, null);
    assertTrue(conflicts.isEmpty());
    geogig.command(CommitOp.class).call();
    Optional<Ref> ref = geogig.command(RefParse.class).setName(Ref.MERGE_HEAD).call();
    assertFalse(ref.isPresent());
}
Also used : AddOp(org.locationtech.geogig.api.porcelain.AddOp) Ref(org.locationtech.geogig.api.Ref) NodeRef(org.locationtech.geogig.api.NodeRef) MergeConflictsException(org.locationtech.geogig.api.porcelain.MergeConflictsException) Conflict(org.locationtech.geogig.api.plumbing.merge.Conflict) RefParse(org.locationtech.geogig.api.plumbing.RefParse) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) Feature(org.opengis.feature.Feature) Test(org.junit.Test)

Example 10 with MergeConflictsException

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

the class ResetOpTest method testResetFixesConflict.

@Test
public void testResetFixesConflict() throws Exception {
    Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)");
    Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(2000), "POINT(1 1)");
    insertAndAdd(points1);
    RevCommit resetCommit = 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(Suppliers.ofInstance(branch.getObjectId())).call();
        fail();
    } catch (MergeConflictsException e) {
        assertTrue(e.getMessage().contains("conflict"));
    }
    geogig.command(ResetOp.class).setMode(ResetMode.HARD).setCommit(Suppliers.ofInstance(resetCommit.getId())).call();
    List<Conflict> conflicts = geogig.getRepository().stagingDatabase().getConflicts(null, null);
    assertTrue(conflicts.isEmpty());
    Optional<Ref> ref = geogig.command(RefParse.class).setName(Ref.MERGE_HEAD).call();
    assertFalse(ref.isPresent());
}
Also used : Ref(org.locationtech.geogig.api.Ref) MergeConflictsException(org.locationtech.geogig.api.porcelain.MergeConflictsException) Conflict(org.locationtech.geogig.api.plumbing.merge.Conflict) RefParse(org.locationtech.geogig.api.plumbing.RefParse) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) ResetOp(org.locationtech.geogig.api.porcelain.ResetOp) Feature(org.opengis.feature.Feature) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Aggregations

MergeConflictsException (org.locationtech.geogig.api.porcelain.MergeConflictsException)14 RefParse (org.locationtech.geogig.api.plumbing.RefParse)13 Ref (org.locationtech.geogig.api.Ref)12 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)11 NodeRef (org.locationtech.geogig.api.NodeRef)9 Test (org.junit.Test)8 Feature (org.opengis.feature.Feature)8 Conflict (org.locationtech.geogig.api.plumbing.merge.Conflict)7 RevCommit (org.locationtech.geogig.api.RevCommit)5 SymRef (org.locationtech.geogig.api.SymRef)4 UpdateRef (org.locationtech.geogig.api.plumbing.UpdateRef)3 AddOp (org.locationtech.geogig.api.porcelain.AddOp)3 Optional (com.google.common.base.Optional)2 Context (org.locationtech.geogig.api.Context)2 RevFeature (org.locationtech.geogig.api.RevFeature)2 UpdateSymRef (org.locationtech.geogig.api.plumbing.UpdateSymRef)2 MergeScenarioReport (org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport)2 PullOp (org.locationtech.geogig.api.porcelain.PullOp)2 ResetOp (org.locationtech.geogig.api.porcelain.ResetOp)2 CommandContext (org.locationtech.geogig.web.api.CommandContext)2