Examples of PackWriter


Examples of org.eclipse.jgit.internal.storage.pack.PackWriter

    // different pack under the same file name is partially broken. We
    // should also have a different file name because the list of objects
    // within the pack has been modified.
    //
    final RevObject o2 = writeBlob(eden, "o2");
    final PackWriter pw = new PackWriter(eden);
    pw.addObject(o2);
    pw.addObject(o1);
    write(out1, pw);
    pw.release();

    // Try the old name, then the new name. The old name should cause the
    // pack to reload when it opens and the index and pack mismatch.
    //
    assertEquals(o1.name(), parse(o1).name());
View Full Code Here

Examples of org.eclipse.jgit.internal.storage.pack.PackWriter

    return new RevWalk(db).parseAny(id);
  }

  private File[] pack(final Repository src, final RevObject... list)
      throws IOException {
    final PackWriter pw = new PackWriter(src);
    for (final RevObject o : list) {
      pw.addObject(o);
    }

    final ObjectId name = pw.computeName();
    final File packFile = fullPackFileName(name, ".pack");
    final File idxFile = fullPackFileName(name, ".idx");
    final File[] files = new File[] { packFile, idxFile };
    write(files, pw);
    pw.release();
    return files;
  }
View Full Code Here

Examples of org.eclipse.jgit.internal.storage.pack.PackWriter

      pc.setIndexVersion(2);
      pc.setDeltaCompress(false);
      pc.setReuseDeltas(true);
      pc.setReuseObjects(true);

      PackWriter pw = new PackWriter(pc, ctx);
      try {
        pw.setDeltaBaseAsOffset(true);
        pw.setReuseDeltaCommits(false);

        addObjectsToPack(pw, ctx, pm);
        if (pw.getObjectCount() == 0) {
          List<DfsPackDescription> remove = toPrune();
          if (remove.size() > 0)
            objdb.commitPack(
                Collections.<DfsPackDescription>emptyList(),
                remove);
          return;
        }

        boolean rollback = true;
        DfsPackDescription pack = objdb.newPack(COMPACT);
        try {
          writePack(objdb, pack, pw, pm);
          writeIndex(objdb, pack, pw);

          PackWriter.Statistics stats = pw.getStatistics();
          pw.release();
          pw = null;

          pack.setPackStats(stats);
          objdb.commitPack(Collections.singletonList(pack), toPrune());
          newPacks.add(pack);
          newStats.add(stats);
          rollback = false;
        } finally {
          if (rollback)
            objdb.rollbackPack(Collections.singletonList(pack));
        }
      } finally {
        if (pw != null)
          pw.release();
      }
    } finally {
      rw = null;
      ctx.release();
    }
View Full Code Here

Examples of org.eclipse.jgit.internal.storage.pack.PackWriter

    if (db.getObjectDatabase() instanceof ObjectDirectory) {
      ObjectDirectory odb = (ObjectDirectory) db.getObjectDatabase();
      NullProgressMonitor m = NullProgressMonitor.INSTANCE;

      final File pack, idx;
      PackWriter pw = new PackWriter(db);
      try {
        Set<ObjectId> all = new HashSet<ObjectId>();
        for (Ref r : db.getAllRefs().values())
          all.add(r.getObjectId());
        pw.preparePack(m, all, Collections.<ObjectId> emptySet());

        final ObjectId name = pw.computeName();
        OutputStream out;

        pack = nameFor(odb, name, ".pack");
        out = new SafeBufferedOutputStream(new FileOutputStream(pack));
        try {
          pw.writePack(m, m, out);
        } finally {
          out.close();
        }
        pack.setReadOnly();

        idx = nameFor(odb, name, ".idx");
        out = new SafeBufferedOutputStream(new FileOutputStream(idx));
        try {
          pw.writeIndex(out);
        } finally {
          out.close();
        }
        idx.setReadOnly();
      } finally {
        pw.release();
      }

      odb.openPack(pack);
      updateServerInfo();
      prunePacked(odb);
View Full Code Here

Examples of org.eclipse.jgit.internal.storage.pack.PackWriter

   *
   * @throws IOException
   */
  @Test
  public void testContructor() throws IOException {
    writer = new PackWriter(config, db.newObjectReader());
    assertFalse(writer.isDeltaBaseAsOffset());
    assertTrue(config.isReuseDeltas());
    assertTrue(config.isReuseObjects());
    assertEquals(0, writer.getObjectCount());
  }
View Full Code Here

Examples of org.eclipse.jgit.internal.storage.pack.PackWriter

    config.setDeltaBaseAsOffset(false);
    assertFalse(config.isReuseDeltas());
    assertFalse(config.isReuseObjects());
    assertFalse(config.isDeltaBaseAsOffset());

    writer = new PackWriter(config, db.newObjectReader());
    writer.setDeltaBaseAsOffset(true);
    assertTrue(writer.isDeltaBaseAsOffset());
    assertFalse(config.isDeltaBaseAsOffset());
  }
