Examples of RevObject


Examples of org.eclipse.jgit.revwalk.RevObject

      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 (baseObjects != null && !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 (providedObjects != null //
          && !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 (providedObjects != null) {
        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 (baseObjects != null) {
      for (ObjectId id : baseObjects) {
        o = ow.parseAny(id);
        if (!o.has(RevFlag.UNINTERESTING))
          throw new MissingObjectException(o, o.getType());
      }
    }
  }
View Full Code Here

Examples of org.eclipse.jgit.revwalk.RevObject

          continue;
        }

        // Is this possibly a non-fast-forward style update?
        //
        RevObject oldObj, newObj;
        try {
          oldObj = walk.parseAny(cmd.getOldId());
        } catch (IOException e) {
          cmd.setResult(Result.REJECTED_MISSING_OBJECT, cmd
              .getOldId().name());
View Full Code Here

Examples of org.eclipse.jgit.revwalk.RevObject

    }
  }

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

    if (getRefDatabase().isNameConflicting(getName()))
      return Result.LOCK_FAILURE;
    try {
      if (!tryLock(true))
View Full Code Here

Examples of org.eclipse.jgit.revwalk.RevObject

    }
  }

  private ObjectId resolve(final RevWalk rw, final String revstr) throws IOException {
    char[] rev = revstr.toCharArray();
    RevObject ref = null;
    for (int i = 0; i < rev.length; ++i) {
      switch (rev[i]) {
      case '^':
        if (ref == null) {
          ref = parseSimple(rw, new String(rev, 0, i));
          if (ref == null)
            return null;
        }
        if (i + 1 < rev.length) {
          switch (rev[i + 1]) {
          case '0':
          case '1':
          case '2':
          case '3':
          case '4':
          case '5':
          case '6':
          case '7':
          case '8':
          case '9':
            int j;
            ref = rw.parseCommit(ref);
            for (j = i + 1; j < rev.length; ++j) {
              if (!Character.isDigit(rev[j]))
                break;
            }
            String parentnum = new String(rev, i + 1, j - i - 1);
            int pnum;
            try {
              pnum = Integer.parseInt(parentnum);
            } catch (NumberFormatException e) {
              throw new RevisionSyntaxException(
                  JGitText.get().invalidCommitParentNumber,
                  revstr);
            }
            if (pnum != 0) {
              RevCommit commit = (RevCommit) ref;
              if (pnum > commit.getParentCount())
                ref = null;
              else
                ref = commit.getParent(pnum - 1);
            }
            i = j - 1;
            break;
          case '{':
            int k;
            String item = null;
            for (k = i + 2; k < rev.length; ++k) {
              if (rev[k] == '}') {
                item = new String(rev, i + 2, k - i - 2);
                break;
              }
            }
            i = k;
            if (item != null)
              if (item.equals("tree")) {
                ref = rw.parseTree(ref);
              } else if (item.equals("commit")) {
                ref = rw.parseCommit(ref);
              } else if (item.equals("blob")) {
                ref = rw.peel(ref);
                if (!(ref instanceof RevBlob))
                  throw new IncorrectObjectTypeException(ref,
                      Constants.TYPE_BLOB);
              } else if (item.equals("")) {
                ref = rw.peel(ref);
              } else
                throw new RevisionSyntaxException(revstr);
            else
              throw new RevisionSyntaxException(revstr);
            break;
          default:
            ref = rw.parseAny(ref);
            if (ref instanceof RevCommit) {
              RevCommit commit = ((RevCommit) ref);
              if (commit.getParentCount() == 0)
                ref = null;
              else
                ref = commit.getParent(0);
            } else
              throw new IncorrectObjectTypeException(ref,
                  Constants.TYPE_COMMIT);

          }
        } else {
          ref = rw.peel(ref);
          if (ref instanceof RevCommit) {
            RevCommit commit = ((RevCommit) ref);
            if (commit.getParentCount() == 0)
              ref = null;
            else
              ref = commit.getParent(0);
          } else
            throw new IncorrectObjectTypeException(ref,
                Constants.TYPE_COMMIT);
        }
        break;
      case '~':
        if (ref == null) {
          ref = parseSimple(rw, new String(rev, 0, i));
          if (ref == null)
            return null;
        }
        ref = rw.peel(ref);
        if (!(ref instanceof RevCommit))
          throw new IncorrectObjectTypeException(ref,
              Constants.TYPE_COMMIT);
        int l;
        for (l = i + 1; l < rev.length; ++l) {
          if (!Character.isDigit(rev[l]))
            break;
        }
        String distnum = new String(rev, i + 1, l - i - 1);
        int dist;
        try {
          dist = Integer.parseInt(distnum);
        } catch (NumberFormatException e) {
          throw new RevisionSyntaxException(
              JGitText.get().invalidAncestryLength, revstr);
        }
        while (dist > 0) {
          RevCommit commit = (RevCommit) ref;
          if (commit.getParentCount() == 0) {
            ref = null;
            break;
          }
          commit = commit.getParent(0);
          rw.parseHeaders(commit);
          ref = commit;
          --dist;
        }
        i = l - 1;
        break;
      case '@':
        int m;
        String time = null;
        for (m = i + 2; m < rev.length; ++m) {
          if (rev[m] == '}') {
            time = new String(rev, i + 2, m - i - 2);
            break;
          }
        }
        if (time != null)
          throw new RevisionSyntaxException(
              JGitText.get().reflogsNotYetSupportedByRevisionParser,
              revstr);
        i = m - 1;
        break;
      case '-':
        if (i + 4 < rev.length && rev[i + 1] == 'g'
            && isHex(rev[i + 2]) && isHex(rev[i + 3])) {
          // Possibly output from git describe?
          // Resolve longest valid abbreviation.
          int cnt = 2;
          while (i + 2 + cnt < rev.length && isHex(rev[i + 2 + cnt]))
            cnt++;
          String s = new String(rev, i + 2, cnt);
          if (AbbreviatedObjectId.isId(s)) {
            ObjectId id = resolveAbbreviation(s);
            if (id != null) {
              ref = rw.parseAny(id);
              i += 1 + s.length();
            }
          }
        }
        break;
      case ':': {
        RevTree tree;
        if (ref == null) {
          // We might not yet have parsed the left hand side.
          ObjectId id;
          try {
            if (i == 0)
              id = resolve(rw, Constants.HEAD);
            else
              id = resolve(rw, new String(rev, 0, i));
          } catch (RevisionSyntaxException badSyntax) {
            throw new RevisionSyntaxException(revstr);
          }
          if (id == null)
            return null;
          tree = rw.parseTree(id);
        } else {
          tree = rw.parseTree(ref);
        }

        if (i == rev.length - i)
          return tree.copy();

        TreeWalk tw = TreeWalk.forPath(rw.getObjectReader(),
            new String(rev, i + 1, rev.length - i - 1), tree);
        return tw != null ? tw.getObjectId(0) : null;
      }

      default:
        if (ref != null)
          throw new RevisionSyntaxException(revstr);
      }
    }
    return ref != null ? ref.copy() : resolveSimple(revstr);
  }
