Search in sources :

Example 1 with MergeScenarioReport

use of org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport in project GeoGig by boundlessgeo.

the class EndTransaction method run.

/**
     * Runs the command and builds the appropriate response.
     * 
     * @param context - the context to use for this command
     * 
     * @throws CommandSpecException
     */
@Override
public void run(CommandContext context) {
    if (this.getTransactionId() == null) {
        throw new CommandSpecException("There isn't a transaction to end.");
    }
    final Context transaction = this.getCommandLocator(context);
    TransactionEnd endTransaction = context.getGeoGIG().command(TransactionEnd.class);
    try {
        final boolean closed = endTransaction.setCancel(cancel).setTransaction((GeogigTransaction) transaction).call();
        context.setResponseContent(new CommandResponse() {

            @Override
            public void write(ResponseWriter out) throws Exception {
                out.start();
                if (closed) {
                    out.writeTransactionId(null);
                } else {
                    out.writeTransactionId(getTransactionId());
                }
                out.finish();
            }
        });
    } catch (MergeConflictsException m) {
        final RevCommit ours = context.getGeoGIG().getRepository().getCommit(m.getOurs());
        final RevCommit theirs = context.getGeoGIG().getRepository().getCommit(m.getTheirs());
        final Optional<ObjectId> ancestor = transaction.command(FindCommonAncestor.class).setLeft(ours).setRight(theirs).call();
        context.setResponseContent(new CommandResponse() {

            final MergeScenarioReport report = transaction.command(ReportMergeScenarioOp.class).setMergeIntoCommit(ours).setToMergeCommit(theirs).call();

            @Override
            public void write(ResponseWriter out) throws Exception {
                out.start();
                Optional<RevCommit> mergeCommit = Optional.absent();
                out.writeMergeResponse(mergeCommit, report, transaction, ours.getId(), theirs.getId(), ancestor.get());
                out.finish();
            }
        });
    } catch (RebaseConflictsException r) {
    // TODO: Handle rebase exception
    }
}
Also used : Context(org.locationtech.geogig.api.Context) CommandContext(org.locationtech.geogig.web.api.CommandContext) GeogigTransaction(org.locationtech.geogig.api.GeogigTransaction) Optional(com.google.common.base.Optional) RebaseConflictsException(org.locationtech.geogig.api.porcelain.RebaseConflictsException) CommandResponse(org.locationtech.geogig.web.api.CommandResponse) MergeScenarioReport(org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport) MergeConflictsException(org.locationtech.geogig.api.porcelain.MergeConflictsException) RebaseConflictsException(org.locationtech.geogig.api.porcelain.RebaseConflictsException) CommandSpecException(org.locationtech.geogig.web.api.CommandSpecException) MergeConflictsException(org.locationtech.geogig.api.porcelain.MergeConflictsException) ResponseWriter(org.locationtech.geogig.web.api.ResponseWriter) CommandSpecException(org.locationtech.geogig.web.api.CommandSpecException) TransactionEnd(org.locationtech.geogig.api.plumbing.TransactionEnd) RevCommit(org.locationtech.geogig.api.RevCommit)

Example 2 with MergeScenarioReport

use of org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport in project GeoGig by boundlessgeo.

the class ReportMergeConflictsOpTest method testRemovedTreeOnlyInOneBranch.

