Package org.locationtech.geogig.api.porcelain

Examples of org.locationtech.geogig.api.porcelain.LogOp$TopologicalHistoryIterator


        sw.stop();
        System.err.println(numberFormat.format(numBranches) + " branches with "
                + numberFormat.format(numCommits) + " comits each created in " + sw.toString());
        System.err.flush();

        LogOp op = geogig.command(LogOp.class);
        for (ObjectId id : ids) {
            op.addCommit(id);
        }
        sw.reset().start();
        Iterator<RevCommit> commits = op.call();
        sw.stop();
        System.err.println("LogOp took " + sw.toString());

        benchmarkIteration(commits);

        op = geogig.command(LogOp.class).setTopoOrder(true);
        for (ObjectId id : ids) {
            op.addCommit(id);
        }
        sw.reset().start();
        commits = op.call();
        sw.stop();
        System.err.println("LogOp using --topo-order took " + sw.toString());
        benchmarkIteration(commits);

        super.tearDown();
View Full Code Here


    public void runInternal(GeogigCLI cli) throws IOException {
        checkParameter(!args.commits.isEmpty(), "No starting commit provided");

        geogig = cli.getGeogig();

        LogOp op = geogig.command(LogOp.class).setTopoOrder(args.topo)
                .setFirstParentOnly(args.firstParent);

        for (String commit : args.commits) {
            if (commit.contains("..")) {
                checkParameter(args.commits.size() == 1,
                        "Only one value accepted when using <since>..<until> syntax");
                List<String> sinceUntil = ImmutableList.copyOf((Splitter.on("..").split(commit)));
                checkParameter(sinceUntil.size() == 2 || sinceUntil.size() == 1,
                        "Invalid refSpec format, expected [<commit> ...]|[<since>..<until>]: %s",
                        commit);
                String sinceRefSpec;
                String untilRefSpec;
                if (sinceUntil.size() == 1) {
                    // just until was given
                    sinceRefSpec = null;
                    untilRefSpec = sinceUntil.get(0);
                } else {
                    sinceRefSpec = sinceUntil.get(0);
                    untilRefSpec = sinceUntil.get(1);
                }
                if (sinceRefSpec != null) {
                    Optional<ObjectId> since;
                    since = geogig.command(RevParse.class).setRefSpec(sinceRefSpec).call();
                    checkParameter(since.isPresent(), "Object not found '%s'", sinceRefSpec);
                    op.setSince(since.get());
                }
                if (untilRefSpec != null) {
                    Optional<ObjectId> until;
                    until = geogig.command(RevParse.class).setRefSpec(untilRefSpec).call();
                    checkParameter(until.isPresent(), "Object not found '%s'", sinceRefSpec);
                    op.setUntil(until.get());
                }
            } else {
                Optional<ObjectId> commitId = geogig.command(RevParse.class).setRefSpec(commit)
                        .call();
                checkParameter(commitId.isPresent(), "Object not found '%s'", commit);
                checkParameter(geogig.getRepository().commitExists(commitId.get()),
                        "%s does not resolve to a commit", commit);
                op.addCommit(commitId.get());
            }
        }
        if (args.author != null && !args.author.isEmpty()) {
            op.setAuthor(args.author);
        }
        if (args.committer != null && !args.committer.isEmpty()) {
            op.setCommiter(args.committer);
        }
        if (args.skip != null) {
            op.setSkip(args.skip.intValue());
        }
        if (args.limit != null) {
            op.setLimit(args.limit.intValue());
        }
        if (args.since != null || args.until != null) {
            Date since = new Date(0);
            Date until = new Date();
            if (args.since != null) {
                since = new Date(geogig.command(ParseTimestamp.class).setString(args.since).call());
            }
            if (args.until != null) {
                until = new Date(geogig.command(ParseTimestamp.class).setString(args.until).call());
            }
            op.setTimeRange(new Range<Date>(Date.class, since, until));
        }
        if (!args.pathNames.isEmpty()) {
            for (String s : args.pathNames) {
                op.addPath(s);
            }
        }
        Iterator<RevCommit> log = op.call();
        console = cli.getConsole();

        RawPrinter printer = new RawPrinter(args.changed);
        while (log.hasNext()) {
            printer.print(log.next());
View Full Code Here

        assertEquals(c2, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c1, iterator.next());

        // test log using first parent only. It should not contain commit 2)
        LogOp op = geogig.command(LogOp.class).setFirstParentOnly(true);
        iterator = op.call();
        assertNotNull(iterator);
        assertTrue(iterator.hasNext());
        assertEquals(mergeCommit, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c4, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c3, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c1, iterator.next());
        assertFalse(iterator.hasNext());

        // Test topological order
        op = geogig.command(LogOp.class).setTopoOrder(true);
        iterator = op.call();
        assertNotNull(iterator);
        assertTrue(iterator.hasNext());
        assertEquals(mergeCommit, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c4, iterator.next());
View Full Code Here

        assertEquals(mergeCommit, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c2, iterator.next());

        // test log using first parent only. It should not contain commit 2)
        LogOp op = geogig.command(LogOp.class).addPath(pointsName + "/" + idP2)
                .setFirstParentOnly(true);
        iterator = op.call();
        assertNotNull(iterator);
        assertTrue(iterator.hasNext());
        assertEquals(mergeCommit, iterator.next());
        assertFalse(iterator.hasNext());
    }
View Full Code Here

        insertAndAdd(points3);
        final RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for " + idP3).call();
        insertAndAdd(lines1);
        final RevCommit c4 = geogig.command(CommitOp.class).setMessage("commit for " + idL1).call();

        LogOp op = geogig.command(LogOp.class);
        op.addCommit(c2.getId());
        op.addCommit(c4.getId());
        Iterator<RevCommit> iterator = op.call();
        assertNotNull(iterator);
        assertTrue(iterator.hasNext());
        assertEquals(c4, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c3, iterator.next());
View Full Code Here

        insertAndAdd(points3);
        geogig.command(CommitOp.class).setMessage("commit for " + idP3).call();
        insertAndAdd(lines1);
        geogig.command(CommitOp.class).setMessage("commit for " + idL1).call();

        LogOp op = geogig.command(LogOp.class).addCommit(c2.getId());
        Iterator<RevCommit> iterator = op.call();
        assertNotNull(iterator);
        assertTrue(iterator.hasNext());
        assertEquals(c2, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c1, iterator.next());
View Full Code Here

        checkParameter(!(args.stats && args.oneline),
                "--name-only and --oneline cannot be used together");

        geogig = cli.getGeogig();

        LogOp op = geogig.command(LogOp.class).setTopoOrder(args.topo)
                .setFirstParentOnly(args.firstParent);

        refs = Maps.newHashMap();
        if (args.decoration) {
            Optional<Ref> head = geogig.command(RefParse.class).setName(Ref.HEAD).call();
            refs.put(head.get().getObjectId(), Ref.HEAD);
            ImmutableSet<Ref> set = geogig.command(ForEachRef.class)
                    .setPrefixFilter(Ref.REFS_PREFIX).call();
            for (Ref ref : set) {
                ObjectId id = ref.getObjectId();
                if (refs.containsKey(id)) {
                    refs.put(id, refs.get(id) + ", " + ref.getName());
                } else {
                    refs.put(id, ref.getName());
                }
            }
        }
        if (args.all) {
            ImmutableSet<Ref> refs = geogig.command(ForEachRef.class)
                    .setPrefixFilter(Ref.REFS_PREFIX).call();
            List<ObjectId> list = Lists.newArrayList();
            for (Ref ref : refs) {
                list.add(ref.getObjectId());
            }
            Optional<Ref> head = geogig.command(RefParse.class).setName(Ref.HEAD).call();
            if (head.isPresent()) {
                Ref ref = head.get();
                if (ref instanceof SymRef) {
                    ObjectId id = ref.getObjectId();
                    list.remove(id);
                    list.add(id);// put the HEAD ref in the last position, to give it preference
                }
            }
            for (ObjectId id : list) {
                op.addCommit(id);
            }
        } else if (args.branch != null) {
            Optional<Ref> obj = geogig.command(RefParse.class).setName(args.branch).call();
            checkParameter(obj.isPresent(), "Wrong branch name: " + args.branch);
            op.addCommit(obj.get().getObjectId());
        }

        if (args.author != null && !args.author.isEmpty()) {
            op.setAuthor(args.author);
        }
        if (args.committer != null && !args.committer.isEmpty()) {
            op.setCommiter(args.committer);
        }
        if (args.skip != null) {
            op.setSkip(args.skip.intValue());
        }
        if (args.limit != null) {
            op.setLimit(args.limit.intValue());
        }
        if (args.since != null || args.until != null) {
            Date since = new Date(0);
            Date until = new Date();
            if (args.since != null) {
                since = new Date(geogig.command(ParseTimestamp.class).setString(args.since).call());
            }
            if (args.until != null) {
                until = new Date(geogig.command(ParseTimestamp.class).setString(args.until).call());
                if (args.all) {
                    throw new InvalidParameterException(
                            "Cannot specify 'until' commit when listing all branches");
                }
            }
            op.setTimeRange(new Range<Date>(Date.class, since, until));
        }
        if (!args.sinceUntilPaths.isEmpty()) {
            List<String> sinceUntil = ImmutableList.copyOf((Splitter.on("..")
                    .split(args.sinceUntilPaths.get(0))));
            checkParameter(sinceUntil.size() == 1 || sinceUntil.size() == 2,
                    "Invalid refSpec format, expected [<until>]|[<since>..<until>]: %s",
                    args.sinceUntilPaths.get(0));

            String sinceRefSpec;
            String untilRefSpec;
            if (sinceUntil.size() == 1) {
                // just until was given
                sinceRefSpec = null;
                untilRefSpec = sinceUntil.get(0);
            } else {
                sinceRefSpec = sinceUntil.get(0);
                untilRefSpec = sinceUntil.get(1);
            }
            if (sinceRefSpec != null) {
                Optional<ObjectId> since;
                since = geogig.command(RevParse.class).setRefSpec(sinceRefSpec).call();
                checkParameter(since.isPresent(), "Object not found '%s'", sinceRefSpec);
                op.setSince(since.get());
            }
            if (untilRefSpec != null) {
                if (args.all) {
                    throw new InvalidParameterException(
                            "Cannot specify 'until' commit when listing all branches");
                }
                Optional<ObjectId> until;
                until = geogig.command(RevParse.class).setRefSpec(untilRefSpec).call();
                checkParameter(until.isPresent(), "Object not found '%s'", sinceRefSpec);
                op.setUntil(until.get());
            }
        }
        if (!args.pathNames.isEmpty()) {
            for (String s : args.pathNames) {
                op.addPath(s);
            }
        }
        Iterator<RevCommit> log = op.call();
        this.console = cli.getConsole();
        if (!log.hasNext()) {
            console.println("No commits to show");
            console.flush();
            return;
View Full Code Here

     */
    @Override
    public void run(CommandContext context) {
        final Context geogig = this.getCommandLocator(context);
        final List<FeatureTypeStats> stats = Lists.newArrayList();
        LogOp logOp = geogig.command(LogOp.class).setFirstParentOnly(true);
        final Iterator<RevCommit> log;
        if (since != null && !since.trim().isEmpty()) {
            Date untilTime = new Date();
            Date sinceTime = new Date(geogig.command(ParseTimestamp.class).setString(since).call());
            logOp.setTimeRange(new Range<Date>(Date.class, sinceTime, untilTime));
        }
        if (this.until != null) {
            Optional<ObjectId> until;
            until = geogig.command(RevParse.class).setRefSpec(this.until).call();
            Preconditions.checkArgument(until.isPresent(), "Object not found '%s'", this.until);
            logOp.setUntil(until.get());
        }

        LsTreeOp lsTreeOp = geogig.command(LsTreeOp.class)
                .setStrategy(LsTreeOp.Strategy.TREES_ONLY);
        if (path != null && !path.trim().isEmpty()) {
            lsTreeOp.setReference(path);
            logOp.addPath(path);
        }
        final Iterator<NodeRef> treeIter = lsTreeOp.call();

        while (treeIter.hasNext()) {
            NodeRef node = treeIter.next();
            stats.add(new FeatureTypeStats(node.path(), context.getGeoGIG().getRepository()
                    .getTree(node.objectId()).size()));
        }
        log = logOp.call();

        RevCommit firstCommit = null;
        RevCommit lastCommit = null;
        int totalCommits = 0;
        final List<RevPerson> authors = Lists.newArrayList();
View Full Code Here

     */
    @Override
    public void run(final CommandContext context) {
        final Context geogig = this.getCommandLocator(context);

        LogOp op = geogig.command(LogOp.class).setFirstParentOnly(firstParentOnly);

        if (skip != null) {
            op.setSkip(skip.intValue());
        }
        if (limit != null) {
            op.setLimit(limit.intValue());
        }

        if (this.sinceTime != null || this.untilTime != null) {
            Date since = new Date(0);
            Date until = new Date();
            if (this.sinceTime != null) {
                since = new Date(geogig.command(ParseTimestamp.class).setString(this.sinceTime)
                        .call());
            }
            if (this.untilTime != null) {
                until = new Date(geogig.command(ParseTimestamp.class).setString(this.untilTime)
                        .call());
            }
            op.setTimeRange(new Range<Date>(Date.class, since, until));
        }

        if (this.since != null) {
            Optional<ObjectId> since;
            since = geogig.command(RevParse.class).setRefSpec(this.since).call();
            Preconditions.checkArgument(since.isPresent(), "Object not found '%s'", this.since);
            op.setSince(since.get());
        }
        if (this.until != null) {
            Optional<ObjectId> until;
            until = geogig.command(RevParse.class).setRefSpec(this.until).call();
            Preconditions.checkArgument(until.isPresent(), "Object not found '%s'", this.until);
            op.setUntil(until.get());
        }
        if (paths != null && !paths.isEmpty()) {
            for (String path : paths) {
                op.addPath(path);
            }
        }

        final Iterator<RevCommit> log = op.call();

        Iterators.advance(log, page * elementsPerPage);

        if (countChanges) {
            final String pathFilter;
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.porcelain.LogOp$TopologicalHistoryIterator

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.