comparison src/org/tmatesoft/hg/core/HgCloneCommand.java @ 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 0f6fa88e2162
comparison
equal deleted inserted replaced
512:10ca3ede8367 513:a41d955dc360
187 indexFile = new FileOutputStream(new File(hgDir, filename = "store/00changelog.i")); 187 indexFile = new FileOutputStream(new File(hgDir, filename = "store/00changelog.i"));
188 collectChangelogIndexes = true; 188 collectChangelogIndexes = true;
189 } catch (IOException ex) { 189 } catch (IOException ex) {
190 throw new HgInvalidControlFileException("Failed to write changelog", ex, new File(filename)); 190 throw new HgInvalidControlFileException("Failed to write changelog", ex, new File(filename));
191 } 191 }
192 stopIfCancelled();
192 } 193 }
193 194
194 public void changelogEnd() { 195 public void changelogEnd() {
195 try { 196 try {
196 if (prevRevContent != null) { 197 if (prevRevContent != null) {
202 indexFile = null; 203 indexFile = null;
203 filename = null; 204 filename = null;
204 } catch (IOException ex) { 205 } catch (IOException ex) {
205 throw new HgInvalidControlFileException("Failed to write changelog", ex, new File(filename)); 206 throw new HgInvalidControlFileException("Failed to write changelog", ex, new File(filename));
206 } 207 }
208 progressSupport.worked(1);
209 stopIfCancelled();
207 } 210 }
208 211
209 public void manifestStart() { 212 public void manifestStart() {
210 try { 213 try {
211 base = -1; 214 base = -1;
213 revisionSequence.clear(); 216 revisionSequence.clear();
214 indexFile = new FileOutputStream(new File(hgDir, filename = "store/00manifest.i")); 217 indexFile = new FileOutputStream(new File(hgDir, filename = "store/00manifest.i"));
215 } catch (IOException ex) { 218 } catch (IOException ex) {
216 throw new HgInvalidControlFileException("Failed to write manifest", ex, new File(filename)); 219 throw new HgInvalidControlFileException("Failed to write manifest", ex, new File(filename));
217 } 220 }
221 stopIfCancelled();
218 } 222 }
219 223
220 public void manifestEnd() { 224 public void manifestEnd() {
221 try { 225 try {
222 if (prevRevContent != null) { 226 if (prevRevContent != null) {
227 indexFile = null; 231 indexFile = null;
228 filename = null; 232 filename = null;
229 } catch (IOException ex) { 233 } catch (IOException ex) {
230 throw new HgInvalidControlFileException("Failed to write changelog", ex, new File(filename)); 234 throw new HgInvalidControlFileException("Failed to write changelog", ex, new File(filename));
231 } 235 }
236 progressSupport.worked(1);
237 stopIfCancelled();
232 } 238 }
233 239
234 public void fileStart(String name) { 240 public void fileStart(String name) {
235 try { 241 try {
236 base = -1; 242 base = -1;
243 indexFile = new FileOutputStream(file); 249 indexFile = new FileOutputStream(file);
244 } catch (IOException ex) { 250 } catch (IOException ex) {
245 String m = String.format("Failed to write file %s", filename); 251 String m = String.format("Failed to write file %s", filename);
246 throw new HgInvalidControlFileException(m, ex, new File(filename)); 252 throw new HgInvalidControlFileException(m, ex, new File(filename));
247 } 253 }
254 stopIfCancelled();
248 } 255 }
249 256
250 public void fileEnd(String name) { 257 public void fileEnd(String name) {
251 try { 258 try {
252 if (prevRevContent != null) { 259 if (prevRevContent != null) {
258 filename = null; 265 filename = null;
259 } catch (IOException ex) { 266 } catch (IOException ex) {
260 String m = String.format("Failed to write file %s", filename); 267 String m = String.format("Failed to write file %s", filename);
261 throw new HgInvalidControlFileException(m, ex, new File(filename)); 268 throw new HgInvalidControlFileException(m, ex, new File(filename));
262 } 269 }
270 progressSupport.worked(1);
271 stopIfCancelled();
263 } 272 }
264 273
265 private int knownRevision(Nodeid p) { 274 private int knownRevision(Nodeid p) {
266 if (p.isNull()) { 275 if (p.isNull()) {
267 return -1; 276 return -1;
358 prevRevContent = new ByteArrayDataAccess(content); 367 prevRevContent = new ByteArrayDataAccess(content);
359 } catch (IOException ex) { 368 } catch (IOException ex) {
360 String m = String.format("Failed to write revision %s of file %s", ge.node().shortNotation(), filename); 369 String m = String.format("Failed to write revision %s of file %s", ge.node().shortNotation(), filename);
361 throw new HgInvalidControlFileException(m, ex, new File(filename)); 370 throw new HgInvalidControlFileException(m, ex, new File(filename));
362 } 371 }
363 return true; 372 return cancelException == null;
364 } 373 }
365 374
366 public void start(int count, Callback callback, Object token) { 375 public void start(int count, Callback callback, Object token) {
367 progressSupport.start(count); 376 progressSupport.start(count);
368 lifecycleCallback = callback; 377 lifecycleCallback = callback;