Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.ObjectLoader$SmallObject


  }

  public ObjectLoader open(AnyObjectId objectId, int typeHint)
      throws MissingObjectException, IncorrectObjectTypeException,
      IOException {
    final ObjectLoader ldr = db.openObject(this, objectId);
    if (ldr == null) {
      if (typeHint == OBJ_ANY)
        throw new MissingObjectException(objectId.copy(), "unknown");
      throw new MissingObjectException(objectId.copy(), typeHint);
    }
    if (typeHint != OBJ_ANY && ldr.getType() != typeHint)
      throw new IncorrectObjectTypeException(objectId.copy(), typeHint);
    return ldr;
  }
View Full Code Here


   *            the entry containing new mode and content
   * @throws IOException
   */
  public static void checkoutEntry(final Repository repo, File f,
      DirCacheEntry entry) throws IOException {
    ObjectLoader ol = repo.open(entry.getObjectId());
    File parentDir = f.getParentFile();
    File tmpFile = File.createTempFile("._" + f.getName(), null, parentDir);
    FileOutputStream channel = new FileOutputStream(tmpFile);
    try {
      ol.copyTo(channel);
    } finally {
      channel.close();
    }
    FS fs = repo.getFS();
    WorkingTreeOptions opt = repo.getConfig().get(WorkingTreeOptions.KEY);
    if (opt.isFileMode() && fs.supportsExecute()) {
      if (FileMode.EXECUTABLE_FILE.equals(entry.getRawMode())) {
        if (!fs.canExecute(tmpFile))
          fs.setExecute(tmpFile, true);
      } else {
        if (fs.canExecute(tmpFile))
          fs.setExecute(tmpFile, false);
      }
    }
    if (!tmpFile.renameTo(f)) {
      // tried to rename which failed. Let' delete the target file and try
      // again
      FileUtils.delete(f);
      if (!tmpFile.renameTo(f)) {
        throw new IOException(MessageFormat.format(
            JGitText.get().couldNotWriteFile, tmpFile.getPath(),
            f.getPath()));
      }
    }
    entry.setLastModified(f.lastModified());
    entry.setLength((int) ol.getSize());
  }
View Full Code Here

          return objItr.next();
        if (!lItr.next())
          return null;

        ObjectId id = lItr.getObjectId();
        ObjectLoader ldr = lItr.open();
        RevObject r = objects.get(id);
        if (r == null)
          r = parseNew(id, ldr);
        else if (r instanceof RevCommit) {
          byte[] raw = ldr.getCachedBytes();
          ((RevCommit) r).parseCanonical(RevWalk.this, raw);
        } else if (r instanceof RevTag) {
          byte[] raw = ldr.getCachedBytes();
          ((RevTag) r).parseCanonical(RevWalk.this, raw);
        } else
          r.flags |= PARSED;
        return r;
      }
View Full Code Here

      else
        throw new AmbiguousObjectException(id, ids);
    }

    try {
      ObjectLoader ldr = source.open(side, entry);
      return ldr.getBytes(binaryFileThreshold);

    } catch (LargeObjectException.ExceedsLimit overLimit) {
      return BINARY;

    } catch (LargeObjectException.ExceedsByteArrayLimit overLimit) {
View Full Code Here

        continue;

      if (needBaseObjectIds)
        baseObjectIds.add(baseId);

      final ObjectLoader ldr;
      try {
        ldr = readCurs.open(baseId);
      } catch (MissingObjectException notFound) {
        missing.add(baseId);
        continue;
      }

      final DeltaVisit visit = new DeltaVisit();
      visit.data = ldr.getCachedBytes(Integer.MAX_VALUE);
      visit.id = baseId;
      final int typeCode = ldr.getType();
      final PackedObjectInfo oe = newInfo(baseId, null, null);

      if (onAppendBase(typeCode, visit.data, oe))
        entries[entryCount++] = oe;
View Full Code Here

      }
    }

    if (isCheckObjectCollisions()) {
      try {
        final ObjectLoader ldr = readCurs.open(id, type);
        final byte[] existingData = ldr.getCachedBytes(data.length);
        if (!Arrays.equals(data, existingData)) {
          throw new IOException(MessageFormat.format(
              JGitText.get().collisionOn, id.name()));
        }
      } catch (MissingObjectException notLocal) {
View Full Code Here

   * @throws IOException
   *             the repository cannot be read.
   */
  public BlameGenerator push(String description, AnyObjectId id)
      throws IOException {
    ObjectLoader ldr = reader.open(id);
    if (ldr.getType() == OBJ_BLOB) {
      if (description == null)
        description = JGitText.get().blameNotCommittedYet;
      BlobCandidate c = new BlobCandidate(description, resultPath);
      c.sourceBlob = id.toObjectId();
      c.sourceText = new RawText(ldr.getCachedBytes(Integer.MAX_VALUE));
      c.regionList = new Region(0, 0, c.sourceText.size());
      remaining = c.sourceText.size();
      push(c);
      return this;
    }
View Full Code Here

    r.renameScore = renameScore;
    return r;
  }

  void loadText(ObjectReader reader) throws IOException {
    ObjectLoader ldr = reader.open(sourceBlob, Constants.OBJ_BLOB);
    sourceText = new RawText(ldr.getCachedBytes(Integer.MAX_VALUE));
  }
View Full Code Here

  }

  ObjectLoader openObject1(final WindowCursor curs,
      final AnyObjectId objectId) throws IOException {
    if (unpackedObjectCache.isUnpacked(objectId)) {
      ObjectLoader ldr = openObject2(curs, objectId.name(), objectId);
      if (ldr != null)
        return ldr;
      else
        unpackedObjectCache.remove(objectId);
    }

    PackList pList = packList.get();
    SEARCH: for (;;) {
      for (final PackFile p : pList.packs) {
        try {
          final ObjectLoader ldr = p.get(curs, objectId);
          if (ldr != null)
            return ldr;
        } catch (PackMismatchException e) {
          // Pack was modified; refresh the entire pack list.
          //
View Full Code Here

   *         object, or null if the object does not exist.
   * @throws IOException
   */
  ObjectLoader openObject(final WindowCursor curs, final AnyObjectId objectId)
      throws IOException {
    ObjectLoader ldr;

    ldr = openObjectImpl1(curs, objectId);
    if (ldr != null)
      return ldr;

View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.ObjectLoader$SmallObject

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.