コード例 #1
0
ファイル: AbstractSubmit.java プロジェクト: hdost/gerrit
 protected void assertNoSubmitter(String changeId, int psId) throws OrmException {
   ChangeNotes cn =
       notesFactory.create(getOnlyElement(queryProvider.get().byKeyPrefix(changeId)).change());
   PatchSetApproval submitter =
       approvalsUtil.getSubmitter(db, cn, new PatchSet.Id(cn.getChangeId(), psId));
   assertThat(submitter).isNull();
 }
コード例 #2
0
 public PatchSetInfo get(ReviewDb db, ChangeNotes notes, PatchSet.Id psId)
     throws PatchSetInfoNotAvailableException {
   try {
     PatchSet patchSet = psUtil.get(db, notes, psId);
     return get(notes.getProjectName(), patchSet);
   } catch (OrmException e) {
     throw new PatchSetInfoNotAvailableException(e);
   }
 }
コード例 #3
0
ファイル: MergeOp.java プロジェクト: web1992/gerrit
  private void setNew(ChangeNotes notes, final ChangeMessage msg)
      throws NoSuchChangeException, IOException {
    Change c = notes.getChange();

    Change change = null;
    ChangeUpdate update = null;
    try {
      db.changes().beginTransaction(c.getId());
      try {
        change =
            db.changes()
                .atomicUpdate(
                    c.getId(),
                    new AtomicUpdate<Change>() {
                      @Override
                      public Change update(Change c) {
                        if (c.getStatus().isOpen()) {
                          c.setStatus(Change.Status.NEW);
                          ChangeUtil.updated(c);
                        }
                        return c;
                      }
                    });
        ChangeControl control = changeControl(change);

        // TODO(yyonas): atomic change is not propagated.
        update = updateFactory.create(control, c.getLastUpdatedOn());
        if (msg != null) {
          cmUtil.addChangeMessage(db, update, msg);
        }
        db.commit();
      } finally {
        db.rollback();
      }
    } catch (OrmException err) {
      logWarn("Cannot record merge failure message", err);
    }
    if (update != null) {
      update.commit();
    }
    indexer.index(db, change);

    PatchSetApproval submitter = null;
    try {
      submitter = approvalsUtil.getSubmitter(db, notes, notes.getChange().currentPatchSetId());
    } catch (Exception e) {
      logError("Cannot get submitter for change " + notes.getChangeId(), e);
    }
    if (submitter != null) {
      try {
        hooks.doMergeFailedHook(
            c,
            accountCache.get(submitter.getAccountId()).getAccount(),
            db.patchSets().get(c.currentPatchSetId()),
            msg.getMessage(),
            db);
      } catch (OrmException ex) {
        logError("Cannot run hook for merge failed " + c.getId(), ex);
      }
    }
  }