Search in sources :

Example 1 with RevertOp

use of org.locationtech.geogig.api.porcelain.RevertOp in project GeoGig by boundlessgeo.

the class Revert method runInternal.

/**
     * Executes the revert command.
     */
@Override
protected void runInternal(GeogigCLI cli) throws IOException {
    checkParameter(commits.size() > 0 || abort || continueRevert, "nothing specified for reverting");
    final GeoGIG geogig = cli.getGeogig();
    RevertOp revert = geogig.command(RevertOp.class);
    for (String st : commits) {
        Optional<ObjectId> commitId = geogig.command(RevParse.class).setRefSpec(st).call();
        checkParameter(commitId.isPresent(), "Couldn't resolve '" + st + "' to a commit, aborting revert.");
        revert.addCommit(Suppliers.ofInstance(commitId.get()));
    }
    try {
        revert.setCreateCommit(!noCommit).setAbort(abort).setContinue(continueRevert).call();
    } catch (RevertConflictsException e) {
        StringBuilder sb = new StringBuilder();
        sb.append(e.getMessage() + "\n");
        sb.append("When you have fixed these conflicts, run 'geogig revert --continue' to continue the revert operation.\n");
        sb.append("To abort the revert operation, run 'geogig revert --abort'\n");
        throw new CommandFailedException(sb.toString());
    }
    if (abort) {
        cli.getConsole().println("Revert aborted successfully.");
    }
}
Also used : RevertOp(org.locationtech.geogig.api.porcelain.RevertOp) ObjectId(org.locationtech.geogig.api.ObjectId) RevertConflictsException(org.locationtech.geogig.api.porcelain.RevertConflictsException) GeoGIG(org.locationtech.geogig.api.GeoGIG) CommandFailedException(org.locationtech.geogig.cli.CommandFailedException)

Aggregations

GeoGIG (org.locationtech.geogig.api.GeoGIG)1 ObjectId (org.locationtech.geogig.api.ObjectId)1 RevertConflictsException (org.locationtech.geogig.api.porcelain.RevertConflictsException)1 RevertOp (org.locationtech.geogig.api.porcelain.RevertOp)1 CommandFailedException (org.locationtech.geogig.cli.CommandFailedException)1