Package org.tmatesoft.hg.internal

Examples of org.tmatesoft.hg.internal.ByteArrayDataAccess


    } else {
      baseRevision = ByteBuffer.allocate(rr.getDataLength());
      rr.getData(baseRevision);
      baseRevision.flip();
    }
    ByteArrayDataAccess baseRevisionContent = new ByteArrayDataAccess(baseRevision.array(), baseRevision.arrayOffset(), baseRevision.remaining());
    //
    final long start = System.currentTimeMillis();
    int n = 1419;
    Patch seqPatch = new Patch(false), normalizedPatch = new Patch(true);
    while (rr.hasMore() && n-- > 0) {
      rr.readNext();
      if (!rr.isPatch()) {
        break;
      }
      if (rr.getDataLength() == 0) {
        System.out.printf("Empty content of revision %d\n", rr.entryIndex);
        continue;
      }
      Patch p1 = createPatch(rr);
      if (n < 1) {
        System.out.println("+" + p1);
        System.currentTimeMillis();
      }
        seqPatch = seqPatch.apply(p1);
        normalizedPatch = normalizedPatch.apply(p1);
//        if (n <= 1) {
//          System.out.println("=" + seqPatch);
//        }
//        if (n == 0) {
//          System.out.println("A" + ppp);
//          System.out.println("N" + normalizedPatch);
//          normalizedPatch = ppp;
//        }
        //
      if (!thoroughCheck) {
        if (baseRevisionContent.length() + seqPatch.patchSizeDelta() != rr.actualLen) {
          System.out.printf("Sequential patches:\tPatchRevision #%d (+%d, cset:%d) failed\n", rr.entryIndex, rr.entryIndex - startEntryIndex, rr.linkRevision);
        }
        if (baseRevisionContent.length() + normalizedPatch.patchSizeDelta() != rr.actualLen) {
          System.out.printf("Normalized patches:\tPatchRevision #%d (+%d, cset:%d) failed\n", rr.entryIndex, rr.entryIndex - startEntryIndex, rr.linkRevision);
        }
      } else {
        byte[] origin = getRevisionTrueContent(indexFile.getParentFile(), rr.entryIndex, rr.linkRevision);
        try {
View Full Code Here


      patchData.clear();
    }
    rr.getData(patchData);
    patchData.flip();
    Patch patch1 = new Patch();
    patch1.read(new ByteArrayDataAccess(patchData.array(), patchData.arrayOffset(), patchData.remaining()));
    return patch1;
  }
View Full Code Here

        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);
        }
View Full Code Here

      byte[] nb = new byte[80];
      da.readBytes(nb, 0, 80);
      int dataLength = len - 84 /* length field + 4 nodeids */;
      byte[] data = new byte[dataLength];
      da.readBytes(data, 0, dataLength);
      DataAccess slice = new ByteArrayDataAccess(data); // XXX in fact, may pass a slicing DataAccess.
      // Just need to make sure that we seek to proper location afterwards (where next GroupElement starts),
      // regardless whether that slice has read it or not.
      GroupElement ge = new GroupElement(nb, prevNodeid, slice);
      good2go = inspector.element(ge);
      slice.done(); // BADA doesn't implement done(), but it could (e.g. free array)
      /// and we'd better tell it we are not going to use it any more. However, it's important to ensure Inspector
      // implementations out there do not retain GroupElement.rawData()
      prevNodeid = ge.node();
      len = da.isEmpty() ? 0 : da.readInt();
    }
View Full Code Here

        }
        sds.done();
        //
        revisionSequence.add(node);
        prevRevContent.done();
        prevRevContent = new ByteArrayDataAccess(content);
      } catch (HgIOException ex) {
        String m = String.format("Failed to write revision %s of file %s", ge.node().shortNotation(), filename);
        throw new HgInvalidControlFileException(m, ex, currentFile);
      } catch (IOException ex) {
        String m = String.format("Failed to write revision %s of file %s", ge.node().shortNotation(), filename);
View Full Code Here

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DeflaterOutputStream dos = new DeflaterOutputStream(bos);
    dos.write(source);
    dos.flush();
    dos.close();
    return new ByteArrayDataAccess(bos.toByteArray());
  }
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.internal.ByteArrayDataAccess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.