@Test
public void testRemovedTreeOnlyInOneBranch() throws Exception {
    insertAndAdd(points1);
    geogig.command(CommitOp.class).call();
    geogig.command(BranchCreateOp.class).setName("TestBranch").call();
    insertAndAdd(points2);
    RevCommit masterCommit = geogig.command(CommitOp.class).call();
    geogig.command(CheckoutOp.class).setSource("TestBranch").call();
    geogig.command(RemoveOp.class).addPathToRemove(pointsName).call();
    geogig.command(AddOp.class).call();
    RevCommit branchCommit = geogig.command(CommitOp.class).call();
    MergeScenarioReport conflicts = geogig.command(ReportMergeScenarioOp.class).setMergeIntoCommit(masterCommit).setToMergeCommit(branchCommit).call();
    assertEquals(1, conflicts.getConflicts().size());
    assertEquals(1, conflicts.getUnconflicted().size());
    Boolean hasConflicts = geogig.command(CheckMergeScenarioOp.class).setCommits(Lists.newArrayList(masterCommit, branchCommit)).call();
    assertTrue(hasConflicts.booleanValue());
}
Also used : AddOp(org.locationtech.geogig.api.porcelain.AddOp) ReportMergeScenarioOp(org.locationtech.geogig.api.plumbing.merge.ReportMergeScenarioOp) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) MergeScenarioReport(org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 3 with MergeScenarioReport

use of org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport in project GeoGig by boundlessgeo.

the class ReportMergeConflictsOpTest method testModifiedFeatureTypeInOneBranch.

@Test
public void testModifiedFeatureTypeInOneBranch() throws Exception {
    insertAndAdd(points1);
    geogig.command(CommitOp.class).call();
    geogig.command(BranchCreateOp.class).setName("TestBranch").call();
    insertAndAdd(points3);
    RevCommit masterCommit = geogig.command(CommitOp.class).call();
    geogig.command(CheckoutOp.class).setSource("TestBranch").call();
    insert(points1B);
    insert(points2);
    geogig.command(AddOp.class).call();
    RevCommit branchCommit = geogig.command(CommitOp.class).call();
    MergeScenarioReport conflicts = geogig.command(ReportMergeScenarioOp.class).setMergeIntoCommit(masterCommit).setToMergeCommit(branchCommit).call();
    assertEquals(0, conflicts.getConflicts().size());
    assertEquals(2, conflicts.getUnconflicted().size());
    Boolean hasConflicts = geogig.command(CheckMergeScenarioOp.class).setCommits(Lists.newArrayList(masterCommit, branchCommit)).call();
    assertFalse(hasConflicts.booleanValue());
}
Also used : AddOp(org.locationtech.geogig.api.porcelain.AddOp) ReportMergeScenarioOp(org.locationtech.geogig.api.plumbing.merge.ReportMergeScenarioOp) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) MergeScenarioReport(org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 4 with MergeScenarioReport

use of org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport in project GeoGig by boundlessgeo.

the class ReportMergeConflictsOpTest method testAddedSameFeatureType.

@Test
public void testAddedSameFeatureType() throws Exception {
    insertAndAdd(lines1);
    geogig.command(CommitOp.class).call();
    geogig.command(BranchCreateOp.class).setName("TestBranch").call();
    insert(points2);
    delete(points2);
    geogig.command(AddOp.class).call();
    RevCommit masterCommit = geogig.command(CommitOp.class).call();
    geogig.command(CheckoutOp.class).setSource("TestBranch").call();
    insert(points2);
    delete(points2);
    geogig.command(AddOp.class).call();
    RevCommit branchCommit = geogig.command(CommitOp.class).call();
    MergeScenarioReport conflicts = geogig.command(ReportMergeScenarioOp.class).setMergeIntoCommit(masterCommit).setToMergeCommit(branchCommit).call();
    assertEquals(0, conflicts.getConflicts().size());
    assertEquals(0, conflicts.getUnconflicted().size());
    Boolean hasConflicts = geogig.command(CheckMergeScenarioOp.class).setCommits(Lists.newArrayList(masterCommit, branchCommit)).call();
    assertFalse(hasConflicts.booleanValue());
}
Also used : AddOp(org.locationtech.geogig.api.porcelain.AddOp) ReportMergeScenarioOp(org.locationtech.geogig.api.plumbing.merge.ReportMergeScenarioOp) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) MergeScenarioReport(org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 5 with MergeScenarioReport

use of org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport in project GeoGig by boundlessgeo.

the class ReportMergeConflictsOpTest method testModifiedSameFeatureIncompatible.

@Test
public void testModifiedSameFeatureIncompatible() 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);
    RevCommit masterCommit = geogig.command(CommitOp.class).call();
    geogig.command(CheckoutOp.class).setSource("TestBranch").call();
    Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(1000), "POINT(1 1)");
    insertAndAdd(points1ModifiedB);
    RevCommit branchCommit = geogig.command(CommitOp.class).call();
    MergeScenarioReport conflicts = geogig.command(ReportMergeScenarioOp.class).setMergeIntoCommit(masterCommit).setToMergeCommit(branchCommit).call();
    assertEquals(1, conflicts.getConflicts().size());
    assertEquals(0, conflicts.getUnconflicted().size());
    Boolean hasConflicts = geogig.command(CheckMergeScenarioOp.class).setCommits(Lists.newArrayList(masterCommit, branchCommit)).call();
    assertTrue(hasConflicts.booleanValue());
}
Also used : ReportMergeScenarioOp(org.locationtech.geogig.api.plumbing.merge.ReportMergeScenarioOp) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) MergeScenarioReport(org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport) Feature(org.opengis.feature.Feature) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Aggregations

RevCommit (org.locationtech.geogig.api.RevCommit)30 MergeScenarioReport (org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport)30 Test (org.junit.Test)23 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)23 ReportMergeScenarioOp (org.locationtech.geogig.api.plumbing.merge.ReportMergeScenarioOp)14 Feature (org.opengis.feature.Feature)9 AddOp (org.locationtech.geogig.api.porcelain.AddOp)8 ObjectId (org.locationtech.geogig.api.ObjectId)5 Optional (com.google.common.base.Optional)4 Ref (org.locationtech.geogig.api.Ref)4 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)4 CommandResponse (org.locationtech.geogig.web.api.CommandResponse)4 ResponseWriter (org.locationtech.geogig.web.api.ResponseWriter)4 Context (org.locationtech.geogig.api.Context)3 SymRef (org.locationtech.geogig.api.SymRef)3 UpdateRef (org.locationtech.geogig.api.plumbing.UpdateRef)3 Conflict (org.locationtech.geogig.api.plumbing.merge.Conflict)3 CommandContext (org.locationtech.geogig.web.api.CommandContext)3 CommandSpecException (org.locationtech.geogig.web.api.CommandSpecException)3 CommitBuilder (org.locationtech.geogig.api.CommitBuilder)2