Mercurial > hg4j
diff src/com/tmate/hgkit/ll/HgBundle.java @ 41:858d1b2458cb
Check integrity for bundle changelog. Sort nodeids when calculating hash
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 14 Jan 2011 04:14:08 +0100 |
parents | 4e9b66b07a28 |
children | 92c3d0920d58 |
line wrap: on
line diff
--- a/src/com/tmate/hgkit/ll/HgBundle.java Fri Jan 14 03:37:06 2011 +0100 +++ b/src/com/tmate/hgkit/ll/HgBundle.java Fri Jan 14 04:14:08 2011 +0100 @@ -28,6 +28,7 @@ public void changes(HgRepository hgRepo) throws IOException { DataAccess da = accessProvider.create(bundleFile); + DigestHelper dh = new DigestHelper(); try { List<GroupElement> changelogGroup = readGroup(da); if (changelogGroup.isEmpty()) { @@ -46,6 +47,9 @@ for (GroupElement ge : changelogGroup) { int resultLen = 10000; // XXX calculate based on baseRevContent.length and ge.patches byte[] csetContent = RevlogStream.apply(baseRevContent, resultLen, ge.patches); + // wiki suggests sha1_digest(min(p1,p2) ++ max(p1,p2) ++ final_text), + 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? + System.out.println("Node: " + ge.node() + ", digest: " + digest); Changeset cs = Changeset.parse(csetContent, 0, csetContent.length); cs.dump(); baseRevContent = csetContent;