Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.CommitBuilder


            }
        }

        final RevCommit commit;
        if (this.commit == null) {
            CommitBuilder cb = new CommitBuilder();
            cb.setAuthor(author);
            cb.setAuthorEmail(authorEmail);
            cb.setCommitter(committer);
            cb.setCommitterEmail(committerEmail);
            cb.setMessage(message);
            cb.setParentIds(parents);
            cb.setTreeId(newTreeId);
            cb.setCommitterTimestamp(committerTime);
            cb.setAuthorTimestamp(authorTime);
            cb.setCommitterTimeZoneOffset(committerTimeZoneOffset);
            cb.setAuthorTimeZoneOffset(authorTimeZoneOffset);
            commit = cb.build();
        } else {
            CommitBuilder cb = new CommitBuilder(this.commit);
            cb.setParentIds(parents);
            cb.setTreeId(newTreeId);
            cb.setCommitterTimestamp(committerTime);
            cb.setCommitterTimeZoneOffset(committerTimeZoneOffset);
            if (message != null) {
                cb.setMessage(message);
            }
            commit = cb.build();
        }

        if (getProgressListener().isCanceled()) {
            return null;
        }
View Full Code Here


            rebaseHead = onto.get();
            command(ResetOp.class).setCommit(Suppliers.ofInstance(rebaseHead))
                    .setMode(ResetMode.HARD).call();

            if (squashMessage != null) {
                CommitBuilder builder = new CommitBuilder(commitsToRebase.get(0));
                builder.setParentIds(Arrays.asList(ancestorCommit.get()));
                builder.setMessage(squashMessage);
                squashCommit = builder.build();
                // save the commit, since it does not exist in the database, and might be needed if
                // there is a conflict
                CharSequence commitString = command(CatObject.class).setObject(
                        Suppliers.ofInstance(squashCommit)).call();
                File squashFile = new File(getRebaseFolder(), "squash");
View Full Code Here

                // 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 {
                    Files.write(currentBranch, branchFile, Charsets.UTF_8);
                } catch (IOException e) {
                    throw new IllegalStateException("Cannot create current branch info file");
                }

                throw new RebaseConflictsException(msg.toString());

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

    }

    private CommitBuilder testCommit(ObjectId treeId, String author, String authorEmail,
            long authorTimestamp, String committer, String committerEmail, long committerTimestamp,
            String message, ObjectId... parentIds) {
        CommitBuilder b = new CommitBuilder();
        b.setTreeId(treeId);
        b.setAuthor(author);
        b.setAuthorEmail(authorEmail);
        b.setCommitter(committer);
        b.setCommitterEmail(committerEmail);
        b.setMessage(message);
        b.setAuthorTimestamp(authorTimestamp);
        b.setCommitterTimestamp(committerTimestamp);
        if (parentIds != null) {
            b.setParentIds(Lists.newArrayList(parentIds));
        }
        return b;
    }
