Package org.eclipse.jgit.revwalk

Examples of org.eclipse.jgit.revwalk.RevObject


    }
  }

  private Result updateImpl(final RevWalk walk, final Store store)
      throws IOException {
    RevObject newObj;
    RevObject oldObj;

    // don't make expensive conflict check if this is an existing Ref
    if (oldValue == null && checkConflicting && getRefDatabase().isNameConflicting(getName()))
      return Result.LOCK_FAILURE;
    try {
View Full Code Here


      else
        objectId = db.resolve(objectName);

      RevWalk rw = new RevWalk(db);
      try {
        RevObject obj = rw.parseAny(objectId);
        while (obj instanceof RevTag) {
          show((RevTag) obj);
          obj = ((RevTag) obj).getObject();
          rw.parseBody(obj);
        }

        switch (obj.getType()) {
        case Constants.OBJ_COMMIT:
          show(rw, (RevCommit) obj);
          break;

        case Constants.OBJ_TREE:
          outw.print("tree "); //$NON-NLS-1$
          outw.print(objectName);
          outw.println();
          outw.println();
          show((RevTree) obj);
          break;

        case Constants.OBJ_BLOB:
          db.open(obj, obj.getType()).copyTo(System.out);
          outw.flush();
          break;

        default:
          throw die(MessageFormat.format(
              CLIText.get().cannotReadBecause, obj.name(),
              obj.getType()));
        }
      } finally {
        rw.release();
      }
    } finally {
View Full Code Here

  }

  class PlotRefComparator implements Comparator<Ref> {
    public int compare(Ref o1, Ref o2) {
      try {
        RevObject obj1 = parseAny(o1.getObjectId());
        RevObject obj2 = parseAny(o2.getObjectId());
        long t1 = timeof(obj1);
        long t2 = timeof(obj2);
        if (t1 > t2)
          return -1;
        if (t1 < t2)
View Full Code Here

      throws TransportException {
    final HashSet<ObjectId> inWorkQueue = new HashSet<ObjectId>();
    for (final Ref r : want) {
      final ObjectId id = r.getObjectId();
      try {
        final RevObject obj = revWalk.parseAny(id);
        if (obj.has(COMPLETE))
          continue;
        if (inWorkQueue.add(id)) {
          obj.add(IN_WORK_QUEUE);
          workQueue.add(obj);
        }
      } catch (MissingObjectException e) {
        if (inWorkQueue.add(id))
          workQueue.add(id);
View Full Code Here

      }
    }
  }

  private void process(final ObjectId id) throws TransportException {
    final RevObject obj;
    try {
      if (id instanceof RevObject) {
        obj = (RevObject) id;
        if (obj.has(COMPLETE))
          return;
        revWalk.parseHeaders(obj);
      } else {
        obj = revWalk.parseAny(id);
        if (obj.has(COMPLETE))
          return;
      }
    } catch (IOException e) {
      throw new TransportException(MessageFormat.format(JGitText.get().cannotRead, id.name()), e);
    }

    switch (obj.getType()) {
    case Constants.OBJ_BLOB:
      processBlob(obj);
      break;
    case Constants.OBJ_TREE:
      processTree(obj);
View Full Code Here

        revWalk.lookupAny(idBuffer, sType).add(COMPLETE);
        continue;

      case Constants.OBJ_TREE: {
        treeWalk.getObjectId(idBuffer, 0);
        final RevObject o = revWalk.lookupAny(idBuffer, sType);
        if (!o.has(COMPLETE)) {
          o.add(COMPLETE);
          treeWalk.enterSubtree();
        }
        continue;
      }
      default:
View Full Code Here

      oc.checkCommit(bin);
      assertHash(o, bin);
    }

    for (;;) {
      final RevObject o = ow.nextObject();
      if (o == null)
        break;

      final byte[] bin = db.open(o, o.getType()).getCachedBytes();
      oc.check(o.getType(), bin);
      assertHash(o, bin);
    }
  }
View Full Code Here

        // Iterate through all of the commits. The BitmapRevFilter does
        // the work.
        pm.update(1);
      }

      RevObject ro;
      while ((ro = walker.nextObject()) != null) {
        bitmapResult.add(ro, ro.getType());
        pm.update(1);
      }
    }

    return bitmapResult;
View Full Code Here

    AsyncRevObjectQueue q = walker.parseAny(all, true);
    try {
      for (;;) {
        try {
          RevObject o = q.next();
          if (o == null)
            break;
          if (have.contains(o))
            haveObjs.add(o);
          if (want.contains(o)) {
            o.add(include);
            wantObjs.add(o);
            if (o instanceof RevTag)
              wantTags.add((RevTag) o);
          }
        } catch (MissingObjectException e) {
          if (ignoreMissingUninteresting
              && have.contains(e.getObjectId()))
            continue;
          throw e;
        }
      }
    } finally {
      q.release();
    }

    if (!wantTags.isEmpty()) {
      all = new ArrayList<ObjectId>(wantTags.size());
      for (RevTag tag : wantTags)
        all.add(tag.getObject());
      q = walker.parseAny(all, true);
      try {
        while (q.next() != null) {
          // Just need to pop the queue item to parse the object.
        }
      } finally {
        q.release();
      }
    }

    if (walker instanceof DepthWalk.ObjectWalk) {
      DepthWalk.ObjectWalk depthWalk = (DepthWalk.ObjectWalk) walker;
      for (RevObject obj : wantObjs)
        depthWalk.markRoot(obj);
      if (unshallowObjects != null) {
        for (ObjectId id : unshallowObjects)
          depthWalk.markUnshallow(walker.parseAny(id));
      }
    } else {
      for (RevObject obj : wantObjs)
        walker.markStart(obj);
    }
    for (RevObject obj : haveObjs)
      walker.markUninteresting(obj);

    final int maxBases = config.getDeltaSearchWindowSize();
    Set<RevTree> baseTrees = new HashSet<RevTree>();
    BlockList<RevCommit> commits = new BlockList<RevCommit>();
    RevCommit c;
    while ((c = walker.next()) != null) {
      if (exclude(c))
        continue;
      if (c.has(RevFlag.UNINTERESTING)) {
        if (baseTrees.size() <= maxBases)
          baseTrees.add(c.getTree());
        continue;
      }

      commits.add(c);
      countingMonitor.update(1);
    }

    if (shallowPack) {
      for (RevCommit cmit : commits) {
        addObject(cmit, 0);
      }
    } else {
      int commitCnt = 0;
      boolean putTagTargets = false;
      for (RevCommit cmit : commits) {
        if (!cmit.has(added)) {
          cmit.add(added);
          addObject(cmit, 0);
          commitCnt++;
        }

        for (int i = 0; i < cmit.getParentCount(); i++) {
          RevCommit p = cmit.getParent(i);
          if (!p.has(added) && !p.has(RevFlag.UNINTERESTING)
              && !exclude(p)) {
            p.add(added);
            addObject(p, 0);
            commitCnt++;
          }
        }

        if (!putTagTargets && 4096 < commitCnt) {
          for (ObjectId id : tagTargets) {
            RevObject obj = walker.lookupOrNull(id);
            if (obj instanceof RevCommit
                && obj.has(include)
                && !obj.has(RevFlag.UNINTERESTING)
                && !obj.has(added)) {
              obj.add(added);
              addObject(obj, 0);
            }
          }
          putTagTargets = true;
        }
      }
    }
    commits = null;

    if (thin && !baseTrees.isEmpty()) {
      BaseSearch bases = new BaseSearch(countingMonitor, baseTrees, //
          objectsMap, edgeObjects, reader);
      RevObject o;
      while ((o = walker.nextObject()) != null) {
        if (o.has(RevFlag.UNINTERESTING))
          continue;
        if (exclude(o))
          continue;

        int pathHash = walker.getPathHashCode();
        byte[] pathBuf = walker.getPathBuffer();
        int pathLen = walker.getPathLength();
        bases.addBase(o.getType(), pathBuf, pathLen, pathHash);
        addObject(o, pathHash);
        countingMonitor.update(1);
      }
    } else {
      RevObject o;
      while ((o = walker.nextObject()) != null) {
        if (o.has(RevFlag.UNINTERESTING))
          continue;
        if (exclude(o))
          continue;
        addObject(o, walker.getPathHashCode());
        countingMonitor.update(1);
View Full Code Here

    List<BitmapCommit> reuse = new ArrayList<BitmapCommit>();
    for (PackBitmapIndexRemapper.Entry entry : bitmapRemapper) {
      if ((entry.getFlags() & FLAG_REUSE) != FLAG_REUSE)
        continue;

      RevObject ro = rw.peel(rw.parseAny(entry));
      if (ro instanceof RevCommit) {
        RevCommit rc = (RevCommit) ro;
        reuse.add(new BitmapCommit(rc, false, entry.getFlags()));
        rw.markUninteresting(rc);

        EWAHCompressedBitmap bitmap = bitmapRemapper.ofObjectType(
            bitmapRemapper.getBitmap(rc), Constants.OBJ_COMMIT);
        writeBitmaps.addBitmap(rc, bitmap, 0);
        reuseBitmap.add(rc, Constants.OBJ_COMMIT);
      }
    }
    writeBitmaps.clearBitmaps(); // Remove temporary bitmaps

    // Do a RevWalk by commit time descending. Keep track of all the paths
    // from the wants.
    List<BitmapBuilder> paths = new ArrayList<BitmapBuilder>(want.size());
    Set<RevCommit> peeledWant = new HashSet<RevCommit>(want.size());
    for (AnyObjectId objectId : want) {
      RevObject ro = rw.peel(rw.parseAny(objectId));
      if (ro instanceof RevCommit && !reuseBitmap.contains(ro)) {
        RevCommit rc = (RevCommit) ro;
        peeledWant.add(rc);
        rw.markStart(rc);
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.revwalk.RevObject

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.