Examples of PatchSet


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

      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

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

    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

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

  public ChangeDetail call() throws OrmException, NoSuchEntityException,
      PatchSetInfoNotAvailableException, NoSuchChangeException,
      RepositoryNotFoundException, IOException {
    control = changeControlFactory.validateFor(changeId);
    final Change change = control.getChange();
    final PatchSet patch = db.patchSets().get(change.currentPatchSetId());
    if (patch == null) {
      throw new NoSuchEntityException();
    }

    aic.want(change.getOwner());
View Full Code Here

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

    ResultSet<ChangeMessage> source = db.changeMessages().byChange(changeId);
    List<ChangeMessage> msgList = new ArrayList<ChangeMessage>();
    for (ChangeMessage msg : source) {
      PatchSet.Id id = msg.getPatchSetId();
      if (id != null) {
        PatchSet ps = patchsetsById.get(msg.getPatchSetId());
        if (control.isPatchVisible(ps, db)) {
          msgList.add(msg);
        }
      } else {
        // Not guaranteed to have a non-null patchset id, so just display it.
View Full Code Here

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

  }

  private void loadCurrentPatchSet() throws OrmException,
      NoSuchEntityException, PatchSetInfoNotAvailableException,
      NoSuchChangeException {
    final PatchSet currentPatch = findCurrentOrLatestPatchSet();
    final PatchSet.Id psId = currentPatch.getId();
    final PatchSetDetailFactory loader = patchSetDetail.create(null, psId, null);
    loader.patchSet = currentPatch;
    loader.control = control;
    detail.setCurrentPatchSetDetail(loader.call());
    detail.setCurrentPatchSetId(psId);
View Full Code Here

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

    detail.setDependsOn(dependsOn);
    detail.setNeededBy(neededBy);
  }

  private PatchSet findCurrentOrLatestPatchSet() {
    PatchSet currentPatch = detail.getCurrentPatchSet();
    // If the current patch set is a draft and user can't see it, set the
    // current patch set to whatever the latest one is
    if (currentPatch == null) {
      List<PatchSet> patchSets = detail.getPatchSets();
      if (!detail.getPatchSets().isEmpty()) {
View Full Code Here

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

        reject(request.cmd, "change state corrupt");
        return null;
      }
    }

    final PatchSet ps;
    final ChangeMessage msg;
    db.changes().beginTransaction(change.getId());
    try {
      change =
        db.changes().atomicUpdate(change.getId(), new AtomicUpdate<Change>() {
          @Override
          public Change update(Change change) {
            if (change.getStatus().isOpen()) {
              change.nextPatchSetId();
              change.setLastSha1MergeTested(null);
              return change;
            } else {
              return null;
            }
          }
        });
      if (change == null) {
        reject(request.cmd, "change is closed");
        return null;
      }

      ps = new PatchSet(change.currPatchSetId());
      ps.setCreatedOn(new Timestamp(System.currentTimeMillis()));
      ps.setUploader(currentUser.getAccountId());
      ps.setRevision(toRevId(c));
      if (MagicBranch.isDraft(request.cmd.getRefName())) {
        ps.setDraft(true);
      }
      insertAncestors(ps.getId(), c);
      db.patchSets().insert(Collections.singleton(ps));

      if (request.checkMergedInto) {
        final Ref mergedInto = findMergedInto(change.getDest().get(), c);
        result.mergedIntoRef = mergedInto != null ? mergedInto.getName() : null;
      }
      final PatchSetInfo info = patchSetInfoFactory.get(c, ps.getId());
      change.setCurrentPatchSet(info);
      result.change = change;
      result.patchSet = ps;
      result.info = info;

      List<PatchSetApproval> patchSetApprovals = approvalsUtil.copyVetosToLatestPatchSet(change);

      final Set<Account.Id> haveApprovals = new HashSet<Account.Id>();
      oldReviewers.clear();
      oldCC.clear();

      for (PatchSetApproval a : patchSetApprovals) {
        haveApprovals.add(a.getAccountId());
        if (a.getValue() != 0) {
          oldReviewers.add(a.getAccountId());
        } else {
          oldCC.add(a.getAccountId());
        }
      }

      approvalsUtil.addReviewers(change, ps, info, reviewers, haveApprovals);

      msg =
          new ChangeMessage(new ChangeMessage.Key(change.getId(), ChangeUtil
              .messageUUID(db)), me, ps.getCreatedOn(), ps.getId());
      msg.setMessage("Uploaded patch set " + ps.getPatchSetId() + ".");
      db.changeMessages().insert(Collections.singleton(msg));
      ChangeUtil.updateTrackingIds(db, change, trackingFooters, footerLines);
      result.msg = msg;

      if (result.mergedIntoRef == null) {
        // Change should be new, so it can go through review again.
        //
        change =
            db.changes().atomicUpdate(change.getId(), new AtomicUpdate<Change>() {
              @Override
              public Change update(Change change) {
                if (change.getStatus().isOpen()) {
                  if (destTopicName != null) {
                    change.setTopic(destTopicName);
                  }
                  if (change.getStatus() == Change.Status.DRAFT && ps.isDraft()) {
                    // Leave in draft status.
                  } else {
                    change.setStatus(Change.Status.NEW);
                  }
                  change.setCurrentPatchSet(result.info);
                  ChangeUtil.updated(change);
                  return change;
                } else {
                  return null;
                }
              }
            });
        if (change == null) {
          db.patchSets().delete(Collections.singleton(ps));
          db.changeMessages().delete(Collections.singleton(msg));
          reject(request.cmd, "change is closed");
          return null;
        }
      }

      db.commit();
    } finally {
      db.rollback();
    }

    if (result.mergedIntoRef != null) {
      // Change was already submitted to a branch, close it.
      //
      markChangeMergedByPush(db, result);
    }

    final RefUpdate ru = repo.updateRef(ps.getRefName());
    ru.setNewObjectId(c);
    ru.disableRefLog();
    if (ru.update(rp.getRevWalk()) != RefUpdate.Result.NEW) {
      throw new IOException("Failed to create ref " + ps.getRefName() + " in "
          + repo.getDirectory() + ": " + ru.getResult());
    }
    replication.fire(project.getNameKey(), ru.getName());
    hooks.doPatchsetCreatedHook(result.change, ps, db);
    request.cmd.setResult(OK);

    workQueue.getDefaultQueue()
        .submit(requestScopePropagator.wrap(new Runnable() {
      @Override
      public void run() {
        try {
          final ReplacePatchSetSender cm;
          cm = replacePatchSetFactory.create(result.change);
          cm.setFrom(me);
          cm.setPatchSet(ps, result.info);
          cm.setChangeMessage(result.msg);
          cm.addReviewers(reviewers);
          cm.addExtraCC(cc);
          cm.addReviewers(oldReviewers);
          cm.addExtraCC(oldCC);
          cm.send();
        } catch (Exception e) {
          log.error("Cannot send email for new patch set " + ps.getId(), e);
        }
      }

      @Override
      public String toString() {
View Full Code Here

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

  @Override
  protected Change.Id updateProjectConfig(ProjectConfig config, MetaDataUpdate md)
      throws IOException, NoSuchProjectException, ConfigInvalidException, OrmException {
    int nextChangeId = db.nextChangeId();
    PatchSet.Id patchSetId = new PatchSet.Id(new Change.Id(nextChangeId), 1);
    final PatchSet ps = new PatchSet(patchSetId);
    RevCommit commit = config.commitToNewRef(md, ps.getRefName());
    if (commit.getId().equals(base)) {
      return null;
    }
    Change.Key changeKey = new Change.Key("I" + commit.name());
    final Change change =
        new Change(changeKey, new Change.Id(nextChangeId), user.getAccountId(),
            new Branch.NameKey(config.getProject().getNameKey(),
                GitRepositoryManager.REF_CONFIG));
    change.nextPatchSetId();

    ps.setCreatedOn(change.getCreatedOn());
    ps.setUploader(user.getAccountId());
    ps.setRevision(new RevId(commit.name()));

    db.patchSets().insert(Collections.singleton(ps));

    final PatchSetInfo info = patchSetInfoFactory.get(commit, ps.getId());
    change.setCurrentPatchSet(info);
    ChangeUtil.updated(change);

    db.changes().insert(Collections.singleton(change));
View Full Code Here

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

      final RevCommit commit) throws OrmException {
    final String refName = cmd.getRefName();
    final Change.Id cid = psi.getParentKey();

    final Change change = db.changes().get(cid);
    final PatchSet ps = db.patchSets().get(psi);
    if (change == null || ps == null) {
      log.warn(project.getName() + " " + psi + " is missing");
      return;
    }
View Full Code Here

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

      } catch (NoSuchChangeException e) {
        return null;
      }
    }

    PatchSet ps = cd.currentPatchSet(db);
    Map<String, LabelInfo> labels = Maps.newLinkedHashMap();
    for (SubmitRecord rec : ctl.canSubmit(db.get(), ps, cd, true, false)) {
      if (rec.labels == null) {
        continue;
      }
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.