当前位置: 首页>>代码示例>>Java>>正文


Java ChangeUtil.status方法代码示例

本文整理汇总了Java中com.google.gerrit.server.ChangeUtil.status方法的典型用法代码示例。如果您正苦于以下问题:Java ChangeUtil.status方法的具体用法?Java ChangeUtil.status怎么用?Java ChangeUtil.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gerrit.server.ChangeUtil的用法示例。


在下文中一共展示了ChangeUtil.status方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateChange

import com.google.gerrit.server.ChangeUtil; //导入方法依赖的package包/类
@Override
public boolean updateChange(ChangeContext ctx) throws OrmException, ResourceConflictException {
  change = ctx.getChange();
  PatchSet.Id psId = change.currentPatchSetId();
  ChangeUpdate update = ctx.getUpdate(psId);
  if (!change.getStatus().isOpen()) {
    throw new ResourceConflictException("change is " + ChangeUtil.status(change));
  }
  patchSet = psUtil.get(ctx.getDb(), ctx.getNotes(), psId);
  change.setStatus(Change.Status.ABANDONED);
  change.setLastUpdatedOn(ctx.getWhen());

  update.setStatus(change.getStatus());
  message = newMessage(ctx);
  cmUtil.addChangeMessage(ctx.getDb(), update, message);
  return true;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:AbandonOp.java

示例2: updateChange

import com.google.gerrit.server.ChangeUtil; //导入方法依赖的package包/类
@Override
public boolean updateChange(ChangeContext ctx) throws OrmException, ResourceConflictException {
  change = ctx.getChange();
  if (change == null || change.getStatus() != Status.ABANDONED) {
    throw new ResourceConflictException("change is " + ChangeUtil.status(change));
  }
  PatchSet.Id psId = change.currentPatchSetId();
  ChangeUpdate update = ctx.getUpdate(psId);
  patchSet = psUtil.get(ctx.getDb(), ctx.getNotes(), psId);
  change.setStatus(Status.NEW);
  change.setLastUpdatedOn(ctx.getWhen());
  update.setStatus(change.getStatus());

  message = newMessage(ctx);
  cmUtil.addChangeMessage(ctx.getDb(), update, message);
  return true;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:Restore.java

示例3: applyImpl

import com.google.gerrit.server.ChangeUtil; //导入方法依赖的package包/类
@Override
public ChangeInfo applyImpl(
    BatchUpdate.Factory updateFactory, ChangeResource rsrc, RevertInput input)
    throws IOException, OrmException, RestApiException, UpdateException, NoSuchChangeException,
        PermissionBackendException, NoSuchProjectException {
  Change change = rsrc.getChange();
  if (change.getStatus() != Change.Status.MERGED) {
    throw new ResourceConflictException("change is " + ChangeUtil.status(change));
  }

  contributorAgreements.check(rsrc.getProject(), rsrc.getUser());
  permissionBackend.user(rsrc.getUser()).ref(change.getDest()).check(CREATE_CHANGE);

  Change.Id revertId =
      revert(updateFactory, rsrc.getNotes(), rsrc.getUser(), Strings.emptyToNull(input.message));
  return json.noOptions().format(rsrc.getProject(), revertId);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:Revert.java

示例4: applyImpl

import com.google.gerrit.server.ChangeUtil; //导入方法依赖的package包/类
@Override
protected Response<?> applyImpl(
    BatchUpdate.Factory updateFactory, ChangeResource rsrc, Input input)
    throws RestApiException, UpdateException {
  Change change = rsrc.getChange();
  if (!rsrc.isUserOwner()) {
    throw new AuthException("not allowed to set work in progress");
  }

  if (change.getStatus() != Status.NEW) {
    throw new ResourceConflictException("change is " + ChangeUtil.status(change));
  }

  if (change.isWorkInProgress()) {
    throw new ResourceConflictException("change is already work in progress");
  }

  try (BatchUpdate bu =
      updateFactory.create(db.get(), rsrc.getProject(), rsrc.getUser(), TimeUtil.nowTs())) {
    bu.addOp(rsrc.getChange().getId(), opFactory.create(true, input));
    bu.execute();
    return Response.ok("");
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:SetWorkInProgress.java

示例5: applyImpl

import com.google.gerrit.server.ChangeUtil; //导入方法依赖的package包/类
@Override
protected Response<?> applyImpl(
    BatchUpdate.Factory updateFactory, ChangeResource rsrc, Input input)
    throws RestApiException, UpdateException {
  Change change = rsrc.getChange();
  if (!rsrc.isUserOwner()) {
    throw new AuthException("not allowed to set ready for review");
  }

  if (change.getStatus() != Status.NEW) {
    throw new ResourceConflictException("change is " + ChangeUtil.status(change));
  }

  if (!change.isWorkInProgress()) {
    throw new ResourceConflictException("change is not work in progress");
  }

  try (BatchUpdate bu =
      updateFactory.create(db.get(), rsrc.getProject(), rsrc.getUser(), TimeUtil.nowTs())) {
    bu.addOp(rsrc.getChange().getId(), opFactory.create(false, input));
    bu.execute();
    return Response.ok("");
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:SetReadyForReview.java

示例6: applyImpl

import com.google.gerrit.server.ChangeUtil; //导入方法依赖的package包/类
@Override
protected ChangeInfo applyImpl(
    BatchUpdate.Factory updateFactory, RevisionResource rsrc, RebaseInput input)
    throws EmailException, OrmException, UpdateException, RestApiException, IOException,
        NoSuchChangeException, PermissionBackendException {
  rsrc.permissions().database(dbProvider).check(ChangePermission.REBASE);

  Change change = rsrc.getChange();
  try (Repository repo = repoManager.openRepository(change.getProject());
      ObjectInserter oi = repo.newObjectInserter();
      ObjectReader reader = oi.newReader();
      RevWalk rw = new RevWalk(reader);
      BatchUpdate bu =
          updateFactory.create(
              dbProvider.get(), change.getProject(), rsrc.getUser(), TimeUtil.nowTs())) {
    if (!change.getStatus().isOpen()) {
      throw new ResourceConflictException("change is " + ChangeUtil.status(change));
    } else if (!hasOneParent(rw, rsrc.getPatchSet())) {
      throw new ResourceConflictException(
          "cannot rebase merge commits or commit with no ancestor");
    }
    bu.setRepository(repo, rw, oi);
    bu.addOp(
        change.getId(),
        rebaseFactory
            .create(rsrc.getNotes(), rsrc.getPatchSet(), findBaseRev(repo, rw, rsrc, input))
            .setForceContentMerge(true)
            .setFireRevisionCreated(true));
    bu.execute();
  }
  return json.create(OPTIONS).format(change.getProject(), change.getId());
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:33,代码来源:Rebase.java

示例7: applyImpl

import com.google.gerrit.server.ChangeUtil; //导入方法依赖的package包/类
@Override
protected ChangeInfo applyImpl(
    BatchUpdate.Factory updateFactory, ChangeResource rsrc, MoveInput input)
    throws RestApiException, OrmException, UpdateException, PermissionBackendException {
  Change change = rsrc.getChange();
  Project.NameKey project = rsrc.getProject();
  IdentifiedUser caller = rsrc.getUser().asIdentifiedUser();
  input.destinationBranch = RefNames.fullName(input.destinationBranch);

  if (change.getStatus().isClosed()) {
    throw new ResourceConflictException("Change is " + ChangeUtil.status(change));
  }

  Branch.NameKey newDest = new Branch.NameKey(project, input.destinationBranch);
  if (change.getDest().equals(newDest)) {
    throw new ResourceConflictException("Change is already destined for the specified branch");
  }

  // Move requires abandoning this change, and creating a new change.
  try {
    rsrc.permissions().database(dbProvider).check(ABANDON);
    permissionBackend.user(caller).database(dbProvider).ref(newDest).check(CREATE_CHANGE);
  } catch (AuthException denied) {
    throw new AuthException("move not permitted", denied);
  }

  try (BatchUpdate u =
      updateFactory.create(dbProvider.get(), project, caller, TimeUtil.nowTs())) {
    u.addOp(change.getId(), new Op(input));
    u.execute();
  }
  return json.noOptions().format(project, rsrc.getId());
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:34,代码来源:Move.java

示例8: apply

import com.google.gerrit.server.ChangeUtil; //导入方法依赖的package包/类
@Override
public BinaryResult apply(RevisionResource rsrc)
    throws OrmException, RestApiException, UpdateException, IOException, ConfigInvalidException,
        PermissionBackendException {
  if (Strings.isNullOrEmpty(format)) {
    throw new BadRequestException("format is not specified");
  }
  ArchiveFormat f = allowedFormats.extensions.get("." + format);
  if (f == null && format.equals("tgz")) {
    // Always allow tgz, even when the allowedFormats doesn't contain it.
    // Then we allow at least one format even if the list of allowed
    // formats is empty.
    f = ArchiveFormat.TGZ;
  }
  if (f == null) {
    throw new BadRequestException("unknown archive format");
  }

  Change change = rsrc.getChange();
  if (!change.getStatus().isOpen()) {
    throw new PreconditionFailedException("change is " + ChangeUtil.status(change));
  }
  if (!rsrc.getUser().isIdentifiedUser()) {
    throw new MethodNotAllowedException("Anonymous users cannot submit");
  }

  return getBundles(rsrc, f);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:29,代码来源:PreviewSubmit.java

示例9: apply

import com.google.gerrit.server.ChangeUtil; //导入方法依赖的package包/类
@Override
public MergeableInfo apply(RevisionResource resource)
    throws AuthException, ResourceConflictException, BadRequestException, OrmException,
        IOException {
  Change change = resource.getChange();
  PatchSet ps = resource.getPatchSet();
  MergeableInfo result = new MergeableInfo();

  if (!change.getStatus().isOpen()) {
    throw new ResourceConflictException("change is " + ChangeUtil.status(change));
  } else if (!ps.getId().equals(change.currentPatchSetId())) {
    // Only the current revision is mergeable. Others always fail.
    return result;
  }

  ChangeData cd = changeDataFactory.create(db.get(), resource.getNotes());
  result.submitType = getSubmitType(resource.getUser(), cd, ps);

  try (Repository git = gitManager.openRepository(change.getProject())) {
    ObjectId commit = toId(ps);
    Ref ref = git.getRefDatabase().exactRef(change.getDest().get());
    ProjectState projectState = projectCache.get(change.getProject());
    String strategy = mergeUtilFactory.create(projectState).mergeStrategyName();
    result.strategy = strategy;
    result.mergeable = isMergable(git, change, commit, ref, result.submitType, strategy);

    if (otherBranches) {
      result.mergeableInto = new ArrayList<>();
      BranchOrderSection branchOrder = projectState.getBranchOrderSection();
      if (branchOrder != null) {
        int prefixLen = Constants.R_HEADS.length();
        String[] names = branchOrder.getMoreStable(ref.getName());
        Map<String, Ref> refs = git.getRefDatabase().exactRef(names);
        for (String n : names) {
          Ref other = refs.get(n);
          if (other == null) {
            continue;
          }
          if (cache.get(commit, other, SubmitType.CHERRY_PICK, strategy, change.getDest(), git)) {
            result.mergeableInto.add(other.getName().substring(prefixLen));
          }
        }
      }
    }
  }
  return result;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:48,代码来源:Mergeable.java

示例10: mergeChange

import com.google.gerrit.server.ChangeUtil; //导入方法依赖的package包/类
public Change mergeChange(RevisionResource rsrc, IdentifiedUser submitter, SubmitInput input)
    throws OrmException, RestApiException, IOException, UpdateException, ConfigInvalidException,
        PermissionBackendException {
  Change change = rsrc.getChange();
  if (!change.getStatus().isOpen()) {
    throw new ResourceConflictException("change is " + ChangeUtil.status(change));
  } else if (!ProjectUtil.branchExists(repoManager, change.getDest())) {
    throw new ResourceConflictException(
        String.format("destination branch \"%s\" not found.", change.getDest().get()));
  } else if (!rsrc.getPatchSet().getId().equals(change.currentPatchSetId())) {
    // TODO Allow submitting non-current revision by changing the current.
    throw new ResourceConflictException(
        String.format(
            "revision %s is not current revision", rsrc.getPatchSet().getRevision().get()));
  }

  try (MergeOp op = mergeOpProvider.get()) {
    ReviewDb db = dbProvider.get();
    op.merge(db, change, submitter, true, input, false);
    try {
      change =
          changeNotesFactory.createChecked(db, change.getProject(), change.getId()).getChange();
    } catch (NoSuchChangeException e) {
      throw new ResourceConflictException("change is deleted");
    }
  }

  switch (change.getStatus()) {
    case MERGED:
      return change;
    case NEW:
      ChangeMessage msg = getConflictMessage(rsrc);
      if (msg != null) {
        throw new ResourceConflictException(msg.getMessage());
      }
      // $FALL-THROUGH$
    case ABANDONED:
    default:
      throw new ResourceConflictException("change is " + ChangeUtil.status(change));
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:42,代码来源:Submit.java

示例11: updateChange

import com.google.gerrit.server.ChangeUtil; //导入方法依赖的package包/类
@Override
public boolean updateChange(ChangeContext ctx)
    throws OrmException, ResourceConflictException, IOException {
  change = ctx.getChange();
  if (change.getStatus() != Status.NEW) {
    throw new ResourceConflictException("Change is " + ChangeUtil.status(change));
  }

  Project.NameKey projectKey = change.getProject();
  newDestKey = new Branch.NameKey(projectKey, input.destinationBranch);
  Branch.NameKey changePrevDest = change.getDest();
  if (changePrevDest.equals(newDestKey)) {
    throw new ResourceConflictException("Change is already destined for the specified branch");
  }

  final PatchSet.Id patchSetId = change.currentPatchSetId();
  try (Repository repo = repoManager.openRepository(projectKey);
      RevWalk revWalk = new RevWalk(repo)) {
    RevCommit currPatchsetRevCommit =
        revWalk.parseCommit(
            ObjectId.fromString(
                psUtil.current(ctx.getDb(), ctx.getNotes()).getRevision().get()));
    if (currPatchsetRevCommit.getParentCount() > 1) {
      throw new ResourceConflictException("Merge commit cannot be moved");
    }

    ObjectId refId = repo.resolve(input.destinationBranch);
    // Check if destination ref exists in project repo
    if (refId == null) {
      throw new ResourceConflictException(
          "Destination " + input.destinationBranch + " not found in the project");
    }
    RevCommit refCommit = revWalk.parseCommit(refId);
    if (revWalk.isMergedInto(currPatchsetRevCommit, refCommit)) {
      throw new ResourceConflictException(
          "Current patchset revision is reachable from tip of " + input.destinationBranch);
    }
  }

  Change.Key changeKey = change.getKey();
  if (!asChanges(queryProvider.get().byBranchKey(newDestKey, changeKey)).isEmpty()) {
    throw new ResourceConflictException(
        "Destination "
            + newDestKey.getShortName()
            + " has a different change with same change key "
            + changeKey);
  }

  if (!change.currentPatchSetId().equals(patchSetId)) {
    throw new ResourceConflictException("Patch set is not current");
  }

  PatchSet.Id psId = change.currentPatchSetId();
  ChangeUpdate update = ctx.getUpdate(psId);
  update.setBranch(newDestKey.get());
  change.setDest(newDestKey);

  updateApprovals(ctx, update, psId, projectKey);

  StringBuilder msgBuf = new StringBuilder();
  msgBuf.append("Change destination moved from ");
  msgBuf.append(changePrevDest.getShortName());
  msgBuf.append(" to ");
  msgBuf.append(newDestKey.getShortName());
  if (!Strings.isNullOrEmpty(input.message)) {
    msgBuf.append("\n\n");
    msgBuf.append(input.message);
  }
  ChangeMessage cmsg =
      ChangeMessagesUtil.newMessage(ctx, msgBuf.toString(), ChangeMessagesUtil.TAG_MOVE);
  cmUtil.addChangeMessage(ctx.getDb(), update, cmsg);

  return true;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:75,代码来源:Move.java


注:本文中的com.google.gerrit.server.ChangeUtil.status方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。