Package com.google.gerrit.reviewdb.client

Examples of com.google.gerrit.reviewdb.client.PatchSet


      CreateCodeReviewNotes notes = codeReviewNotesFactory.create(db, git);
      try {
        notes.loadBase();
        for (Change change : changes) {
          monitor.update(1);
          PatchSet ps = db.patchSets().get(change.currentPatchSetId());
          if (ps == null) {
            continue;
          }
          notes.add(change, ObjectId.fromString(ps.getRevision().get()));
        }
        notes.commit("Exported prior reviews from Gerrit Code Review\n");
        notes.updateRef();
      } finally {
        notes.release();
View Full Code Here


      git = gitManager.openRepository(project);
    } catch (IOException e) {
      return;
    }
    try {
      PatchSet ps = db.patchSets().get(change.currentPatchSetId());
      if (ps == null || ps.getRevision() == null
          || ps.getRevision().get() == null) {
        return;
      }
      ChangeUtil.updateTrackingIds(db, change, footers, parse(git, ps)
          .getFooterLines());
    } catch (OrmException error) {
View Full Code Here

    if (commit.patchsetId == null) {
      try {
        List<PatchSet> matches =
            db.patchSets().byRevision(new RevId(commit.name())).toList();
        if (matches.size() == 1) {
          final PatchSet ps = matches.get(0);
          commit.patchsetId = ps.getId();
          commit.change = db.changes().get(ps.getId().getParentKey());
        }
      } catch (OrmException e) {
      }
    }
  }
