Package org.eclipse.jgit.revwalk

Examples of org.eclipse.jgit.revwalk.AsyncRevObjectQueue


      needMissing = true;
    }

    Set<RevObject> notAdvertisedWants = null;
    int haveCnt = 0;
    AsyncRevObjectQueue q = walk.parseAny(toParse, needMissing);
    try {
      for (;;) {
        RevObject obj;
        try {
          obj = q.next();
        } catch (MissingObjectException notFound) {
          ObjectId id = notFound.getObjectId();
          if (wantIds.contains(id)) {
            String msg = MessageFormat.format(
                JGitText.get().wantNotValid, id.name());
            throw new PackProtocolException(msg, notFound);
          }
          continue;
        }
        if (obj == null)
          break;

        // If the object is still found in wantIds, the want
        // list wasn't parsed earlier, and was done in this batch.
        //
        if (wantIds.remove(obj)) {
          if (!advertised.contains(obj) && requestPolicy != RequestPolicy.ANY) {
            if (notAdvertisedWants == null)
              notAdvertisedWants = new HashSet<RevObject>();
            notAdvertisedWants.add(obj);
          }

          if (!obj.has(WANT)) {
            obj.add(WANT);
            wantAll.add(obj);
          }

          if (!(obj instanceof RevCommit))
            obj.add(SATISFIED);

          if (obj instanceof RevTag) {
            RevObject target = walk.peel(obj);
            if (target instanceof RevCommit) {
              if (!target.has(WANT)) {
                target.add(WANT);
                wantAll.add(target);
              }
            }
          }

          if (!peerHasSet.contains(obj))
            continue;
        }

        last = obj;
        haveCnt++;

        if (obj instanceof RevCommit) {
          RevCommit c = (RevCommit) obj;
          if (oldestTime == 0 || c.getCommitTime() < oldestTime)
            oldestTime = c.getCommitTime();
        }

        if (obj.has(PEER_HAS))
          continue;

        obj.add(PEER_HAS);
        if (obj instanceof RevCommit)
          ((RevCommit) obj).carry(PEER_HAS);
        addCommonBase(obj);

        // If both sides have the same object; let the client know.
        //
        switch (multiAck) {
        case OFF:
          if (commonBase.size() == 1)
            pckOut.writeString("ACK " + obj.name() + "\n");
          break;
        case CONTINUE:
          pckOut.writeString("ACK " + obj.name() + " continue\n");
          break;
        case DETAILED:
          pckOut.writeString("ACK " + obj.name() + " common\n");
          break;
        }
      }
    } finally {
      q.release();
    }

    // If the client asked for non advertised object, check our policy.
    if (notAdvertisedWants != null && !notAdvertisedWants.isEmpty()) {
      switch (requestPolicy) {
View Full Code Here


    List<RevObject> wantObjs = new ArrayList<RevObject>(want.size());
    List<RevObject> haveObjs = new ArrayList<RevObject>(haveEst);
    List<RevTag> wantTags = new ArrayList<RevTag>(want.size());

    AsyncRevObjectQueue q = walker.parseAny(all, true);
    try {
      for (;;) {
        try {
          RevObject o = q.next();
          if (o == null)
            break;

          if (tipToPack.containsKey(o))
            o.add(inCachedPack);

          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;
View Full Code Here

    List<RevObject> wantObjs = new ArrayList<RevObject>(want.size());
    List<RevObject> haveObjs = new ArrayList<RevObject>(haveEst);
    List<RevTag> wantTags = new ArrayList<RevTag>(want.size());

    AsyncRevObjectQueue q = walker.parseAny(all, true);
    try {
      for (;;) {
        try {
          RevObject o = q.next();
          if (o == null)
            break;

          if (tipToPack.containsKey(o))
            o.add(inCachedPack);

          if (have.contains(o)) {
            haveObjs.add(o);
          } else 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();
      }
    }

    for (RevObject obj : wantObjs)
      walker.markStart(obj);
View Full Code Here

      toParse.addAll(peerHasSet);
      needMissing = true;
    }

    int haveCnt = 0;
    AsyncRevObjectQueue q = walk.parseAny(toParse, needMissing);
    try {
      for (;;) {
        RevObject obj;
        try {
          obj = q.next();
        } catch (MissingObjectException notFound) {
          ObjectId id = notFound.getObjectId();
          if (wantIds.contains(id)) {
            String msg = MessageFormat.format(
                JGitText.get().wantNotValid, id.name());
            pckOut.writeString("ERR " + msg);
            throw new PackProtocolException(msg, notFound);
          }
          continue;
        }
        if (obj == null)
          break;

        // If the object is still found in wantIds, the want
        // list wasn't parsed earlier, and was done in this batch.
        //
        if (wantIds.remove(obj)) {
          if (!advertised.contains(obj)) {
            String msg = MessageFormat.format(
                JGitText.get().wantNotValid, obj.name());
            pckOut.writeString("ERR " + msg);
            throw new PackProtocolException(msg);
          }

          if (!obj.has(WANT)) {
            obj.add(WANT);
            wantAll.add(obj);
          }

          if (!(obj instanceof RevCommit))
            obj.add(SATISFIED);

          if (obj instanceof RevTag) {
            RevObject target = walk.peel(obj);
            if (target instanceof RevCommit) {
              if (!target.has(WANT)) {
                target.add(WANT);
                wantAll.add(target);
              }
            }
          }

          if (!peerHasSet.contains(obj))
            continue;
        }

        last = obj;
        haveCnt++;

        if (obj instanceof RevCommit) {
          RevCommit c = (RevCommit) obj;
          if (oldestTime == 0 || c.getCommitTime() < oldestTime)
            oldestTime = c.getCommitTime();
        }

        if (obj.has(PEER_HAS))
          continue;

        obj.add(PEER_HAS);
        if (obj instanceof RevCommit)
          ((RevCommit) obj).carry(PEER_HAS);
        addCommonBase(obj);

        // If both sides have the same object; let the client know.
        //
        switch (multiAck) {
        case OFF:
          if (commonBase.size() == 1)
            pckOut.writeString("ACK " + obj.name() + "\n");
          break;
        case CONTINUE:
          pckOut.writeString("ACK " + obj.name() + " continue\n");
          break;
        case DETAILED:
          pckOut.writeString("ACK " + obj.name() + " common\n");
          break;
        }
      }
    } finally {
      q.release();
    }
    int missCnt = peerHas.size() - haveCnt;

    // If we don't have one of the objects but we're also willing to
    // create a pack at this point, let the client know so it stops
View Full Code Here

      needMissing = true;
    }

    Set<RevObject> notAdvertisedWants = null;
    int haveCnt = 0;
    AsyncRevObjectQueue q = walk.parseAny(toParse, needMissing);
    try {
      for (;;) {
        RevObject obj;
        try {
          obj = q.next();
        } catch (MissingObjectException notFound) {
          ObjectId id = notFound.getObjectId();
          if (wantIds.contains(id)) {
            String msg = MessageFormat.format(
                JGitText.get().wantNotValid, id.name());
            throw new PackProtocolException(msg, notFound);
          }
          continue;
        }
        if (obj == null)
          break;

        // If the object is still found in wantIds, the want
        // list wasn't parsed earlier, and was done in this batch.
        //
        if (wantIds.remove(obj)) {
          if (!advertised.contains(obj) && requestPolicy != RequestPolicy.ANY) {
            if (notAdvertisedWants == null)
              notAdvertisedWants = new HashSet<RevObject>();
            notAdvertisedWants.add(obj);
          }

          if (!obj.has(WANT)) {
            obj.add(WANT);
            wantAll.add(obj);
          }

          if (!(obj instanceof RevCommit))
            obj.add(SATISFIED);

          if (obj instanceof RevTag) {
            RevObject target = walk.peel(obj);
            if (target instanceof RevCommit) {
              if (!target.has(WANT)) {
                target.add(WANT);
                wantAll.add(target);
              }
            }
          }

          if (!peerHasSet.contains(obj))
            continue;
        }

        last = obj;
        haveCnt++;

        if (obj instanceof RevCommit) {
          RevCommit c = (RevCommit) obj;
          if (oldestTime == 0 || c.getCommitTime() < oldestTime)
            oldestTime = c.getCommitTime();
        }

        if (obj.has(PEER_HAS))
          continue;

        obj.add(PEER_HAS);
        if (obj instanceof RevCommit)
          ((RevCommit) obj).carry(PEER_HAS);
        addCommonBase(obj);

        // If both sides have the same object; let the client know.
        //
        switch (multiAck) {
        case OFF:
          if (commonBase.size() == 1)
            pckOut.writeString("ACK " + obj.name() + "\n");
          break;
        case CONTINUE:
          pckOut.writeString("ACK " + obj.name() + " continue\n");
          break;
        case DETAILED:
          pckOut.writeString("ACK " + obj.name() + " common\n");
          break;
        }
      }
    } finally {
      q.release();
    }

    // If the client asked for non advertised object, check our policy.
    if (notAdvertisedWants != null && !notAdvertisedWants.isEmpty()) {
      switch (requestPolicy) {
View Full Code Here

    }

    if (wantIds.isEmpty())
      return;

    AsyncRevObjectQueue q = walk.parseAny(wantIds, true);
    try {
      for (;;) {
        RevObject o;
        try {
          o = q.next();
        } catch (IOException error) {
          throw new PackProtocolException(MessageFormat.format(
              JGitText.get().notValid, error.getMessage()), error);
        }
        if (o == null)
          break;
        if (o.has(WANT)) {
          // Already processed, the client repeated itself.

        } else if (advertised.contains(o)) {
          o.add(WANT);
          wantAll.add(o);

          if (o instanceof RevTag) {
            o = walk.peel(o);
            if (o instanceof RevCommit) {
              if (!o.has(WANT)) {
                o.add(WANT);
                wantAll.add(o);
              }
            }
          }
        } else {
          throw new PackProtocolException(MessageFormat.format(
              JGitText.get().notValid, o.name()));
        }
      }
    } finally {
      q.release();
    }
  }
View Full Code Here

    if (peerHas.isEmpty())
      return last;

    // If both sides have the same object; let the client know.
    //
    AsyncRevObjectQueue q = walk.parseAny(peerHas, false);
    try {
      for (;;) {
        RevObject obj;
        try {
          obj = q.next();
        } catch (MissingObjectException notFound) {
          continue;
        }
        if (obj == null)
          break;

        last = obj;
        if (obj.has(PEER_HAS))
          continue;

        obj.add(PEER_HAS);
        if (obj instanceof RevCommit)
          ((RevCommit) obj).carry(PEER_HAS);
        addCommonBase(obj);

        switch (multiAck) {
        case OFF:
          if (commonBase.size() == 1)
            pckOut.writeString("ACK " + obj.name() + "\n");
          break;
        case CONTINUE:
          pckOut.writeString("ACK " + obj.name() + " continue\n");
          break;
        case DETAILED:
          pckOut.writeString("ACK " + obj.name() + " common\n");
          break;
        }
      }
    } finally {
      q.release();
    }

    // If we don't have one of the objects but we're also willing to
    // create a pack at this point, let the client know so it stops
    // telling us about its history.
View Full Code Here

    }

    List<RevObject> wantObjs = new ArrayList<RevObject>(want.size());
    List<RevObject> haveObjs = new ArrayList<RevObject>(haveEst);

    AsyncRevObjectQueue q = walker.parseAny(all, true);
    try {
      for (;;) {
        try {
          RevObject o = q.next();
          if (o == null)
            break;

          if (tipToPack.containsKey(o))
            o.add(inCachedPack);

          if (have.contains(o)) {
            haveObjs.add(o);
            walker.markUninteresting(o);
          } else if (want.contains(o)) {
            o.add(include);
            wantObjs.add(o);
            walker.markStart(o);
          }
        } catch (MissingObjectException e) {
          if (ignoreMissingUninteresting
              && have.contains(e.getObjectId()))
            continue;
          throw e;
        }
      }
    } finally {
      q.release();
    }

    int typesToPrune = 0;
    final int maxBases = config.getDeltaSearchWindowSize();
    Set<RevTree> baseTrees = new HashSet<RevTree>();
View Full Code Here

      toParse.addAll(peerHasSet);
      needMissing = true;
    }

    int haveCnt = 0;
    AsyncRevObjectQueue q = walk.parseAny(toParse, needMissing);
    try {
      for (;;) {
        RevObject obj;
        try {
          obj = q.next();
        } catch (MissingObjectException notFound) {
          ObjectId id = notFound.getObjectId();
          if (wantIds.contains(id)) {
            String msg = MessageFormat.format(
                JGitText.get().wantNotValid, id.name());
            pckOut.writeString("ERR " + msg);
            throw new PackProtocolException(msg, notFound);
          }
          continue;
        }
        if (obj == null)
          break;

        // If the object is still found in wantIds, the want
        // list wasn't parsed earlier, and was done in this batch.
        //
        if (wantIds.remove(obj)) {
          if (!advertised.contains(obj)) {
            String msg = MessageFormat.format(
                JGitText.get().wantNotValid, obj.name());
            pckOut.writeString("ERR " + msg);
            throw new PackProtocolException(msg);
          }

          if (!obj.has(WANT)) {
            obj.add(WANT);
            wantAll.add(obj);
          }

          if (!(obj instanceof RevCommit))
            obj.add(SATISFIED);

          if (obj instanceof RevTag) {
            RevObject target = walk.peel(obj);
            if (target instanceof RevCommit) {
              if (!target.has(WANT)) {
                target.add(WANT);
                wantAll.add(target);
              }
            }
          }

          if (!peerHasSet.contains(obj))
            continue;
        }

        last = obj;
        haveCnt++;

        if (obj instanceof RevCommit) {
          RevCommit c = (RevCommit) obj;
          if (oldestTime == 0 || c.getCommitTime() < oldestTime)
            oldestTime = c.getCommitTime();
        }

        if (obj.has(PEER_HAS))
          continue;

        obj.add(PEER_HAS);
        if (obj instanceof RevCommit)
          ((RevCommit) obj).carry(PEER_HAS);
        addCommonBase(obj);

        // If both sides have the same object; let the client know.
        //
        switch (multiAck) {
        case OFF:
          if (commonBase.size() == 1)
            pckOut.writeString("ACK " + obj.name() + "\n");
          break;
        case CONTINUE:
          pckOut.writeString("ACK " + obj.name() + " continue\n");
          break;
        case DETAILED:
          pckOut.writeString("ACK " + obj.name() + " common\n");
          break;
        }
      }
    } finally {
      q.release();
    }
    int missCnt = peerHas.size() - haveCnt;

    // If we don't have one of the objects but we're also willing to
    // create a pack at this point, let the client know so it stops
View Full Code Here

      return last;

    sentReady = false;
    int haveCnt = 0;
    walk.getObjectReader().setAvoidUnreachableObjects(true);
    AsyncRevObjectQueue q = walk.parseAny(peerHas, false);
    try {
      for (;;) {
        RevObject obj;
        try {
          obj = q.next();
        } catch (MissingObjectException notFound) {
          continue;
        }
        if (obj == null)
          break;

        last = obj;
        haveCnt++;

        if (obj instanceof RevCommit) {
          RevCommit c = (RevCommit) obj;
          if (oldestTime == 0 || c.getCommitTime() < oldestTime)
            oldestTime = c.getCommitTime();
        }

        if (obj.has(PEER_HAS))
          continue;

        obj.add(PEER_HAS);
        if (obj instanceof RevCommit)
          ((RevCommit) obj).carry(PEER_HAS);
        addCommonBase(obj);

        // If both sides have the same object; let the client know.
        //
        switch (multiAck) {
        case OFF:
          if (commonBase.size() == 1)
            pckOut.writeString("ACK " + obj.name() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
          break;
        case CONTINUE:
          pckOut.writeString("ACK " + obj.name() + " continue\n"); //$NON-NLS-1$ //$NON-NLS-2$
          break;
        case DETAILED:
          pckOut.writeString("ACK " + obj.name() + " common\n"); //$NON-NLS-1$ //$NON-NLS-2$
          break;
        }
      }
    } finally {
      q.release();
      walk.getObjectReader().setAvoidUnreachableObjects(false);
    }

    int missCnt = peerHas.size() - haveCnt;
View Full Code Here

TOP

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

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.