Package org.tmatesoft.hg.internal

Examples of org.tmatesoft.hg.internal.ByteVector


    void walk(int[] manifestRevIndexes, RevlogStream content) throws HgRuntimeException {
      content.iterate(manifestRevIndexes, true, this);
    }
   
    public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess data) throws HgRuntimeException {
      ByteVector byteVector = new ByteVector(256, 128); // allocate for long paths right away
      try {
        byte b;
        while (!data.isEmpty() && (b = data.readByte()) != '\n') {
          if (b != 0) {
            byteVector.add(b);
          } else {
            if (byteVector.equalsTo(filenameAsBytes)) {
              Nodeid fileRev = null;
              Flags flags = null;
              if (csetIndex2FileRev != null || delegate != null) {
                byte[] nid = new byte[40]
                data.readBytes(nid, 0, 40);
                fileRev = Nodeid.fromAscii(nid, 0, 40);
              } else {
                data.skip(40);
              }
              if (csetIndex2Flags != null || delegate != null) {
                byteVector.clear();
                while (!data.isEmpty() && (b = data.readByte()) != '\n') {
                  byteVector.add(b);
                }
                if (byteVector.size() == 0) {
                  flags = Flags.RegularFile;
                } else {
                  flags = Flags.parse(byteVector.toByteArray(), 0, byteVector.size());
                }
              }
              if (delegate != null) {
                assert flags != null;
                assert fileRev != null;
                delegate.begin(revisionNumber, Nodeid.fromBinary(nodeid, 0), linkRevision);
                delegate.next(fileRev, filename, flags);
                delegate.end(revisionNumber);
               
              } else {
                if (csetIndex2FileRev != null) {
                  csetIndex2FileRev.put(linkRevision, fileRev);
                }
                if (csetIndex2Flags != null) {
                  csetIndex2Flags.put(linkRevision, flags);
                }
              }
              break;
            } else {
              data.skip(40);
            }
            // else skip to the end of line
            while (!data.isEmpty() && (b = data.readByte()) != '\n')
              ;

            byteVector.clear();
          }
        }
      } catch (IOException ex) {
        throw new HgInvalidControlFileException("Failed reading manifest", ex, null);
      }
View Full Code Here


    errorCollector.assertFalse(rs.includesTargetLine(12));
  }
 
  @Test
  public void testByteVector() {
    ByteVector v = new ByteVector(4, 2);
    v.add(7);
    v.add(9);
    errorCollector.assertEquals(2, v.size());
    v.clear();
    errorCollector.assertEquals(0, v.size());
    v.add(10);
    v.add(9);
    v.add(8);
    v.add(7);
    v.add(6);
    errorCollector.assertEquals(5, v.size());
    v.add(5);
    v.add(4);
    errorCollector.assertEquals(7, v.size());
    byte x = 10;
    for (byte d : v.toByteArray()) {
      errorCollector.assertEquals(x, d);
      x--;
    }
    x = 10;
    byte[] dd = new byte[10];
    v.copyTo(dd);
    for (int i = 0; i < v.size(); i++) {
      errorCollector.assertEquals(x, dd[i]);
      x--;
    }
    errorCollector.assertTrue(v.equalsTo(new byte[] { 10,9,8,7,6,5,4 }));
  }
View Full Code Here

TOP

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

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.