# HG changeset patch # User Artem Tikhomirov # Date 1355752917 -3600 # Node ID a41d955dc360b1c2b6af3e8dcb1f214ebc11bd6e # Parent 10ca3ede836781d7a07d11f4883f76cc86f6b168 Issue 39: HgCloneCommand doesn't use CancelSupport/ProgressSupport handlers diff -r 10ca3ede8367 -r a41d955dc360 src/org/tmatesoft/hg/core/HgCloneCommand.java --- 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) { diff -r 10ca3ede8367 -r a41d955dc360 src/org/tmatesoft/hg/repo/HgBundle.java --- 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); } }