View Full Code Here

    @Test
    public void testCommitRoundTrippin() throws Exception {
        long currentTime = System.currentTimeMillis();
        int timeZoneOffset = TimeZone.getDefault().getOffset(currentTime);
        CommitBuilder builder = new CommitBuilder();
        String author = "groldan";
        builder.setAuthor(author);
        String authorEmail = "groldan@boundlessgeo.com";
        builder.setAuthorEmail(authorEmail);
        builder.setAuthorTimestamp(currentTime);
        builder.setAuthorTimeZoneOffset(timeZoneOffset);
        String committer = "mleslie";
        builder.setCommitter(committer);
        String committerEmail = "mleslie@boundlessgeo.com";
        builder.setCommitterEmail(committerEmail);
        builder.setCommitterTimestamp(currentTime);
        builder.setCommitterTimeZoneOffset(timeZoneOffset);

        ObjectId treeId = ObjectId.forString("Fake tree");
        builder.setTreeId(treeId);

        ObjectId parent1 = ObjectId.forString("Parent 1 of fake commit");
        ObjectId parent2 = ObjectId.forString("Parent 2 of fake commit");
        List<ObjectId> parents = Arrays.asList(parent1, parent2);
        builder.setParentIds(parents);

        RevCommit cmtIn = builder.build();
        assertNotNull(cmtIn);

        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        ObjectWriter<RevCommit> write = factory.createObjectWriter(TYPE.COMMIT);
        write.write(cmtIn, bout);
View Full Code Here

                    writeTree.dontMoveObjects();
                }

                ObjectId newTreeId = writeTree.call();

                CommitBuilder builder = new CommitBuilder(commit);
                List<ObjectId> newParents = new LinkedList<ObjectId>();
                for (ObjectId parentCommitId : commit.getParentIds()) {
                    newParents.add(graphDatabase.getMapping(parentCommitId));
                }
                builder.setParentIds(newParents);
                builder.setTreeId(newTreeId);

                RevCommit mapped = builder.build();
                objectDatabase.put(mapped);

                if (changes.wasFiltered()) {
                    graphDatabase.setProperty(mapped.getId(), GraphDatabase.SPARSE_FLAG, "true");
                }

                graphDatabase.map(mapped.getId(), commit.getId());
                // Replace the old mapping with the new commit Id.
                graphDatabase.map(commit.getId(), mapped.getId());
            } else if (allowEmpty) {
                CommitBuilder builder = new CommitBuilder(commit);
                List<ObjectId> newParents = new LinkedList<ObjectId>();
                for (ObjectId parentCommitId : commit.getParentIds()) {
                    newParents.add(graphDatabase.getMapping(parentCommitId));
                }
                builder.setParentIds(newParents);
                builder.setTreeId(rootTree.getId());
                builder.setMessage(PLACEHOLDER_COMMIT_MESSAGE);

                RevCommit mapped = builder.build();
                objectDatabase.put(mapped);

                graphDatabase.setProperty(mapped.getId(), GraphDatabase.SPARSE_FLAG, "true");

                graphDatabase.map(mapped.getId(), commit.getId());
View Full Code Here

            // Create new commit
            ObjectId newTreeId = to.command(WriteTree.class)
                    .setOldRoot(Suppliers.ofInstance(rootTree))
                    .setDiffSupplier(Suppliers.ofInstance((Iterator<DiffEntry>) changes)).call();

            CommitBuilder builder = new CommitBuilder(commit);
            builder.setParentIds(newParents);
            builder.setTreeId(newTreeId);

            RevCommit mapped = builder.build();
            to.objectDatabase().put(mapped);

            from.graphDatabase().map(commit.getId(), mapped.getId());
            from.graphDatabase().map(mapped.getId(), commit.getId());
View Full Code Here

        masterCommit3 = commit("masterCommit3");

        // fake a merge until we have the merge op in place

        CommitBuilder cb = new CommitBuilder();
        cb.setParentIds(ImmutableList.of(masterCommit3.getId(), branchCommit2.getId()));
        cb.setMessage("mergeCommit");
        cb.setAuthor("groldan");
        cb.setCommitter("groldan");
        cb.setTreeId(masterCommit3.getTreeId());
        long now = System.currentTimeMillis();
        cb.setAuthorTimestamp(now);
        cb.setCommitterTimestamp(now);
        mergeCommit = cb.build();

        getRepository().objectDatabase().put(mergeCommit);

        geogig.command(UpdateRef.class).setName("refs/heads/master")
                .setOldValue(masterCommit3.getId()).setNewValue(mergeCommit.getId()).call();
View Full Code Here

                        .setOldRoot(Suppliers.ofInstance(rootTree))
                        .setDiffSupplier(Suppliers.ofInstance((Iterator<DiffEntry>) changes))
                        .dontMoveObjects()// HttpFilteredDiffIterator is "auto ingesting"
                        .call();

                CommitBuilder builder = new CommitBuilder(commit);

                builder.setParentIds(newParents);
                builder.setTreeId(newTreeId);

                RevCommit mapped = builder.build();
                repository.objectDatabase().put(mapped);
                newCommitId = mapped.getId();

            } catch (IOException e) {
                throw new RuntimeException(e);
View Full Code Here

        // simulate a commit so the repo head points to this new tree
        ObjectInserter objectInserter = repo.newObjectInserter();
        List<ObjectId> parents = ImmutableList.of();

        RevCommit commit = new CommitBuilder(geogig.getPlatform()).setTreeId(newRootTreeId)
                .setParentIds(parents).build();
        ObjectId commitId = commit.getId();

        objectInserter.insert(commit);
        Optional<Ref> newHead = geogig.command(UpdateRef.class).setName("refs/heads/master")
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.CommitBuilder

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.