Package org.tmatesoft.hg.internal.DataSerializer

Examples of org.tmatesoft.hg.internal.DataSerializer.OutputStreamSerializer


    DataSerializer.DataSource bundleData = BundleSerializer.newInstance(sessionContext, bundle);
    OutputStream os = null;
    try {
      remote.sessionBegin();
      os = remote.unbundle(bundleData.serializeLength(), remoteHeads);
      bundleData.serialize(new OutputStreamSerializer(os));
      os.flush();
      os.close();
      os = null;
    } catch (IOException ex) {
      throw new HgRemoteConnectionException("Communication failure", ex).setRemoteCommand("unbundle").setServerInfo(getLocation());
View Full Code Here


    if (clogRevs.length == 0) {
      // nothing to write
      return bundleFile;
    }
    final FileOutputStream osBundle = new FileOutputStream(bundleFile);
    final OutputStreamSerializer outRaw = new OutputStreamSerializer(osBundle);
    outRaw.write("HG10UN".getBytes(), 0, 6);
    //
    RevlogStream clogStream = repo.getImplAccess().getChangelogStream();
    new ChunkGenerator(outRaw, clogMap).iterate(clogStream, clogRevs);
    outRaw.writeInt(0); // null chunk for changelog group
    //
    RevlogStream manifestStream = repo.getImplAccess().getManifestStream();
    new ChunkGenerator(outRaw, clogMap).iterate(manifestStream, manifestRevs.toArray(true));
    outRaw.writeInt(0); // null chunk for manifest group
    //
    EncodingHelper fnEncoder = repo.buildFileNameEncodingHelper();
    for (HgDataFile df : sortedByName(files)) {
      RevlogStream s = repo.getImplAccess().getStream(df);
      final IntVector fileRevs = new IntVector();
      s.iterate(0, TIP, false, new RevlogStream.Inspector() {
       
        public void next(int revisionIndex, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess data) throws HgRuntimeException {
          if (Arrays.binarySearch(clogRevs, linkRevision) >= 0) {
            fileRevs.add(revisionIndex);
          }
        }
      });
      fileRevs.sort(true);
      if (!fileRevs.isEmpty()) {
        // although BundleFormat page says "filename length, filename" for a file,
        // in fact there's a sort of 'filename chunk', i.e. filename length field includes
        // not only length of filename, but also length of the field itseld, i.e. filename.length+sizeof(int)
        byte[] fnameBytes = fnEncoder.toBundle(df.getPath());
        outRaw.writeInt(fnameBytes.length + 4);
        outRaw.writeByte(fnameBytes);
        new ChunkGenerator(outRaw, clogMap).iterate(s, fileRevs.toArray(true));
        outRaw.writeInt(0); // null chunk for file group
      }
    }
    outRaw.writeInt(0); // null chunk to indicate no more files (although BundleFormat page doesn't mention this)
    outRaw.done();
    osBundle.flush();
    osBundle.close();
    //return new HgBundle(repo.getSessionContext(), repo.getDataAccess(), bundleFile);
    return bundleFile;
  }
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.internal.DataSerializer.OutputStreamSerializer

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.