View Full Code Here

Examples of org.eclipse.jgit.revwalk.RevObject

  private ObjectIdRef doPeel(final Ref leaf) throws MissingObjectException,
      IOException {
    RevWalk rw = new RevWalk(getRepository());
    try {
      RevObject obj = rw.parseAny(leaf.getObjectId());
      if (obj instanceof RevTag) {
        return new ObjectIdRef.PeeledTag(leaf.getStorage(), leaf
            .getName(), leaf.getObjectId(), rw.peel(obj).copy());
      } else {
        return new ObjectIdRef.PeeledNonTag(leaf.getStorage(), leaf
View Full Code Here

Examples of org.eclipse.jgit.revwalk.RevObject

  private int maxTimeWanted(final Collection<Ref> wants) {
    int maxTime = 0;
    for (final Ref r : wants) {
      try {
        final RevObject obj = walk.parseAny(r.getObjectId());
        if (obj instanceof RevCommit) {
          final int cTime = ((RevCommit) obj).getCommitTime();
          if (maxTime < cTime)
            maxTime = cTime;
        }
View Full Code Here

Examples of org.eclipse.jgit.revwalk.RevObject

      // - both old and new ref must point to commits, AND
      // - both of them must be known for us, exist in repository, AND
      // - old commit must be ancestor of new commit
      boolean fastForward = true;
      try {
        RevObject oldRev = walker.parseAny(advertisedOld);
        final RevObject newRev = walker.parseAny(rru.getNewObjectId());
        if (!(oldRev instanceof RevCommit)
            || !(newRev instanceof RevCommit)
            || !walker.isMergedInto((RevCommit) oldRev,
                (RevCommit) newRev))
          fastForward = false;
View Full Code Here

Examples of org.eclipse.jgit.revwalk.RevObject

      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

Examples of org.eclipse.jgit.revwalk.RevObject

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

Examples of org.eclipse.jgit.revwalk.RevObject

      pw.setDeltaBaseAsOffset(options.contains(OPTION_OFS_DELTA));
      pw.setThin(options.contains(OPTION_THIN_PACK));
      pw.preparePack(pm, wantAll, commonBase);
      if (options.contains(OPTION_INCLUDE_TAG)) {
        for (final Ref r : refs.values()) {
          final RevObject o;
          try {
            o = walk.parseAny(r.getObjectId());
          } catch (IOException e) {
            continue;
          }
          if (o.has(WANT) || !(o instanceof RevTag))
            continue;
          final RevTag t = (RevTag) o;
          if (!pw.willInclude(t) && pw.willInclude(t.getObject()))
            pw.addObject(t);
        }
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.