Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgBundle.java @ 358:fc8bc2f1edbe v0.7.0
Clean internal classes from public API
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 06 Dec 2011 20:02:48 +0100 |
parents | dfb8405d996f |
children | 994b5813a925 |
comparison
equal
deleted
inserted
replaced
357:dfb8405d996f | 358:fc8bc2f1edbe |
---|---|
27 import org.tmatesoft.hg.internal.ByteArrayChannel; | 27 import org.tmatesoft.hg.internal.ByteArrayChannel; |
28 import org.tmatesoft.hg.internal.ByteArrayDataAccess; | 28 import org.tmatesoft.hg.internal.ByteArrayDataAccess; |
29 import org.tmatesoft.hg.internal.DataAccess; | 29 import org.tmatesoft.hg.internal.DataAccess; |
30 import org.tmatesoft.hg.internal.DataAccessProvider; | 30 import org.tmatesoft.hg.internal.DataAccessProvider; |
31 import org.tmatesoft.hg.internal.DigestHelper; | 31 import org.tmatesoft.hg.internal.DigestHelper; |
32 import org.tmatesoft.hg.internal.Experimental; | |
32 import org.tmatesoft.hg.internal.InflaterDataAccess; | 33 import org.tmatesoft.hg.internal.InflaterDataAccess; |
33 import org.tmatesoft.hg.internal.Patch; | 34 import org.tmatesoft.hg.internal.Patch; |
34 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; | 35 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; |
35 import org.tmatesoft.hg.util.CancelledException; | 36 import org.tmatesoft.hg.util.CancelledException; |
36 | 37 |
356 da.skip(len - 4); // sizeof(int) | 357 da.skip(len - 4); // sizeof(int) |
357 len = da.isEmpty() ? 0 : da.readInt(); | 358 len = da.isEmpty() ? 0 : da.readInt(); |
358 } | 359 } |
359 } | 360 } |
360 | 361 |
361 // FIXME GroupElement exposes some internal API!!! (DataAccess) | 362 @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") |
362 public static class GroupElement { | 363 public static class GroupElement { |
363 private final byte[] header; // byte[80] takes 120 bytes, 4 Nodeids - 192 | 364 private final byte[] header; // byte[80] takes 120 bytes, 4 Nodeids - 192 |
364 private final DataAccess dataAccess; | 365 private final DataAccess dataAccess; |
365 private Patch patches; | 366 private Patch patches; |
366 | 367 |
368 assert fourNodeids != null && fourNodeids.length == 80; | 369 assert fourNodeids != null && fourNodeids.length == 80; |
369 header = fourNodeids; | 370 header = fourNodeids; |
370 dataAccess = rawDataAccess; | 371 dataAccess = rawDataAccess; |
371 } | 372 } |
372 | 373 |
373 // non-null | 374 /** |
375 * <b>node</b> field of the group element | |
376 * @return node revision, never <code>null</code> | |
377 */ | |
374 public Nodeid node() { | 378 public Nodeid node() { |
375 return Nodeid.fromBinary(header, 0); | 379 return Nodeid.fromBinary(header, 0); |
376 } | 380 } |
377 | 381 |
378 // non-null | 382 /** |
383 * <b>p1</b> <i>(parent 1)</i> field of the group element | |
384 * @return revision of parent 1, never <code>null</code> | |
385 */ | |
379 public Nodeid firstParent() { | 386 public Nodeid firstParent() { |
380 return Nodeid.fromBinary(header, 20); | 387 return Nodeid.fromBinary(header, 20); |
381 } | 388 } |
382 | 389 |
383 // non-null | 390 /** |
391 * <b>p2</b> <i>(parent 2)</i> field of the group element | |
392 * @return revision of parent 2, never <code>null</code> | |
393 */ | |
384 public Nodeid secondParent() { | 394 public Nodeid secondParent() { |
385 return Nodeid.fromBinary(header, 40); | 395 return Nodeid.fromBinary(header, 40); |
386 } | 396 } |
387 | 397 |
388 // non-null | 398 /** |
389 public Nodeid cset() { // cs seems to be changeset | 399 * <b>cs</b> <i>(changeset link)</i> field of the group element |
400 * @return changeset revision, never <code>null</code> | |
401 */ | |
402 public Nodeid cset() { | |
390 return Nodeid.fromBinary(header, 60); | 403 return Nodeid.fromBinary(header, 60); |
391 } | 404 } |
392 | 405 |
393 public DataAccess rawData() { | 406 public byte[] rawDataByteArray() throws IOException { // XXX IOException or HgInvalidFileException? |
407 return rawData().byteArray(); | |
408 } | |
409 | |
410 public byte[] apply(byte[] baseContent) throws IOException { | |
411 return apply(new ByteArrayDataAccess(baseContent)); | |
412 } | |
413 | |
414 /*package-local*/ DataAccess rawData() { | |
394 return dataAccess; | 415 return dataAccess; |
395 } | 416 } |
396 | 417 |
397 /*package-local*/ Patch patch() throws IOException { | 418 /*package-local*/ Patch patch() throws IOException { |
398 if (patches == null) { | 419 if (patches == null) { |
401 patches.read(dataAccess); | 422 patches.read(dataAccess); |
402 } | 423 } |
403 return patches; | 424 return patches; |
404 } | 425 } |
405 | 426 |
406 public byte[] apply(DataAccess baseContent) throws IOException { | 427 /*package-local*/ byte[] apply(DataAccess baseContent) throws IOException { |
407 return patch().apply(baseContent, -1); | 428 return patch().apply(baseContent, -1); |
408 } | 429 } |
409 | 430 |
410 public String toString() { | 431 public String toString() { |
411 int patchCount; | 432 int patchCount; |