Skip to content

Commit

Permalink
Allow to set a progress listener to transaction commit
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Roldan <[email protected]>
  • Loading branch information
Gabriel Roldan committed Aug 28, 2018
1 parent d83e285 commit bd78bbf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import java.util.function.Function;

import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.AtomicDouble;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.locationtech.geogig.plumbing.RevParse;
import org.locationtech.geogig.plumbing.merge.ReadMergeCommitMessageOp;
import org.locationtech.geogig.porcelain.CommitOp;
import org.locationtech.geogig.porcelain.ConflictsException;
import org.locationtech.geogig.porcelain.NothingToCommitException;
import org.locationtech.geogig.repository.DiffObjectCount;
import org.locationtech.geogig.repository.ProgressListener;
Expand Down Expand Up @@ -121,7 +120,7 @@ public void runInternal(GeogigCLI cli) throws IOException {
commitOp.setCommit(geogig.getRepository().getCommit(commitId.get()));
}
commit = commitOp.setPathFilters(pathFilters).setProgressListener(progress).call();
} catch (NothingToCommitException | ConflictsException
} catch (NothingToCommitException
| IllegalStateException notificationError) {
throw new CommandFailedException(notificationError.getMessage(), true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,25 @@ private void updateRefs() {
if (rebase) {
// Try to rebase
transaction.command(CheckoutOp.class).setSource(refName).setForce(true)
.call();
.setProgressListener(getProgressListener()).call();
transaction.command(RebaseOp.class)
.setUpstream(Suppliers.ofInstance(currentRef.get().getObjectId()))
.call();
.setProgressListener(getProgressListener()).call();

updatedRef = transaction.command(RefParse.class).setName(refName).call()
.get();
} else {
// sync transactions have to use merge to prevent divergent history
transaction.command(CheckoutOp.class).setSource(refName).setForce(true)
.call();
.setProgressListener(getProgressListener()).call();
try {
transaction.command(MergeOp.class)
.setAuthor(authorName.orNull(), authorEmail.orNull())
.addCommit(currentRef.get().getObjectId()).call();
.addCommit(currentRef.get().getObjectId())
.setProgressListener(getProgressListener()).call();
} catch (NothingToCommitException e) {
LOGGER.debug("Transaction merge for {} unnecessary. {}",
currentRef.get().getName(), e.getMessage());
// The repo commit is already in our history, this is a fast
// forward.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import org.locationtech.geogig.porcelain.ConflictsException;
import org.locationtech.geogig.repository.AbstractGeoGigOp;
import org.locationtech.geogig.repository.Context;
import org.locationtech.geogig.repository.DefaultProgressListener;
import org.locationtech.geogig.repository.Platform;
import org.locationtech.geogig.repository.ProgressListener;
import org.locationtech.geogig.repository.Repository;
import org.locationtech.geogig.repository.StagingArea;
import org.locationtech.geogig.repository.WorkingTree;
Expand Down Expand Up @@ -155,8 +157,13 @@ public String toString() {
}

public void commit() throws ConflictsException {
commit(DefaultProgressListener.NULL);
}

public void commit(ProgressListener listener) throws ConflictsException {
context.command(TransactionEnd.class).setAuthor(authorName.orNull(), authorEmail.orNull())
.setTransaction(this).setCancel(false).setRebase(true).call();
.setTransaction(this).setCancel(false).setRebase(true).setProgressListener(listener)
.call();
}

public void commitSyncTransaction() throws ConflictsException {
Expand Down

0 comments on commit bd78bbf

Please sign in to comment.