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

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


            // 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();

                long timestamp = platform.currentTimeMillis();
                // Create new commit
                CommitBuilder builder = new CommitBuilder(commitToApply);
                builder.setParentIds(Arrays.asList(rebaseHead));
                builder.setTreeId(newTreeId);
                builder.setCommitterTimestamp(timestamp);
                builder.setCommitterTimeZoneOffset(platform.timeZoneOffset(timestamp));

                RevCommit newCommit = builder.build();
                repository.objectDatabase().put(newCommit);

                rebaseHead = newCommit.getId();

                command(UpdateRef.class).setName(currentBranch).setNewValue(rebaseHead).call();
                command(UpdateSymRef.class).setName(Ref.HEAD).setNewValue(currentBranch).call();

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

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

                // mark conflicted elements
                command(ConflictsWriteOp.class).setConflicts(report.getConflicts()).call();

                // created exception message
                StringBuilder msg = new StringBuilder();
                msg.append("error: could not apply ");
                msg.append(commitToApply.getId().toString().substring(0, 7));
                msg.append(" " + commitToApply.getMessage() + "\n");

                for (Conflict conflict : report.getConflicts()) {
                    msg.append("CONFLICT: conflict in " + conflict.getPath() + "\n");
                }

                File branchFile = new File(getRebaseFolder(), "branch");
                try {
View Full Code Here


        Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_1", new Integer(2000),
                "POINT(1 1)");
        insertAndAdd(points1ModifiedB);
        RevCommit branchCommit = geogig.command(CommitOp.class).call();
        geogig.command(CheckoutOp.class).setSource("master").call();
        MergeScenarioReport conflicts = geogig.command(ReportCommitConflictsOp.class)
                .setCommit(branchCommit).call();
        assertEquals(0, conflicts.getConflicts().size());
        assertEquals(1, conflicts.getUnconflicted().size());
    }
View Full Code Here

        Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000),
                "POINT(1 1)");
        insertAndAdd(points1Modified);
        RevCommit branchCommit = geogig.command(CommitOp.class).call();
        geogig.command(CheckoutOp.class).setSource("master").call();
        MergeScenarioReport conflicts = geogig.command(ReportCommitConflictsOp.class)
                .setCommit(branchCommit).call();
        assertEquals(0, conflicts.getConflicts().size());
        assertEquals(1, conflicts.getUnconflicted().size());
    }
View Full Code Here

        Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_2", new Integer(2000),
                "POINT(1 1)");
        insertAndAdd(points1ModifiedB);
        RevCommit branchCommit = geogig.command(CommitOp.class).call();
        geogig.command(CheckoutOp.class).setSource("master").call();
        MergeScenarioReport conflicts = geogig.command(ReportCommitConflictsOp.class)
                .setCommit(branchCommit).call();
        assertEquals(0, conflicts.getConflicts().size());
        assertEquals(1, conflicts.getUnconflicted().size());
    }
View Full Code Here

        Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(1000),
                "POINT(1 1)");
        insertAndAdd(points1ModifiedB);
        RevCommit branchCommit = geogig.command(CommitOp.class).call();
        geogig.command(CheckoutOp.class).setSource("master").call();
        MergeScenarioReport conflicts = geogig.command(ReportCommitConflictsOp.class)
                .setCommit(branchCommit).call();
        assertEquals(1, conflicts.getConflicts().size());
        assertEquals(0, conflicts.getUnconflicted().size());
    }
View Full Code Here

        geogig.command(CommitOp.class).call();
        geogig.command(CheckoutOp.class).setSource("TestBranch").call();
        deleteAndAdd(points1);
        RevCommit branchCommit = geogig.command(CommitOp.class).call();
        geogig.command(CheckoutOp.class).setSource("master").call();
        MergeScenarioReport conflicts = geogig.command(ReportCommitConflictsOp.class)
                .setCommit(branchCommit).call();
        assertEquals(1, conflicts.getConflicts().size());
        assertEquals(0, conflicts.getUnconflicted().size());
    }
View Full Code Here

        geogig.command(CommitOp.class).call();
        geogig.command(CheckoutOp.class).setSource("TestBranch").call();
        insertAndAdd(points3);
        RevCommit branchCommit = geogig.command(CommitOp.class).call();
        geogig.command(CheckoutOp.class).setSource("master").call();
        MergeScenarioReport conflicts = geogig.command(ReportCommitConflictsOp.class)
                .setCommit(branchCommit).call();
        assertEquals(0, conflicts.getConflicts().size());
        assertEquals(1, conflicts.getUnconflicted().size());
    }
View Full Code Here

        insert(points2);
        delete(points2);
        geogig.command(AddOp.class).call();
        RevCommit branchCommit = geogig.command(CommitOp.class).call();
        geogig.command(CheckoutOp.class).setSource("master").call();
        MergeScenarioReport conflicts = geogig.command(ReportCommitConflictsOp.class)
                .setCommit(branchCommit).call();
        assertEquals(0, conflicts.getConflicts().size());
        assertEquals(0, conflicts.getUnconflicted().size());
    }
View Full Code Here

        insert(points1B);
        delete(points1B);
        geogig.command(AddOp.class).call();
        RevCommit branchCommit = geogig.command(CommitOp.class).call();
        geogig.command(CheckoutOp.class).setSource("master").call();
        MergeScenarioReport conflicts = geogig.command(ReportCommitConflictsOp.class)
                .setCommit(branchCommit).call();
        assertEquals(1, conflicts.getConflicts().size());
        assertEquals(0, conflicts.getUnconflicted().size());
    }
View Full Code Here

        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());
    }
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.