comparison src/org/tmatesoft/hg/core/HgCloneCommand.java @ 531:95c2f43008bd

Throw specific exception when checksum calculation fails
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 23 Jan 2013 18:03:13 +0100
parents 0f6fa88e2162
children 688c1ab113bb
comparison
equal deleted inserted replaced
530:0f6fa88e2162 531:95c2f43008bd
296 } 296 }
297 byte[] content = ge.apply(prevRevContent.byteArray()); 297 byte[] content = ge.apply(prevRevContent.byteArray());
298 byte[] calculated = dh.sha1(p1, p2, content).asBinary(); 298 byte[] calculated = dh.sha1(p1, p2, content).asBinary();
299 final Nodeid node = ge.node(); 299 final Nodeid node = ge.node();
300 if (!node.equalsTo(calculated)) { 300 if (!node.equalsTo(calculated)) {
301 // TODO post-1.0 custom exception ChecksumCalculationFailed? 301 String m = String.format("Checksum failed: expected %s, calculated %s. File %s", node, calculated, filename);
302 throw new HgInvalidStateException(String.format("Checksum failed: expected %s, calculated %s. File %s", node, calculated, filename)); 302 throw new HgRevisionIntegrityException(m, null, new File(hgDir, filename));
303 } 303 }
304 revlogHeader.nodeid(node); 304 revlogHeader.nodeid(node);
305 if (collectChangelogIndexes) { 305 if (collectChangelogIndexes) {
306 changelogIndexes.put(node, revisionSequence.size()); 306 changelogIndexes.put(node, revisionSequence.size());
307 revlogHeader.linkRevision(revisionSequence.size()); 307 revlogHeader.linkRevision(revisionSequence.size());
346 revisionSequence.add(node); 346 revisionSequence.add(node);
347 prevRevContent.done(); 347 prevRevContent.done();
348 prevRevContent = new ByteArrayDataAccess(content); 348 prevRevContent = new ByteArrayDataAccess(content);
349 } catch (IOException ex) { 349 } catch (IOException ex) {
350 String m = String.format("Failed to write revision %s of file %s", ge.node().shortNotation(), filename); 350 String m = String.format("Failed to write revision %s of file %s", ge.node().shortNotation(), filename);
351 throw new HgInvalidControlFileException(m, ex, new File(filename)); 351 throw new HgInvalidControlFileException(m, ex, new File(hgDir, filename));
352 } 352 }
353 return cancelException == null; 353 return cancelException == null;
354 } 354 }
355 /* 355 /*
356 $ hg debugindex build.gradle 356 $ hg debugindex build.gradle