# HG changeset patch # User Artem Tikhomirov # Date 1323198168 -3600 # Node ID fc8bc2f1edbe876c66c8fcbfc054bb836c733b06 # Parent dfb8405d996f524c83f541a9be0fae4641cc586c Clean internal classes from public API diff -r dfb8405d996f -r fc8bc2f1edbe src/org/tmatesoft/hg/core/HgCloneCommand.java --- a/src/org/tmatesoft/hg/core/HgCloneCommand.java Tue Dec 06 19:47:01 2011 +0100 +++ b/src/org/tmatesoft/hg/core/HgCloneCommand.java Tue Dec 06 20:02:48 2011 +0100 @@ -254,7 +254,7 @@ prevRevContent = new ByteArrayDataAccess(new byte[0]); writeComplete = true; } - byte[] content = ge.apply(prevRevContent); + byte[] content = ge.apply(prevRevContent.byteArray()); byte[] calculated = dh.sha1(p1, p2, content).asBinary(); final Nodeid node = ge.node(); if (!node.equalsTo(calculated)) { @@ -272,12 +272,12 @@ link = csRev.intValue(); } final int p1Rev = knownRevision(p1), p2Rev = knownRevision(p2); - DataAccess patchContent = ge.rawData(); - writeComplete = writeComplete || patchContent.length() >= (/* 3/4 of actual */content.length - (content.length >>> 2)); + byte[] patchContent = ge.rawDataByteArray(); + writeComplete = writeComplete || patchContent.length >= (/* 3/4 of actual */content.length - (content.length >>> 2)); if (writeComplete) { base = revisionSequence.size(); } - final byte[] sourceData = writeComplete ? content : patchContent.byteArray(); + final byte[] sourceData = writeComplete ? content : patchContent; final byte[] data; ByteArrayOutputStream bos = new ByteArrayOutputStream(content.length); DeflaterOutputStream dos = new DeflaterOutputStream(bos); diff -r dfb8405d996f -r fc8bc2f1edbe src/org/tmatesoft/hg/repo/HgBundle.java --- a/src/org/tmatesoft/hg/repo/HgBundle.java Tue Dec 06 19:47:01 2011 +0100 +++ b/src/org/tmatesoft/hg/repo/HgBundle.java Tue Dec 06 20:02:48 2011 +0100 @@ -29,6 +29,7 @@ import org.tmatesoft.hg.internal.DataAccess; import org.tmatesoft.hg.internal.DataAccessProvider; import org.tmatesoft.hg.internal.DigestHelper; +import org.tmatesoft.hg.internal.Experimental; import org.tmatesoft.hg.internal.InflaterDataAccess; import org.tmatesoft.hg.internal.Patch; import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; @@ -358,7 +359,7 @@ } } - // FIXME GroupElement exposes some internal API!!! (DataAccess) + @Experimental(reason="Cumbersome API, rawData and apply with byte[] perhaps need replacement with ByteChannel/ByteBuffer, and better Exceptions. Perhaps, shall split into interface and impl") public static class GroupElement { private final byte[] header; // byte[80] takes 120 bytes, 4 Nodeids - 192 private final DataAccess dataAccess; @@ -370,27 +371,47 @@ dataAccess = rawDataAccess; } - // non-null + /** + * node field of the group element + * @return node revision, never null + */ public Nodeid node() { return Nodeid.fromBinary(header, 0); } - // non-null + /** + * p1 (parent 1) field of the group element + * @return revision of parent 1, never null + */ public Nodeid firstParent() { return Nodeid.fromBinary(header, 20); } - // non-null + /** + * p2 (parent 2) field of the group element + * @return revision of parent 2, never null + */ public Nodeid secondParent() { return Nodeid.fromBinary(header, 40); } - // non-null - public Nodeid cset() { // cs seems to be changeset + /** + * cs (changeset link) field of the group element + * @return changeset revision, never null + */ + public Nodeid cset() { return Nodeid.fromBinary(header, 60); } + + public byte[] rawDataByteArray() throws IOException { // XXX IOException or HgInvalidFileException? + return rawData().byteArray(); + } + + public byte[] apply(byte[] baseContent) throws IOException { + return apply(new ByteArrayDataAccess(baseContent)); + } - public DataAccess rawData() { + /*package-local*/ DataAccess rawData() { return dataAccess; } @@ -403,7 +424,7 @@ return patches; } - public byte[] apply(DataAccess baseContent) throws IOException { + /*package-local*/ byte[] apply(DataAccess baseContent) throws IOException { return patch().apply(baseContent, -1); }