diff 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
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/HgCloneCommand.java	Wed Jan 23 17:46:12 2013 +0100
+++ b/src/org/tmatesoft/hg/core/HgCloneCommand.java	Wed Jan 23 18:03:13 2013 +0100
@@ -298,8 +298,8 @@
 				byte[] calculated = dh.sha1(p1, p2, content).asBinary();
 				final Nodeid node = ge.node();
 				if (!node.equalsTo(calculated)) {
-					// TODO post-1.0 custom exception ChecksumCalculationFailed?
-					throw new HgInvalidStateException(String.format("Checksum failed: expected %s, calculated %s. File %s", node, calculated, filename));
+					String m = String.format("Checksum failed: expected %s, calculated %s. File %s", node, calculated, filename);
+					throw new HgRevisionIntegrityException(m, null, new File(hgDir, filename));
 				}
 				revlogHeader.nodeid(node);
 				if (collectChangelogIndexes) {
@@ -348,7 +348,7 @@
 				prevRevContent = new ByteArrayDataAccess(content);
 			} catch (IOException ex) {
 				String m = String.format("Failed to write revision %s of file %s", ge.node().shortNotation(), filename);
-				throw new HgInvalidControlFileException(m, ex, new File(filename));
+				throw new HgInvalidControlFileException(m, ex, new File(hgDir, filename));
 			}
 			return cancelException == null;
 		}