View Full Code Here

Examples of org.eclipse.jgit.internal.storage.pack.PackWriter

  }

  private static PackIndex writePack(FileRepository repo,
      Set<? extends ObjectId> want, Set<ObjectIdSet> excludeObjects)
      throws IOException {
    PackWriter pw = new PackWriter(repo);
    pw.setDeltaBaseAsOffset(true);
    pw.setReuseDeltaCommits(false);
    for (ObjectIdSet idx : excludeObjects)
      pw.excludeObjects(idx);
    pw.preparePack(NullProgressMonitor.INSTANCE, want,
        Collections.<ObjectId> emptySet());
    String id = pw.computeName().getName();
    File packdir = new File(repo.getObjectsDirectory(), "pack");
    File packFile = new File(packdir, "pack-" + id + ".pack");
    FileOutputStream packOS = new FileOutputStream(packFile);
    pw.writePack(NullProgressMonitor.INSTANCE,
        NullProgressMonitor.INSTANCE, packOS);
    packOS.close();
    File idxFile = new File(packdir, "pack-" + id + ".idx");
    FileOutputStream idxOS = new FileOutputStream(idxFile);
    pw.writeIndex(idxOS);
    idxOS.close();
    pw.release();
    return PackIndex.open(idxFile);
  }
View Full Code Here

Examples of org.eclipse.jgit.internal.storage.pack.PackWriter

  private void createVerifyOpenPack(final Set<ObjectId> interestings,
      final Set<ObjectId> uninterestings, final boolean thin,
      final boolean ignoreMissingUninteresting, boolean useBitmaps)
      throws MissingObjectException, IOException {
    NullProgressMonitor m = NullProgressMonitor.INSTANCE;
    writer = new PackWriter(config, db.newObjectReader());
    writer.setUseBitmaps(useBitmaps);
    writer.setThin(thin);
    writer.setIgnoreMissingUninteresting(ignoreMissingUninteresting);
    writer.preparePack(m, interestings, uninterestings);
    writer.writePack(m, m, os);
View Full Code Here

Examples of org.eclipse.jgit.internal.storage.pack.PackWriter

  }

  private void createVerifyOpenPack(final List<RevObject> objectSource)
      throws MissingObjectException, IOException {
    NullProgressMonitor m = NullProgressMonitor.INSTANCE;
    writer = new PackWriter(config, db.newObjectReader());
    writer.preparePack(objectSource.iterator());
    assertEquals(objectSource.size(), writer.getObjectCount());
    writer.writePack(m, m, os);
    writer.release();
    verifyOpenPack(false);
View Full Code Here

Examples of org.eclipse.jgit.internal.storage.pack.PackWriter

      throws IOException, MissingObjectException,
      StoredObjectRepresentationNotAvailableException {
    ObjectReuseAsIs asis = (ObjectReuseAsIs) reader;
    ObjectToPack target = asis.newObjectToPack(obj, obj.getType());

    PackWriter pw = new PackWriter(reader) {
      @Override
      public void select(ObjectToPack otp, StoredObjectRepresentation next) {
        otp.select(next);
      }
    };
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.