emptyChangelog = false;
HgChangelog changelog = hgRepo.getChangelog();
try {
if (prevRevContent == null) {
if (ge.firstParent().isNull() && ge.secondParent().isNull()) {
prevRevContent = new ByteArrayDataAccess(new byte[0]);
} else {
final Nodeid base = ge.firstParent();
if (!changelog.isKnown(base) /*only first parent, that's Bundle contract*/) {
throw new IllegalStateException(String.format("Revision %s needs a parent %s, which is missing in the supplied repo %s", ge.node().shortNotation(), base.shortNotation(), hgRepo.toString()));
}
ByteArrayChannel bac = new ByteArrayChannel();
changelog.rawContent(base, bac); // TODO post-1.0 get DataAccess directly, to avoid
// extra byte[] (inside ByteArrayChannel) duplication just for the sake of subsequent ByteArrayDataChannel wrap.
prevRevContent = new ByteArrayDataAccess(bac.toArray());
}
}
//
byte[] csetContent = ge.patch().apply(prevRevContent, -1);
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?
if (!ge.node().equalsTo(dh.asBinary())) {
throw new HgInvalidStateException(String.format("Integrity check failed on %s, node: %s", bundleFile, ge.node().shortNotation()));
}
RawChangeset cs = csetBuilder.parse(csetContent);
inspector.next(revisionIndex++, ge.node(), cs);
prevRevContent.done();
prevRevContent = new ByteArrayDataAccess(csetContent);
} catch (CancelledException ex) {
return false;
} catch (HgInvalidDataFormatException ex) {
throw new HgInvalidControlFileException("Invalid bundle file", ex, bundleFile);
}