Package org.eclipse.jgit.revwalk

Examples of org.eclipse.jgit.revwalk.ObjectWalk


      baseObjects = parser.getBaseObjectIds();
      providedObjects = parser.getNewObjectIds();
    }
    parser = null;

    final ObjectWalk ow = new ObjectWalk(db);
    ow.setRetainBody(false);
    if (checkReferencedIsReachable) {
      ow.sort(RevSort.TOPO);
      if (!baseObjects.isEmpty())
        ow.sort(RevSort.BOUNDARY, true);
    }

    for (final ReceiveCommand cmd : commands) {
      if (cmd.getResult() != Result.NOT_ATTEMPTED)
        continue;
      if (cmd.getType() == ReceiveCommand.Type.DELETE)
        continue;
      ow.markStart(ow.parseAny(cmd.getNewId()));
    }
    for (final ObjectId have : advertisedHaves) {
      RevObject o = ow.parseAny(have);
      ow.markUninteresting(o);

      if (checkReferencedIsReachable && !baseObjects.isEmpty()) {
        o = ow.peel(o);
        if (o instanceof RevCommit)
          o = ((RevCommit) o).getTree();
        if (o instanceof RevTree)
          ow.markUninteresting(o);
      }
    }

    RevCommit c;
    while ((c = ow.next()) != null) {
      if (checkReferencedIsReachable //
          && !c.has(RevFlag.UNINTERESTING) //
          && !providedObjects.contains(c))
        throw new MissingObjectException(c, Constants.TYPE_COMMIT);
    }

    RevObject o;
    while ((o = ow.nextObject()) != null) {
      if (o.has(RevFlag.UNINTERESTING))
        continue;

      if (checkReferencedIsReachable) {
        if (providedObjects.contains(o))
          continue;
        else
          throw new MissingObjectException(o, o.getType());
      }

      if (o instanceof RevBlob && !db.hasObject(o))
        throw new MissingObjectException(o, Constants.TYPE_BLOB);
    }

    if (checkReferencedIsReachable) {
      for (ObjectId id : baseObjects) {
        o = ow.parseAny(id);
        if (!o.has(RevFlag.UNINTERESTING))
          throw new MissingObjectException(o, o.getType());
      }
    }
  }
View Full Code Here


      if (wantAll.isEmpty()) {
        pw.preparePack(pm, wantIds, commonBase);
      } else {
        walk.reset();

        ObjectWalk ow = walk.toObjectWalkWithSameObjects();
        pw.preparePack(pm, ow, wantAll, commonBase);
        rw = ow;
      }

      if (options.contains(OPTION_INCLUDE_TAG) && refs != null) {
View Full Code Here

    }
  }

  private boolean askForIsComplete() throws TransportException {
    try {
      final ObjectWalk ow = new ObjectWalk(transport.local);
      try {
        for (final ObjectId want : askFor.keySet())
          ow.markStart(ow.parseAny(want));
        for (final Ref ref : transport.local.getAllRefs().values())
          ow.markUninteresting(ow.parseAny(ref.getObjectId()));
        ow.checkConnectivity();
      } finally {
        ow.release();
      }
      return true;
    } catch (MissingObjectException e) {
      return false;
    } catch (IOException e) {
View Full Code Here

   *             when some I/O problem occur during reading objects.
   */
  public void preparePack(ProgressMonitor countingMonitor,
      Set<? extends ObjectId> want,
      Set<? extends ObjectId> have) throws IOException {
    ObjectWalk ow;
    if (shallowPack)
      ow = new DepthWalk.ObjectWalk(reader, depth);
    else
      ow = new ObjectWalk(reader);
    preparePack(countingMonitor, ow, want, have);
  }
View Full Code Here

      baseObjects = parser.getBaseObjectIds();
      providedObjects = parser.getNewObjectIds();
    }
    parser = null;

    final ObjectWalk ow = new ObjectWalk(db);
    ow.setRetainBody(false);
    if (checkReferencedIsReachable) {
      ow.sort(RevSort.TOPO);
      if (!baseObjects.isEmpty())
        ow.sort(RevSort.BOUNDARY, true);
    }

    for (final ReceiveCommand cmd : commands) {
      if (cmd.getResult() != Result.NOT_ATTEMPTED)
        continue;
      if (cmd.getType() == ReceiveCommand.Type.DELETE)
        continue;
      ow.markStart(ow.parseAny(cmd.getNewId()));
    }
    for (final ObjectId have : advertisedHaves) {
      RevObject o = ow.parseAny(have);
      ow.markUninteresting(o);

      if (checkReferencedIsReachable && !baseObjects.isEmpty()) {
        o = ow.peel(o);
        if (o instanceof RevCommit)
          o = ((RevCommit) o).getTree();
        if (o instanceof RevTree)
          ow.markUninteresting(o);
      }
    }

    RevCommit c;
    while ((c = ow.next()) != null) {
      if (checkReferencedIsReachable //
          && !c.has(RevFlag.UNINTERESTING) //
          && !providedObjects.contains(c))
        throw new MissingObjectException(c, Constants.TYPE_COMMIT);
    }

    RevObject o;
    while ((o = ow.nextObject()) != null) {
      if (o.has(RevFlag.UNINTERESTING))
        continue;

      if (checkReferencedIsReachable) {
        if (providedObjects.contains(o))
          continue;
        else
          throw new MissingObjectException(o, o.getType());
      }

      if (o instanceof RevBlob && !db.hasObject(o))
        throw new MissingObjectException(o, Constants.TYPE_BLOB);
    }

    if (checkReferencedIsReachable) {
      for (ObjectId id : baseObjects) {
        o = ow.parseAny(id);
        if (!o.has(RevFlag.UNINTERESTING))
          throw new MissingObjectException(o, o.getType());
      }
    }
  }
