Mercurial > jhg
diff src/org/tmatesoft/hg/core/HgRevertCommand.java @ 581:0890628ed51e
Progress/cancel support in new commands
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 22 Apr 2013 16:02:17 +0200 |
parents | 78a9e26e670d |
children | f41dd9a3b8af |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/HgRevertCommand.java Fri Apr 19 20:30:34 2013 +0200 +++ b/src/org/tmatesoft/hg/core/HgRevertCommand.java Mon Apr 22 16:02:17 2013 +0200 @@ -30,8 +30,10 @@ import org.tmatesoft.hg.repo.HgManifest.Flags; import org.tmatesoft.hg.repo.HgRepository; import org.tmatesoft.hg.repo.HgRuntimeException; +import org.tmatesoft.hg.util.CancelSupport; import org.tmatesoft.hg.util.CancelledException; import org.tmatesoft.hg.util.Path; +import org.tmatesoft.hg.util.ProgressSupport; /** * WORK IN PROGRESS. @@ -95,12 +97,16 @@ /** * Perform the back out for the given files * - * @throws HgIOException - * @throws HgException - * @throws CancelledException + * @throws HgIOException to indicate troubles updating files in working copy + * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state + * @throws CancelledException if execution of the command was cancelled */ public void execute() throws HgException, CancelledException { try { + final ProgressSupport progress = getProgressSupport(null); + final CancelSupport cancellation = getCancelSupport(null, true); + cancellation.checkCancelled(); + progress.start(files.size() + 2); final int csetRevision; if (changesetToCheckout.get() == HgRepository.WORKING_COPY) { csetRevision = repo.getChangelog().getRevisionIndex(repo.getWorkingCopyParents().first()); @@ -110,6 +116,9 @@ Internals implRepo = Internals.getInstance(repo); final DirstateBuilder dirstateBuilder = new DirstateBuilder(implRepo); dirstateBuilder.fillFrom(new DirstateReader(implRepo, new Path.SimpleSource())); + progress.worked(1); + cancellation.checkCancelled(); + final HgCheckoutCommand.CheckoutWorker worker = new HgCheckoutCommand.CheckoutWorker(implRepo); HgManifest.Inspector insp = new HgManifest.Inspector() { @@ -146,8 +155,12 @@ } repo.getManifest().walkFileRevisions(file, insp, csetRevision); worker.checkFailed(); + progress.worked(1); + cancellation.checkCancelled(); } dirstateBuilder.serialize(); + progress.worked(1); + progress.done(); } catch (HgRuntimeException ex) { throw new HgLibraryFailureException(ex); }