Merge "Refactor PublishDraft into gerrit-server"
This commit is contained in:
@@ -35,7 +35,6 @@ import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||
import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException;
|
||||
import com.google.gerrit.server.project.InvalidChangeOperationException;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gwtorm.client.AtomicUpdate;
|
||||
import com.google.gwtorm.client.OrmConcurrencyException;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
|
||||
@@ -266,43 +265,6 @@ public class ChangeUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void publishDraftPatchSet(final ReviewDb db,
|
||||
final PatchSet.Id patchSetId) throws OrmException, NoSuchChangeException{
|
||||
final Change.Id changeId = patchSetId.getParentKey();
|
||||
final PatchSet patch = db.patchSets().get(patchSetId);
|
||||
if (patch == null || !patch.isDraft()) {
|
||||
throw new NoSuchChangeException(changeId);
|
||||
}
|
||||
|
||||
db.patchSets().atomicUpdate(patchSetId, new AtomicUpdate<PatchSet>() {
|
||||
@Override
|
||||
public PatchSet update(PatchSet patchset) {
|
||||
if (patchset.isDraft()) {
|
||||
patchset.setDraft(false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
final Change change = db.changes().get(changeId);
|
||||
if (change.getStatus() == Change.Status.DRAFT) {
|
||||
db.changes().atomicUpdate(changeId,
|
||||
new AtomicUpdate<Change>() {
|
||||
@Override
|
||||
public Change update(Change change) {
|
||||
if (change.getStatus() == Change.Status.DRAFT
|
||||
&& change.currentPatchSetId().equals(patchSetId)) {
|
||||
change.setStatus(Change.Status.NEW);
|
||||
ChangeUtil.updated(change);
|
||||
return change;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteDraftChange(final PatchSet.Id patchSetId,
|
||||
GitRepositoryManager gitManager,
|
||||
final ReplicationQueue replication, final ReviewDb db)
|
||||
|
Reference in New Issue
Block a user