View Full Code Here

    final PatchSetApproval from = submitter;
    workQueue.getDefaultQueue()
        .submit(requestScopePropagator.wrap(new Runnable() {
      @Override
      public void run() {
        PatchSet patchSet;
        try {
          ReviewDb reviewDb = schemaFactory.open();
          try {
            patchSet = reviewDb.patchSets().get(c.currentPatchSetId());
          } finally {
View Full Code Here

    workQueue.getDefaultQueue()
        .submit(requestScopePropagator.wrap(new Runnable() {
      @Override
      public void run() {
        PatchSet patchSet;
        PatchSetApproval submitter;
        try {
          ReviewDb reviewDb = schemaFactory.open();
          try {
            patchSet = reviewDb.patchSets().get(c.currentPatchSetId());
View Full Code Here

        commits.put(changeId, CodeReviewCommit
            .error(CommitMergeStatus.NO_PATCH_SET));
        continue;
      }

      final PatchSet ps;
      try {
        ps = db.patchSets().get(chg.currentPatchSetId());
      } catch (OrmException e) {
        throw new MergeException("Cannot query the database", e);
      }
      if (ps == null || ps.getRevision() == null
          || ps.getRevision().get() == null) {
        commits.put(changeId, CodeReviewCommit
            .error(CommitMergeStatus.NO_PATCH_SET));
        continue;
      }

      final String idstr = ps.getRevision().get();
      final ObjectId id;
      try {
        id = ObjectId.fromString(idstr);
      } catch (IllegalArgumentException iae) {
        commits.put(changeId, CodeReviewCommit
            .error(CommitMergeStatus.NO_PATCH_SET));
        continue;
      }

      if (!tips.contains(id)) {
        // TODO Technically the proper way to do this test is to use a
        // RevWalk on "$id --not --all" and test for an empty set. But
        // that is way slower than looking for a ref directly pointing
        // at the desired tip. We should always have a ref available.
        //
        // TODO this is actually an error, the branch is gone but we
        // want to merge the issue. We can't safely do that if the
        // tip is not reachable.
        //
        commits.put(changeId, CodeReviewCommit
            .error(CommitMergeStatus.REVISION_GONE));
        continue;
      }

      final CodeReviewCommit commit;
      try {
        commit = (CodeReviewCommit) rw.parseCommit(id);
      } catch (IOException e) {
        log.error("Invalid commit " + id.name() + " on " + chg.getKey(), e);
        commits.put(changeId, CodeReviewCommit
            .error(CommitMergeStatus.REVISION_GONE));
        continue;
      }

      commit.change = chg;
      commit.patchsetId = ps.getId();
      commit.originalOrder = commitOrder++;
      commits.put(changeId, commit);

      if (branchTip != null) {
        // If this commit is already merged its a bug in the queuing code
View Full Code Here

                change.nextPatchSetId();
                return change;
              }
            });

    final PatchSet ps = new PatchSet(n.change.currPatchSetId());
    ps.setCreatedOn(new Timestamp(System.currentTimeMillis()));
    ps.setUploader(submitAudit.getAccountId());
    ps.setRevision(new RevId(id.getName()));
    insertAncestors(ps.getId(), newCommit);
    db.patchSets().insert(Collections.singleton(ps));

    n.change =
        db.changes().atomicUpdate(n.change.getId(),
            new AtomicUpdate<Change>() {
              @Override
              public Change update(Change change) {
                change.setCurrentPatchSet(patchSetInfoFactory.get(newCommit,
                    ps.getId()));
                return change;
              }
            });

    this.submitted.remove(oldChange);
    this.submitted.add(n.change);

    if (approvalList != null) {
      for (PatchSetApproval a : approvalList) {
        db.patchSetApprovals().insert(
            Collections.singleton(new PatchSetApproval(ps.getId(), a)));
      }
    }

    newCommit.copyFrom(n);
    newCommit.statusCode = CommitMergeStatus.CLEAN_PICK;
View Full Code Here

                  includeApprovals ? d.approvalsMap(db) : null);
            }
          }

          if (includeCurrentPatchSet) {
            PatchSet current = d.currentPatchSet(db);
            if (current != null) {
              c.currentPatchSet = eventFactory.asPatchSetAttribute(current);
              eventFactory.addApprovals(c.currentPatchSet, //
                  d.currentApprovals(db));
View Full Code Here

      throws OrmException, NoSuchChangeException {
    if (!changeId.equals(psId.getParentKey())) {
      throw new NoSuchChangeException(changeId);
    }

    final PatchSet ps = db.patchSets().get(psId);
    if (ps == null || ps.getRevision() == null
        || ps.getRevision().get() == null) {
      throw new NoSuchChangeException(changeId);
    }

    try {
      return ObjectId.fromString(ps.getRevision().get());
    } catch (IllegalArgumentException e) {
      log.error("Patch set " + psId + " has invalid revision");
      throw new NoSuchChangeException(changeId, e);
    }
  }
View Full Code Here

    reviewers.remove(me);
    cc.remove(me);
    cc.removeAll(reviewers);

    final Change change;
    final PatchSet ps;
    final PatchSetInfo info;

    change = new Change(changeKey, new Change.Id(db.nextChangeId()), me, destBranch);
    change.setTopic(destTopicName);
    change.nextPatchSetId();

    db.changes().beginTransaction(change.getId());
    try {
      ps = new PatchSet(change.currPatchSetId());
      ps.setCreatedOn(change.getCreatedOn());
      ps.setUploader(me);
      ps.setRevision(toRevId(c));
      if (MagicBranch.isDraft(newChange.getRefName())) {
        change.setStatus(Change.Status.DRAFT);
        ps.setDraft(true);
      }
      insertAncestors(ps.getId(), c);
      db.patchSets().insert(Collections.singleton(ps));

      info = patchSetInfoFactory.get(c, ps.getId());
      change.setCurrentPatchSet(info);
      ChangeUtil.updated(change);
      db.changes().insert(Collections.singleton(change));
      ChangeUtil.updateTrackingIds(db, change, trackingFooters, footerLines);
      approvalsUtil.addReviewers(change, ps, info, reviewers);
      db.commit();
    } finally {
      db.rollback();
    }

    final RefUpdate ru = repo.updateRef(ps.getRefName());
    ru.setNewObjectId(c);
    ru.disableRefLog();
    if (ru.update(walk) != RefUpdate.Result.NEW) {
      throw new IOException("Failed to create ref " + ps.getRefName() + " in "
          + repo.getDirectory() + ": " + ru.getResult());
    }
    replication.fire(project.getNameKey(), ru.getName());

    allNewChanges.add(change);
View Full Code Here

TOP

Related Classes of com.google.gerrit.reviewdb.client.PatchSet

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.