Package org.locationtech.geogig.api.plumbing.merge

Examples of org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport


        geogig.command(CheckoutOp.class).setSource("TestBranch").call();
        Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_1", new Integer(2000),
                "POINT(1 1)");
        insertAndAdd(points1ModifiedB);
        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());
        assertEquals(1, conflicts.getMerged().size());
        Feature pointsMerged = feature(pointsType, idP1, "StringProp1_2", new Integer(2000),
                "POINT(1 1)");
        assertEquals(pointsMerged, conflicts.getMerged().get(0).getFeature());
        Boolean hasConflictsOrAutomerge = geogig.command(CheckMergeScenarioOp.class)
                .setCommits(Lists.newArrayList(masterCommit, branchCommit)).call();
        assertTrue(hasConflictsOrAutomerge.booleanValue());

    }
View Full Code Here


        geogig.command(CheckoutOp.class).setSource("TestBranch").call();
        Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_2", new Integer(2000),
                "POINT(1 1)");
        insertAndAdd(points1ModifiedB);
        RevCommit branchCommit = geogig.command(CommitOp.class).call();
        MergeScenarioReport conflicts = geogig.command(ReportMergeScenarioOp.class)
                .setMergeIntoCommit(masterCommit).setToMergeCommit(branchCommit).call();
        assertEquals(0, conflicts.getConflicts().size());
        assertEquals(1, conflicts.getUnconflicted().size());
        Boolean hasConflictsOrAutomerge = geogig.command(CheckMergeScenarioOp.class)
                .setCommits(Lists.newArrayList(masterCommit, branchCommit)).call();
        assertTrue(hasConflictsOrAutomerge.booleanValue());
    }
View Full Code Here

        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());
    }
View Full Code Here

        insertAndAdd(points1Modified);
        RevCommit masterCommit = geogig.command(CommitOp.class).call();
        geogig.command(CheckoutOp.class).setSource("TestBranch").call();
        deleteAndAdd(points1);
        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());
    }
View Full Code Here

        // get changes
        Iterator<DiffEntry> diff = command(DiffTree.class).setOldTree(parentTreeId)
                .setNewTree(commitToApply.getTreeId()).setReportTrees(true).call();

        // see if there are conflicts
        MergeScenarioReport report = command(ReportCommitConflictsOp.class)
                .setCommit(commitToApply).call();
        if (report.getConflicts().isEmpty()) {
            // stage changes
            index().stage(getProgressListener(), diff, 0);
            // write new tree
            ObjectId newTreeId = command(WriteTree2.class).call();
            RevCommit newCommit = command(CommitOp.class).setCommit(commitToApply).call();

            repository.workingTree().updateWorkHead(newTreeId);
            repository.index().updateStageHead(newTreeId);

            getProgressListener().complete();

            return newCommit;
        } else {
            Iterator<DiffEntry> unconflicted = report.getUnconflicted().iterator();
            // stage changes
            index().stage(getProgressListener(), unconflicted, 0);
            workingTree().updateWorkHead(index().getTree().getId());

            command(UpdateRef.class).setName(Ref.CHERRY_PICK_HEAD).setNewValue(commit).call();
            command(UpdateRef.class).setName(Ref.ORIG_HEAD).setNewValue(headId).call();
            command(ConflictsWriteOp.class).setConflicts(report.getConflicts()).call();

            StringBuilder msg = new StringBuilder();
            msg.append("error: could not apply ");
            msg.append(commitToApply.getId().toString().substring(0, 7));
            msg.append(" " + commitToApply.getMessage());
            for (Conflict conflict : report.getConflicts()) {
                msg.append("\t" + conflict.getPath() + "\n");
            }

            StringBuilder sb = new StringBuilder();
            for (Conflict conflict : report.getConflicts()) {
                sb.append("CONFLICT: conflict in " + conflict.getPath() + "\n");
            }
            sb.append("Fix conflicts and then commit the result using 'geogig commit -c "
                    + commitToApply.getId().toString().substring(0, 7) + "\n");
            throw new IllegalStateException(sb.toString());
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.