Skip to content

Commit bd78bbf

Browse files
author
Gabriel Roldan
committed
Allow to set a progress listener to transaction commit
Signed-off-by: Gabriel Roldan <[email protected]>
1 parent d83e285 commit bd78bbf

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

src/api/src/main/java/org/locationtech/geogig/repository/DefaultProgressListener.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import java.util.function.Function;
1313

14-
import com.google.common.base.Preconditions;
1514
import com.google.common.util.concurrent.AtomicDouble;
1615

1716
/**

src/cli/core/src/main/java/org/locationtech/geogig/cli/porcelain/Commit.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.locationtech.geogig.plumbing.RevParse;
2929
import org.locationtech.geogig.plumbing.merge.ReadMergeCommitMessageOp;
3030
import org.locationtech.geogig.porcelain.CommitOp;
31-
import org.locationtech.geogig.porcelain.ConflictsException;
3231
import org.locationtech.geogig.porcelain.NothingToCommitException;
3332
import org.locationtech.geogig.repository.DiffObjectCount;
3433
import org.locationtech.geogig.repository.ProgressListener;
@@ -121,7 +120,7 @@ public void runInternal(GeogigCLI cli) throws IOException {
121120
commitOp.setCommit(geogig.getRepository().getCommit(commitId.get()));
122121
}
123122
commit = commitOp.setPathFilters(pathFilters).setProgressListener(progress).call();
124-
} catch (NothingToCommitException | ConflictsException
123+
} catch (NothingToCommitException
125124
| IllegalStateException notificationError) {
126125
throw new CommandFailedException(notificationError.getMessage(), true);
127126
}

src/core/src/main/java/org/locationtech/geogig/plumbing/TransactionEnd.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,22 +164,25 @@ private void updateRefs() {
164164
if (rebase) {
165165
// Try to rebase
166166
transaction.command(CheckoutOp.class).setSource(refName).setForce(true)
167-
.call();
167+
.setProgressListener(getProgressListener()).call();
168168
transaction.command(RebaseOp.class)
169169
.setUpstream(Suppliers.ofInstance(currentRef.get().getObjectId()))
170-
.call();
170+
.setProgressListener(getProgressListener()).call();
171171

172172
updatedRef = transaction.command(RefParse.class).setName(refName).call()
173173
.get();
174174
} else {
175175
// sync transactions have to use merge to prevent divergent history
176176
transaction.command(CheckoutOp.class).setSource(refName).setForce(true)
177-
.call();
177+
.setProgressListener(getProgressListener()).call();
178178
try {
179179
transaction.command(MergeOp.class)
180180
.setAuthor(authorName.orNull(), authorEmail.orNull())
181-
.addCommit(currentRef.get().getObjectId()).call();
181+
.addCommit(currentRef.get().getObjectId())
182+
.setProgressListener(getProgressListener()).call();
182183
} catch (NothingToCommitException e) {
184+
LOGGER.debug("Transaction merge for {} unnecessary. {}",
185+
currentRef.get().getName(), e.getMessage());
183186
// The repo commit is already in our history, this is a fast
184187
// forward.
185188
}

src/core/src/main/java/org/locationtech/geogig/repository/impl/GeogigTransaction.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
import org.locationtech.geogig.porcelain.ConflictsException;
2222
import org.locationtech.geogig.repository.AbstractGeoGigOp;
2323
import org.locationtech.geogig.repository.Context;
24+
import org.locationtech.geogig.repository.DefaultProgressListener;
2425
import org.locationtech.geogig.repository.Platform;
26+
import org.locationtech.geogig.repository.ProgressListener;
2527
import org.locationtech.geogig.repository.Repository;
2628
import org.locationtech.geogig.repository.StagingArea;
2729
import org.locationtech.geogig.repository.WorkingTree;
@@ -155,8 +157,13 @@ public String toString() {
155157
}
156158

157159
public void commit() throws ConflictsException {
160+
commit(DefaultProgressListener.NULL);
161+
}
162+
163+
public void commit(ProgressListener listener) throws ConflictsException {
158164
context.command(TransactionEnd.class).setAuthor(authorName.orNull(), authorEmail.orNull())
159-
.setTransaction(this).setCancel(false).setRebase(true).call();
165+
.setTransaction(this).setCancel(false).setRebase(true).setProgressListener(listener)
166+
.call();
160167
}
161168

162169
public void commitSyncTransaction() throws ConflictsException {

0 commit comments

Comments
 (0)