View Full Code Here

   *             when some I/O problem occur during reading objects.
   */
  public void preparePack(ProgressMonitor countingMonitor,
      final Collection<? extends ObjectId> want,
      final Collection<? extends ObjectId> have) throws IOException {
    ObjectWalk ow = new ObjectWalk(reader);
    preparePack(countingMonitor, ow, want, have);
  }
View Full Code Here

    }
  }

  private boolean askForIsComplete() throws TransportException {
    try {
      final ObjectWalk ow = new ObjectWalk(transport.local);
      try {
        for (final ObjectId want : askFor.keySet())
          ow.markStart(ow.parseAny(want));
        for (final Ref ref : transport.local.getAllRefs().values())
          ow.markUninteresting(ow.parseAny(ref.getObjectId()));
        ow.checkConnectivity();
      } finally {
        ow.release();
      }
      return true;
    } catch (MissingObjectException e) {
      return false;
    } catch (IOException e) {
View Full Code Here

      if (wantAll.isEmpty()) {
        pw.preparePack(pm, wantIds, commonBase);
      } else {
        walk.reset();

        ObjectWalk ow = walk.toObjectWalkWithSameObjects();
        pw.preparePack(pm, ow, wantAll, commonBase);
        rw = ow;
      }

      if (options.contains(OPTION_INCLUDE_TAG)) {
View Full Code Here

      // There are new/modified refs! Check which loose objects are now
      // referenced by these modified refs (or their reflogentries).
      // Remove these loose objects
      // from the deletionCandidates. When the last candidate is removed
      // leave this method.
      ObjectWalk w = new ObjectWalk(repo);
      try {
        for (Ref cr : newRefs.values())
          w.markStart(w.parseAny(cr.getObjectId()));
        if (lastPackedRefs != null)
          for (Ref lpr : lastPackedRefs.values())
            w.markUninteresting(w.parseAny(lpr.getObjectId()));
        removeReferenced(deletionCandidates, w);
      } finally {
        w.dispose();
      }
    }

    if (deletionCandidates.isEmpty())
      return;

    // Since we have not left the method yet there are still
    // deletionCandidates. Last chance for these objects not to be pruned is
    // that they are referenced by reflog entries. Even refs which currently
    // point to the same object as during last repack() may have
    // additional reflog entries not handled during last repack()
    ObjectWalk w = new ObjectWalk(repo);
    try {
      for (Ref ar : getAllRefs().values())
        for (ObjectId id : listRefLogObjects(ar, lastRepackTime))
          w.markStart(w.parseAny(id));
      if (lastPackedRefs != null)
        for (Ref lpr : lastPackedRefs.values())
          w.markUninteresting(w.parseAny(lpr.getObjectId()));
      removeReferenced(deletionCandidates, w);
    } finally {
      w.dispose();
    }

    if (deletionCandidates.isEmpty())
      return;
View Full Code Here

  }

  private RevWalk verifyConnected(final Repository repo, final ObjectId revid)
      throws InvalidRevisionException {
    try {
      final ObjectWalk rw = new ObjectWalk(repo);
      try {
        rw.markStart(rw.parseCommit(revid));
      } catch (IncorrectObjectTypeException err) {
        throw new InvalidRevisionException();
      }
      for (final Ref r : repo.getAllRefs().values()) {
        try {
          rw.markUninteresting(rw.parseAny(r.getObjectId()));
        } catch (MissingObjectException err) {
          continue;
        }
      }
      rw.checkConnectivity();
      return rw;
    } catch (IncorrectObjectTypeException err) {
      throw new InvalidRevisionException();
    } catch (MissingObjectException err) {
      throw new InvalidRevisionException();
View Full Code Here

TOP

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

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.