Mercurial > jhg
changeset 513:a41d955dc360
Issue 39: HgCloneCommand doesn't use CancelSupport/ProgressSupport handlers
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 17 Dec 2012 15:01:57 +0100 |
parents | 10ca3ede8367 |
children | 5dcb4581c8ef |
files | src/org/tmatesoft/hg/core/HgCloneCommand.java src/org/tmatesoft/hg/repo/HgBundle.java |
diffstat | 2 files changed, 34 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/HgCloneCommand.java Fri Dec 14 20:10:15 2012 +0100 +++ b/src/org/tmatesoft/hg/core/HgCloneCommand.java Mon Dec 17 15:01:57 2012 +0100 @@ -189,6 +189,7 @@ } catch (IOException ex) { throw new HgInvalidControlFileException("Failed to write changelog", ex, new File(filename)); } + stopIfCancelled(); } public void changelogEnd() { @@ -204,6 +205,8 @@ } catch (IOException ex) { throw new HgInvalidControlFileException("Failed to write changelog", ex, new File(filename)); } + progressSupport.worked(1); + stopIfCancelled(); } public void manifestStart() { @@ -215,6 +218,7 @@ } catch (IOException ex) { throw new HgInvalidControlFileException("Failed to write manifest", ex, new File(filename)); } + stopIfCancelled(); } public void manifestEnd() { @@ -229,6 +233,8 @@ } catch (IOException ex) { throw new HgInvalidControlFileException("Failed to write changelog", ex, new File(filename)); } + progressSupport.worked(1); + stopIfCancelled(); } public void fileStart(String name) { @@ -245,6 +251,7 @@ String m = String.format("Failed to write file %s", filename); throw new HgInvalidControlFileException(m, ex, new File(filename)); } + stopIfCancelled(); } public void fileEnd(String name) { @@ -260,6 +267,8 @@ String m = String.format("Failed to write file %s", filename); throw new HgInvalidControlFileException(m, ex, new File(filename)); } + progressSupport.worked(1); + stopIfCancelled(); } private int knownRevision(Nodeid p) { @@ -360,7 +369,7 @@ String m = String.format("Failed to write revision %s of file %s", ge.node().shortNotation(), filename); throw new HgInvalidControlFileException(m, ex, new File(filename)); } - return true; + return cancelException == null; } public void start(int count, Callback callback, Object token) {
--- a/src/org/tmatesoft/hg/repo/HgBundle.java Fri Dec 14 20:10:15 2012 +0100 +++ b/src/org/tmatesoft/hg/repo/HgBundle.java Mon Dec 17 15:01:57 2012 +0100 @@ -311,7 +311,13 @@ try { da = getDataStream(); internalInspectChangelog(da, inspector); + if (flowControl.isStopped()) { + return; + } internalInspectManifest(da, inspector); + if (flowControl.isStopped()) { + return; + } internalInspectFiles(da, inspector); } catch (IOException ex) { throw new HgInvalidFileException("Bundle.inspectAll failed", ex, bundleFile); @@ -353,7 +359,13 @@ return; } inspector.changelogStart(); + if (flowControl.isStopped()) { + return; + } readGroup(da, inspector); + if (flowControl.isStopped()) { + return; + } inspector.changelogEnd(); } @@ -362,7 +374,13 @@ return; } inspector.manifestStart(); + if (flowControl.isStopped()) { + return; + } readGroup(da, inspector); + if (flowControl.isStopped()) { + return; + } inspector.manifestEnd(); } @@ -376,7 +394,13 @@ da.readBytes(fnameBuf, 0, fnameBuf.length); String name = new String(fnameBuf); inspector.fileStart(name); + if (flowControl.isStopped()) { + return; + } readGroup(da, inspector); + if (flowControl.isStopped()) { + return; + } inspector.fileEnd(name); } }