Mercurial > hg4j
comparison src/com/tmate/hgkit/ll/HgBundle.java @ 42:92c3d0920d58
Real integrity check, with exception. DigestHelper refactored to accomodate new needs
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 14 Jan 2011 04:29:03 +0100 |
parents | 858d1b2458cb |
children | 1b26247d7367 |
comparison
equal
deleted
inserted
replaced
41:858d1b2458cb | 42:92c3d0920d58 |
---|---|
46 byte[] baseRevContent = hgRepo.getChangelog().content(base); | 46 byte[] baseRevContent = hgRepo.getChangelog().content(base); |
47 for (GroupElement ge : changelogGroup) { | 47 for (GroupElement ge : changelogGroup) { |
48 int resultLen = 10000; // XXX calculate based on baseRevContent.length and ge.patches | 48 int resultLen = 10000; // XXX calculate based on baseRevContent.length and ge.patches |
49 byte[] csetContent = RevlogStream.apply(baseRevContent, resultLen, ge.patches); | 49 byte[] csetContent = RevlogStream.apply(baseRevContent, resultLen, ge.patches); |
50 // wiki suggests sha1_digest(min(p1,p2) ++ max(p1,p2) ++ final_text), | 50 // wiki suggests sha1_digest(min(p1,p2) ++ max(p1,p2) ++ final_text), |
51 String digest = dh.sha1(ge.firstParent(), ge.secondParent(), csetContent); // XXX ge may give me access to byte[] content of nodeid directly, perhaps, I don't need DH to be friend of Nodeid? | 51 dh = dh.sha1(ge.firstParent(), ge.secondParent(), csetContent); // XXX ge may give me access to byte[] content of nodeid directly, perhaps, I don't need DH to be friend of Nodeid? |
52 System.out.println("Node: " + ge.node() + ", digest: " + digest); | 52 if (!ge.node().equalsTo(dh.asBinary())) { |
53 throw new IllegalStateException("Integrity check failed on " + bundleFile + ", node:" + ge.node()); | |
54 } | |
53 Changeset cs = Changeset.parse(csetContent, 0, csetContent.length); | 55 Changeset cs = Changeset.parse(csetContent, 0, csetContent.length); |
54 cs.dump(); | 56 cs.dump(); |
55 baseRevContent = csetContent; | 57 baseRevContent = csetContent; |
56 } | 58 } |
57 } finally { | 59 } finally { |