diff --git a/Documentation/dev-plugins.txt b/Documentation/dev-plugins.txt index 490bc55b9c..75ef9e6642 100644 --- a/Documentation/dev-plugins.txt +++ b/Documentation/dev-plugins.txt @@ -1309,7 +1309,7 @@ public Object apply(RevisionResource rcrs, Input in) { db, project.getNameKey(), user, TimeUtil.nowTs())) { bu.addOp(change.getId(), new BatchUpdate.Op() { @Override - public boolean updateChange(BatchUpdate.ChangeContext ctx) { + public boolean updateChange(ChangeContext ctx) { return true; } }); diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/change/ChangeIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/change/ChangeIT.java index 02d52aaada..de2204e187 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/change/ChangeIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/change/ChangeIT.java @@ -109,6 +109,7 @@ import com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage; import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.project.Util; import com.google.gerrit.server.update.BatchUpdate; +import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.testutil.FakeEmailSender.Message; import com.google.gerrit.testutil.TestTimeUtil; import com.google.inject.Inject; @@ -2517,7 +2518,7 @@ public class ChangeIT extends AbstractDaemonTest { } @Override - public boolean updateChange(BatchUpdate.ChangeContext ctx) throws Exception { + public boolean updateChange(ChangeContext ctx) throws Exception { Change change = ctx.getChange(); // Change status in database. diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java index 0d465e217a..f29e18c502 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java @@ -70,7 +70,7 @@ import com.google.gerrit.server.git.validators.OnSubmitValidationListener; import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.project.Util; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; +import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.validators.ValidationException; import com.google.gerrit.testutil.ConfigSuite; import com.google.gerrit.testutil.TestTimeUtil; diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/DraftChangeIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/DraftChangeIT.java index c5a44900e9..65ed6e3700 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/DraftChangeIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/DraftChangeIT.java @@ -42,6 +42,7 @@ import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.server.notedb.PatchSetState; import com.google.gerrit.server.update.BatchUpdate; +import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.testutil.ConfigSuite; import com.google.inject.Inject; import java.util.Collection; @@ -277,7 +278,7 @@ public class DraftChangeIT extends AbstractDaemonTest { private class MarkChangeAsDraftUpdateOp extends BatchUpdate.Op { @Override - public boolean updateChange(BatchUpdate.ChangeContext ctx) throws Exception { + public boolean updateChange(ChangeContext ctx) throws Exception { Change change = ctx.getChange(); // Change status in database. @@ -299,7 +300,7 @@ public class DraftChangeIT extends AbstractDaemonTest { } @Override - public boolean updateChange(BatchUpdate.ChangeContext ctx) throws Exception { + public boolean updateChange(ChangeContext ctx) throws Exception { Collection patchSets = psUtil.byChange(db, ctx.getNotes()); // Change status in database. diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/ConsistencyCheckerIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/ConsistencyCheckerIT.java index a3b5013f76..29125966ad 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/ConsistencyCheckerIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/ConsistencyCheckerIT.java @@ -50,8 +50,8 @@ import com.google.gerrit.server.notedb.ChangeNoteUtil; import com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage; import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.testutil.InMemoryRepositoryManager; import com.google.gerrit.testutil.TestChanges; import com.google.gwtorm.server.OrmException; diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/GetRelatedIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/GetRelatedIT.java index 9aeb9b600c..f8d1ce8a6c 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/GetRelatedIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/GetRelatedIT.java @@ -36,7 +36,7 @@ import com.google.gerrit.server.change.GetRelated.ChangeAndCommit; import com.google.gerrit.server.change.GetRelated.RelatedInfo; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; +import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.testutil.TestTimeUtil; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java index b506e321a6..a8d65abb4b 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java @@ -78,7 +78,7 @@ import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException; import com.google.gerrit.server.project.Util; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; +import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.testutil.ConfigSuite; import com.google.gerrit.testutil.NoteDbChecker; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/ChangeMessagesUtil.java b/gerrit-server/src/main/java/com/google/gerrit/server/ChangeMessagesUtil.java index d9b6f26aa9..d277bf9eda 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/ChangeMessagesUtil.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/ChangeMessagesUtil.java @@ -26,7 +26,7 @@ import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.notedb.NotesMigration; -import com.google.gerrit.server.update.BatchUpdate; +import com.google.gerrit.server.update.ChangeContext; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -58,8 +58,7 @@ public class ChangeMessagesUtil { public static final String TAG_SET_TOPIC = "autogenerated:gerrit:setTopic"; public static final String TAG_UPLOADED_PATCH_SET = "autogenerated:gerrit:newPatchSet"; - public static ChangeMessage newMessage( - BatchUpdate.ChangeContext ctx, String body, @Nullable String tag) { + public static ChangeMessage newMessage(ChangeContext ctx, String body, @Nullable String tag) { return newMessage(ctx.getChange().currentPatchSetId(), ctx.getUser(), ctx.getWhen(), body, tag); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/CommentsUtil.java b/gerrit-server/src/main/java/com/google/gerrit/server/CommentsUtil.java index d1846cee4c..8d2289ac54 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/CommentsUtil.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/CommentsUtil.java @@ -46,7 +46,7 @@ import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.notedb.NotesMigration; import com.google.gerrit.server.patch.PatchListCache; import com.google.gerrit.server.patch.PatchListNotAvailableException; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; +import com.google.gerrit.server.update.ChangeContext; import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.ResultSet; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeInserter.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeInserter.java index 5ed7f4219b..d8821058dc 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeInserter.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeInserter.java @@ -58,9 +58,9 @@ import com.google.gerrit.server.project.ProjectControl; import com.google.gerrit.server.project.RefControl; import com.google.gerrit.server.ssh.NoSshInfo; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; +import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.server.util.RequestScopePropagator; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/CherryPickChange.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/CherryPickChange.java index a7a19c01f4..ca66228e6e 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/CherryPickChange.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/CherryPickChange.java @@ -48,7 +48,7 @@ import com.google.gerrit.server.project.RefControl; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; +import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/ConsistencyChecker.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/ConsistencyChecker.java index 792d5c8258..80e64d349c 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/ConsistencyChecker.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/ConsistencyChecker.java @@ -51,8 +51,8 @@ import com.google.gerrit.server.patch.PatchSetInfoFactory; import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException; import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/CreateDraftComment.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/CreateDraftComment.java index 0b54ceb4c1..3605e4ba6e 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/CreateDraftComment.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/CreateDraftComment.java @@ -35,7 +35,7 @@ import com.google.gerrit.server.CommentsUtil; import com.google.gerrit.server.PatchSetUtil; import com.google.gerrit.server.patch.PatchListCache; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; +import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteAssignee.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteAssignee.java index d24f91cc24..df62f6c593 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteAssignee.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteAssignee.java @@ -31,8 +31,8 @@ import com.google.gerrit.server.change.DeleteAssignee.Input; import com.google.gerrit.server.extensions.events.AssigneeChanged; import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; @@ -110,8 +110,7 @@ public class DeleteAssignee implements RestModifyView { return deletedAssignee != null ? deletedAssignee.getId() : null; } - private void addMessage( - BatchUpdate.ChangeContext ctx, ChangeUpdate update, IdentifiedUser deletedAssignee) + private void addMessage(ChangeContext ctx, ChangeUpdate update, IdentifiedUser deletedAssignee) throws OrmException { ChangeMessage cmsg = ChangeMessagesUtil.newMessage( diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteChange.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteChange.java index 8c081e1ad2..ad823d47f8 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteChange.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteChange.java @@ -26,6 +26,7 @@ import com.google.gerrit.server.change.DeleteChange.Input; import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.update.BatchUpdate; +import com.google.gerrit.server.update.Order; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; @@ -61,7 +62,7 @@ public class DeleteChange try (BatchUpdate bu = updateFactory.create(db.get(), rsrc.getProject(), rsrc.getUser(), TimeUtil.nowTs())) { Change.Id id = rsrc.getChange().getId(); - bu.setOrder(BatchUpdate.Order.DB_BEFORE_REPO); + bu.setOrder(Order.DB_BEFORE_REPO); bu.addOp(id, opProvider.get()); bu.execute(); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteChangeOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteChangeOp.java index 3e800dcde9..81827fcc4e 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteChangeOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteChangeOp.java @@ -30,9 +30,10 @@ import com.google.gerrit.server.StarredChangesUtil; import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; import com.google.gerrit.server.update.BatchUpdateReviewDb; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Order; +import com.google.gerrit.server.update.RepoContext; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; @@ -84,8 +85,7 @@ class DeleteChangeOp extends BatchUpdate.Op { public boolean updateChange(ChangeContext ctx) throws RestApiException, OrmException, IOException, NoSuchChangeException { checkState( - ctx.getOrder() == BatchUpdate.Order.DB_BEFORE_REPO, - "must use DeleteChangeOp with DB_BEFORE_REPO"); + ctx.getOrder() == Order.DB_BEFORE_REPO, "must use DeleteChangeOp with DB_BEFORE_REPO"); checkState(id == null, "cannot reuse DeleteChangeOp"); id = ctx.getChange().getId(); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteDraftComment.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteDraftComment.java index 3a788e4b08..d1e31c0d20 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteDraftComment.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteDraftComment.java @@ -30,7 +30,7 @@ import com.google.gerrit.server.PatchSetUtil; import com.google.gerrit.server.change.DeleteDraftComment.Input; import com.google.gerrit.server.patch.PatchListCache; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; +import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteDraftPatchSet.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteDraftPatchSet.java index 0f1c4c1b74..1f0a4e62e3 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteDraftPatchSet.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteDraftPatchSet.java @@ -34,8 +34,9 @@ import com.google.gerrit.server.patch.PatchSetInfoFactory; import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException; import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Order; +import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; @@ -83,7 +84,7 @@ public class DeleteDraftPatchSet throws RestApiException, UpdateException { try (BatchUpdate bu = updateFactory.create(db.get(), rsrc.getProject(), rsrc.getUser(), TimeUtil.nowTs())) { - bu.setOrder(BatchUpdate.Order.DB_BEFORE_REPO); + bu.setOrder(Order.DB_BEFORE_REPO); bu.addOp(rsrc.getChange().getId(), new Op(rsrc.getPatchSet().getId())); bu.execute(); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteReviewer.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteReviewer.java index 25a3e3c3eb..47a49c3548 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteReviewer.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteReviewer.java @@ -43,9 +43,9 @@ import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage; import com.google.gerrit.server.notedb.NotesMigration; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; import com.google.gerrit.server.update.BatchUpdateReviewDb; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteVote.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteVote.java index 562d17cb18..bb182d2f3c 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteVote.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/DeleteVote.java @@ -43,8 +43,8 @@ import com.google.gerrit.server.mail.send.DeleteVoteSender; import com.google.gerrit.server.mail.send.ReplyToChangeSender; import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.LabelVote; import com.google.gwtorm.server.OrmException; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/Move.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/Move.java index 81daec152b..86b60be0ae 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/Move.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/Move.java @@ -39,7 +39,7 @@ import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; +import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/PatchSetInserter.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/PatchSetInserter.java index bbe776d329..826d9b99b0 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/PatchSetInserter.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/PatchSetInserter.java @@ -46,9 +46,9 @@ import com.google.gerrit.server.patch.PatchSetInfoFactory; import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.ssh.NoSshInfo; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; +import com.google.gerrit.server.update.RepoContext; import com.google.gwtorm.server.OrmException; import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/PostReview.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/PostReview.java index 7df34c77ad..70daa93b60 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/PostReview.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/PostReview.java @@ -93,8 +93,8 @@ import com.google.gerrit.server.patch.PatchListCache; import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.LabelVote; import com.google.gwtorm.server.OrmException; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/PostReviewers.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/PostReviewers.java index 7ba2fb7f7f..ff00b79899 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/PostReviewers.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/PostReviewers.java @@ -59,8 +59,8 @@ import com.google.gerrit.server.notedb.NotesMigration; import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.project.NoSuchProjectException; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/PublishDraftPatchSet.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/PublishDraftPatchSet.java index f1ab12232a..1b071f95be 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/PublishDraftPatchSet.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/PublishDraftPatchSet.java @@ -46,8 +46,8 @@ import com.google.gerrit.server.mail.send.ReplacePatchSetSender; import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.patch.PatchSetInfoFactory; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/PutDescription.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/PutDescription.java index a3a9ac0d0e..4b3498ab04 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/PutDescription.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/PutDescription.java @@ -30,7 +30,7 @@ import com.google.gerrit.server.PatchSetUtil; import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; +import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/PutDraftComment.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/PutDraftComment.java index ca11ef0d6d..f2f64120fc 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/PutDraftComment.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/PutDraftComment.java @@ -34,7 +34,7 @@ import com.google.gerrit.server.PatchSetUtil; import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.patch.PatchListCache; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; +import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/PutTopic.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/PutTopic.java index 004d030e33..22e34307d7 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/PutTopic.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/PutTopic.java @@ -31,8 +31,8 @@ import com.google.gerrit.server.extensions.events.TopicEdited; import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/RebaseChangeOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/RebaseChangeOp.java index 2256e65efb..d913f95e68 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/RebaseChangeOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/RebaseChangeOp.java @@ -32,9 +32,9 @@ import com.google.gerrit.server.project.InvalidChangeOperationException; import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; +import com.google.gerrit.server.update.RepoContext; import com.google.gwtorm.server.OrmException; import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/Restore.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/Restore.java index 61331b7d0f..d64e26c5b3 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/Restore.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/Restore.java @@ -36,8 +36,8 @@ import com.google.gerrit.server.mail.send.RestoredSender; import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/Revert.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/Revert.java index 704db095d6..8488749fce 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/Revert.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/Revert.java @@ -47,8 +47,8 @@ import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.project.ProjectControl; import com.google.gerrit.server.project.RefControl; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/SetAssigneeOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/SetAssigneeOp.java index 6e5d0f6e01..b613eda0ae 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/SetAssigneeOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/SetAssigneeOp.java @@ -31,7 +31,8 @@ import com.google.gerrit.server.extensions.events.AssigneeChanged; import com.google.gerrit.server.mail.send.SetAssigneeSender; import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.Context; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; import com.google.gerrit.server.validators.AssigneeValidationListener; import com.google.gerrit.server.validators.ValidationException; import com.google.gwtorm.server.OrmException; @@ -82,7 +83,7 @@ public class SetAssigneeOp extends BatchUpdate.Op { } @Override - public boolean updateChange(BatchUpdate.ChangeContext ctx) throws OrmException, RestApiException { + public boolean updateChange(ChangeContext ctx) throws OrmException, RestApiException { change = ctx.getChange(); ChangeUpdate update = ctx.getUpdate(change.currentPatchSetId()); IdentifiedUser newAssigneeUser = accounts.parse(assignee); @@ -119,7 +120,7 @@ public class SetAssigneeOp extends BatchUpdate.Op { } private void addMessage( - BatchUpdate.ChangeContext ctx, + ChangeContext ctx, ChangeUpdate update, IdentifiedUser previousAssignee, IdentifiedUser newAssignee) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/SetHashtagsOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/SetHashtagsOp.java index bfbf8b1783..b348fc14b9 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/SetHashtagsOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/SetHashtagsOp.java @@ -34,8 +34,8 @@ import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.notedb.NotesMigration; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; import com.google.gerrit.server.validators.HashtagValidationListener; import com.google.gerrit.server.validators.ValidationException; import com.google.gwtorm.server.OrmException; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/edit/ChangeEditUtil.java b/gerrit-server/src/main/java/com/google/gerrit/server/edit/ChangeEditUtil.java index f3da374418..8112098188 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/edit/ChangeEditUtil.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/edit/ChangeEditUtil.java @@ -41,7 +41,7 @@ import com.google.gerrit.server.index.change.ChangeIndexer; import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; +import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/AbandonOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/AbandonOp.java index 38809c955e..9e90ebb645 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/AbandonOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/AbandonOp.java @@ -31,8 +31,8 @@ import com.google.gerrit.server.mail.send.AbandonedSender; import com.google.gerrit.server.mail.send.ReplyToChangeSender; import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; import com.google.gwtorm.server.OrmException; import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/ChangeProgressOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/ChangeProgressOp.java index e8ffdf9425..a89a13d1c8 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/ChangeProgressOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/ChangeProgressOp.java @@ -15,7 +15,7 @@ package com.google.gerrit.server.git; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; +import com.google.gerrit.server.update.ChangeContext; import org.eclipse.jgit.lib.ProgressMonitor; /** Trivial op to update a counter during {@code updateChange} */ diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java index 32e747f608..9cd87f6572 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java @@ -64,7 +64,7 @@ import com.google.gerrit.server.project.SubmitRuleOptions; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; +import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.RequestId; import com.google.gwtorm.server.OrmException; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/MergedByPushOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/MergedByPushOp.java index d646b6c974..6061bb35c5 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/MergedByPushOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/MergedByPushOp.java @@ -30,8 +30,8 @@ import com.google.gerrit.server.mail.send.MergedSender; import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.patch.PatchSetInfoFactory; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; import com.google.gerrit.server.util.RequestScopePropagator; import com.google.gwtorm.server.OrmException; import com.google.inject.Provider; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java index 063e44f460..66a1451d8d 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java @@ -115,7 +115,7 @@ import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.ssh.SshInfo; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; +import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.LabelVote; import com.google.gerrit.server.util.MagicBranch; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReplaceOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReplaceOp.java index 13e193848a..4a2bcaf406 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReplaceOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReplaceOp.java @@ -50,9 +50,9 @@ import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.project.ProjectControl; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; +import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.server.util.RequestScopePropagator; import com.google.gwtorm.server.OrmException; import com.google.inject.assistedinject.Assisted; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/SubmoduleOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/SubmoduleOp.java index 790ca940b4..719638a488 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/SubmoduleOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/SubmoduleOp.java @@ -32,7 +32,7 @@ import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.update.BatchUpdate; import com.google.gerrit.server.update.BatchUpdate.Listener; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; +import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.server.update.UpdateException; import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/CherryPick.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/CherryPick.java index e4b3fc8662..96b5b55cee 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/CherryPick.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/CherryPick.java @@ -27,8 +27,8 @@ import com.google.gerrit.server.git.IntegrationException; import com.google.gerrit.server.git.MergeIdenticalTreeException; import com.google.gerrit.server.git.MergeTip; import com.google.gerrit.server.project.NoSuchChangeException; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.RepoContext; import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.ArrayList; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/FastForwardOnly.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/FastForwardOnly.java index 3f32af18ea..7151486c36 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/FastForwardOnly.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/FastForwardOnly.java @@ -16,7 +16,7 @@ package com.google.gerrit.server.git.strategy; import com.google.gerrit.server.git.CodeReviewCommit; import com.google.gerrit.server.git.IntegrationException; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; +import com.google.gerrit.server.update.RepoContext; import java.util.ArrayList; import java.util.Collection; import java.util.List; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/FastForwardOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/FastForwardOp.java index b366468217..a3b10cb5df 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/FastForwardOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/FastForwardOp.java @@ -16,7 +16,7 @@ package com.google.gerrit.server.git.strategy; import com.google.gerrit.server.git.CodeReviewCommit; import com.google.gerrit.server.git.IntegrationException; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; +import com.google.gerrit.server.update.RepoContext; class FastForwardOp extends SubmitStrategyOp { FastForwardOp(SubmitStrategy.Arguments args, CodeReviewCommit toMerge) { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/MergeOneOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/MergeOneOp.java index bfc2f780ed..2a6680c290 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/MergeOneOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/MergeOneOp.java @@ -16,7 +16,7 @@ package com.google.gerrit.server.git.strategy; import com.google.gerrit.server.git.CodeReviewCommit; import com.google.gerrit.server.git.IntegrationException; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; +import com.google.gerrit.server.update.RepoContext; import java.io.IOException; import org.eclipse.jgit.lib.PersonIdent; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/RebaseSubmitStrategy.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/RebaseSubmitStrategy.java index 4a733492ca..52ff29ad7b 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/RebaseSubmitStrategy.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/RebaseSubmitStrategy.java @@ -32,9 +32,9 @@ import com.google.gerrit.server.git.RebaseSorter; import com.google.gerrit.server.git.validators.CommitValidators; import com.google.gerrit.server.project.InvalidChangeOperationException; import com.google.gerrit.server.project.NoSuchChangeException; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; +import com.google.gerrit.server.update.RepoContext; import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.ArrayList; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/SubmitStrategyOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/SubmitStrategyOp.java index d92a27d8c9..3c755f3bf7 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/SubmitStrategyOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/SubmitStrategyOp.java @@ -47,9 +47,9 @@ import com.google.gerrit.server.git.SubmoduleException; import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; -import com.google.gerrit.server.update.BatchUpdate.Context; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; +import com.google.gerrit.server.update.RepoContext; import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.ArrayList; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/mail/receive/MailProcessor.java b/gerrit-server/src/main/java/com/google/gerrit/server/mail/receive/MailProcessor.java index cd70d3f445..fee090a266 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/mail/receive/MailProcessor.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/mail/receive/MailProcessor.java @@ -47,6 +47,8 @@ import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.update.BatchUpdate; +import com.google.gerrit.server.update.ChangeContext; +import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.ManualRequestContext; import com.google.gerrit.server.util.OneOffRequestContext; @@ -221,7 +223,7 @@ public class MailProcessor { } @Override - public boolean updateChange(BatchUpdate.ChangeContext ctx) + public boolean updateChange(ChangeContext ctx) throws OrmException, UnprocessableEntityException { changeControl = ctx.getControl(); patchSet = psUtil.get(ctx.getDb(), ctx.getNotes(), psId); @@ -296,7 +298,7 @@ public class MailProcessor { } @Override - public void postUpdate(BatchUpdate.Context ctx) throws Exception { + public void postUpdate(Context ctx) throws Exception { String patchSetComment = null; if (parsedComments.get(0).type == MailComment.CommentType.CHANGE_MESSAGE) { patchSetComment = parsedComments.get(0).message; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/notedb/PrimaryStorageMigrator.java b/gerrit-server/src/main/java/com/google/gerrit/server/notedb/PrimaryStorageMigrator.java index 98d31aaf1d..8a178b0385 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/notedb/PrimaryStorageMigrator.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/notedb/PrimaryStorageMigrator.java @@ -50,7 +50,7 @@ import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gerrit.server.update.BatchUpdate.ChangeContext; +import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.UpdateException; import com.google.gwtorm.server.AtomicUpdate; import com.google.gwtorm.server.OrmException; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/update/BatchUpdate.java b/gerrit-server/src/main/java/com/google/gerrit/server/update/BatchUpdate.java index 3595be9471..67a33c67ca 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/update/BatchUpdate.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/update/BatchUpdate.java @@ -39,7 +39,6 @@ import com.google.gerrit.metrics.Description.Units; import com.google.gerrit.metrics.Field; import com.google.gerrit.metrics.MetricMaker; import com.google.gerrit.metrics.Timer1; -import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.Project; @@ -47,7 +46,6 @@ import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDbWrapper; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.GerritPersonIdent; -import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.config.AllUsersName; import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.extensions.events.GitReferenceUpdated; @@ -127,28 +125,10 @@ public class BatchUpdate implements AutoCloseable { BatchUpdate create(ReviewDb db, Project.NameKey project, CurrentUser user, Timestamp when); } - /** Order of execution of the various phases. */ - public enum Order { - /** - * Update the repository and execute all ref updates before touching the database. - * - *

The default and most common, as Gerrit does not behave well when a patch set has no - * corresponding ref in the repo. - */ - REPO_BEFORE_DB, - - /** - * Update the database before touching the repository. - * - *

Generally only used when deleting patch sets, which should be deleted first from the - * database (for the same reason as above.) - */ - DB_BEFORE_REPO; - } - - public class Context { + private class ContextImpl implements Context { private Repository repoWrapper; + @Override public Repository getRepository() throws IOException { if (repoWrapper == null) { repoWrapper = new ReadOnlyRepository(BatchUpdate.this.getRepository()); @@ -156,67 +136,61 @@ public class BatchUpdate implements AutoCloseable { return repoWrapper; } + @Override public RevWalk getRevWalk() throws IOException { return BatchUpdate.this.getRevWalk(); } + @Override public Project.NameKey getProject() { return project; } + @Override public Timestamp getWhen() { return when; } + @Override + public TimeZone getTimeZone() { + return tz; + } + + @Override public ReviewDb getDb() { return db; } + @Override public CurrentUser getUser() { return user; } - public IdentifiedUser getIdentifiedUser() { - checkNotNull(user); - return user.asIdentifiedUser(); - } - - public Account getAccount() { - checkNotNull(user); - return user.asIdentifiedUser().getAccount(); - } - - public Account.Id getAccountId() { - checkNotNull(user); - return user.getAccountId(); - } - + @Override public Order getOrder() { return order; } } - public class RepoContext extends Context { + private class RepoContextImpl extends ContextImpl implements RepoContext { @Override public Repository getRepository() throws IOException { return BatchUpdate.this.getRepository(); } + @Override public ObjectInserter getInserter() throws IOException { return BatchUpdate.this.getObjectInserter(); } + @Override public void addRefUpdate(ReceiveCommand cmd) throws IOException { initRepository(); commands.add(cmd); } - - public TimeZone getTimeZone() { - return tz; - } } - public class ChangeContext extends Context { + private class ChangeContextImpl extends ContextImpl implements ChangeContext { private final ChangeControl ctl; private final Map updates; private final ReviewDbWrapper dbWrapper; @@ -226,7 +200,7 @@ public class BatchUpdate implements AutoCloseable { private boolean deleted; private boolean bumpLastUpdatedOn = true; - protected ChangeContext( + protected ChangeContextImpl( ChangeControl ctl, ReviewDbWrapper dbWrapper, Repository repo, RevWalk rw) { this.ctl = ctl; this.dbWrapper = dbWrapper; @@ -251,6 +225,7 @@ public class BatchUpdate implements AutoCloseable { return threadLocalRevWalk; } + @Override public ChangeUpdate getUpdate(PatchSet.Id psId) { ChangeUpdate u = updates.get(psId); if (u == null) { @@ -264,27 +239,18 @@ public class BatchUpdate implements AutoCloseable { return u; } - public ChangeNotes getNotes() { - ChangeNotes n = ctl.getNotes(); - checkNotNull(n); - return n; - } - + @Override public ChangeControl getControl() { checkNotNull(ctl); return ctl; } - public Change getChange() { - Change c = ctl.getChange(); - checkNotNull(c); - return c; - } - + @Override public void bumpLastUpdatedOn(boolean bump) { bumpLastUpdatedOn = bump; } + @Override public void deleteChange() { deleted = true; } @@ -651,7 +617,7 @@ public class BatchUpdate implements AutoCloseable { } public BatchUpdate insertChange(InsertChangeOp op) { - Context ctx = new Context(); + ContextImpl ctx = new ContextImpl(); Change c = op.createChange(ctx); checkArgument( !newChanges.containsKey(c.getId()), "only one op allowed to create change %s", c.getId()); @@ -675,7 +641,7 @@ public class BatchUpdate implements AutoCloseable { private void executeUpdateRepo() throws UpdateException, RestApiException { try { logDebug("Executing updateRepo on {} ops", ops.size()); - RepoContext ctx = new RepoContext(); + RepoContextImpl ctx = new RepoContextImpl(); for (Op op : ops.values()) { op.updateRepo(ctx); } @@ -952,7 +918,7 @@ public class BatchUpdate implements AutoCloseable { try { db.changes().beginTransaction(id); try { - ChangeContext ctx = newChangeContext(db, repo, rw, id); + ChangeContextImpl ctx = newChangeContext(db, repo, rw, id); NoteDbChangeState oldState = NoteDbChangeState.parse(ctx.getChange()); NoteDbChangeState.checkNotReadOnly(oldState, skewMs); @@ -1038,8 +1004,8 @@ public class BatchUpdate implements AutoCloseable { } } - private ChangeContext newChangeContext(ReviewDb db, Repository repo, RevWalk rw, Change.Id id) - throws OrmException { + private ChangeContextImpl newChangeContext( + ReviewDb db, Repository repo, RevWalk rw, Change.Id id) throws OrmException { Change c = newChanges.get(id); boolean isNew = c != null; if (isNew) { @@ -1075,10 +1041,10 @@ public class BatchUpdate implements AutoCloseable { } ChangeNotes notes = changeNotesFactory.createForBatchUpdate(c, !isNew); ChangeControl ctl = changeControlFactory.controlFor(notes, user); - return new ChangeContext(ctl, new BatchUpdateReviewDb(db), repo, rw); + return new ChangeContextImpl(ctl, new BatchUpdateReviewDb(db), repo, rw); } - private NoteDbUpdateManager stageNoteDbUpdate(ChangeContext ctx, boolean deleted) + private NoteDbUpdateManager stageNoteDbUpdate(ChangeContextImpl ctx, boolean deleted) throws OrmException, IOException { logDebug("Staging NoteDb update"); NoteDbUpdateManager updateManager = @@ -1129,7 +1095,7 @@ public class BatchUpdate implements AutoCloseable { } } - private static Iterable changesToUpdate(ChangeContext ctx) { + private static Iterable changesToUpdate(ChangeContextImpl ctx) { Change c = ctx.getChange(); if (ctx.bumpLastUpdatedOn && c.getLastUpdatedOn().before(ctx.getWhen())) { c.setLastUpdatedOn(ctx.getWhen()); @@ -1138,7 +1104,7 @@ public class BatchUpdate implements AutoCloseable { } private void executePostOps() throws Exception { - Context ctx = new Context(); + ContextImpl ctx = new ContextImpl(); for (Op op : ops.values()) { op.postUpdate(ctx); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/update/ChangeContext.java b/gerrit-server/src/main/java/com/google/gerrit/server/update/ChangeContext.java new file mode 100644 index 0000000000..398986c5ba --- /dev/null +++ b/gerrit-server/src/main/java/com/google/gerrit/server/update/ChangeContext.java @@ -0,0 +1,75 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gerrit.server.update; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.gerrit.reviewdb.client.Change; +import com.google.gerrit.reviewdb.client.PatchSet; +import com.google.gerrit.server.notedb.ChangeNotes; +import com.google.gerrit.server.notedb.ChangeUpdate; +import com.google.gerrit.server.project.ChangeControl; + +/** + * Context for performing the {@link BatchUpdate.Op#updateChange} phase. + * + *

A single {@code ChangeContext} corresponds to updating a single change; if a {@link + * BatchUpdate} spans multiple changes, then multiple {@code ChangeContext} instances will be + * created. + */ +public interface ChangeContext extends Context { + /** + * Get an update for this change at a given patch set. + * + *

A single operation can modify changes at different patch sets. Commits in the NoteDb graph + * within this update are created in patch set order. + * + *

To get the current patch set ID, use {@link com.google.gerrit.server.PatchSetUtil#current}. + * + * @param psId patch set ID. + * @return handle for change updates. + */ + ChangeUpdate getUpdate(PatchSet.Id psId); + + /** + * @return control for this change. The user will be the same as {@link #getUser()}, and the + * change data is read within the same transaction that {@code updateChange} is executing. + */ + ChangeControl getControl(); + + /** + * @param bump whether to bump the value of {@link Change#getLastUpdatedOn()} field before storing + * to ReviewDb. For NoteDb, the value is always incremented (assuming the update is not + * otherwise a no-op). + */ + void bumpLastUpdatedOn(boolean bump); + + /** + * Instruct {@link BatchUpdate} to delete this change. + * + *

If called, all other updates are ignored. + */ + void deleteChange(); + + /** @return notes corresponding to {@link #getControl()}. */ + default ChangeNotes getNotes() { + return checkNotNull(getControl().getNotes()); + } + + /** @return change corresponding to {@link #getControl()}. */ + default Change getChange() { + return checkNotNull(getControl().getChange()); + } +} diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/update/Context.java b/gerrit-server/src/main/java/com/google/gerrit/server/update/Context.java new file mode 100644 index 0000000000..f3940664f9 --- /dev/null +++ b/gerrit-server/src/main/java/com/google/gerrit/server/update/Context.java @@ -0,0 +1,108 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gerrit.server.update; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.gerrit.reviewdb.client.Account; +import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.server.ReviewDb; +import com.google.gerrit.server.CurrentUser; +import com.google.gerrit.server.IdentifiedUser; +import java.io.IOException; +import java.sql.Timestamp; +import java.util.TimeZone; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.revwalk.RevWalk; + +/** + * Context for performing a {@link BatchUpdate}. + * + *

A single update may span multiple changes, but they all belong to a single repo. + */ +public interface Context { + /** @return the project name this update operates on. */ + Project.NameKey getProject(); + + /** + * Get an open repository instance for this project. + * + *

Will be opened lazily if necessary; callers should not close the repo. In some phases of the + * update, the repository might be read-only; see {@link BatchUpdate.Op} for details. + * + * @return repository instance. + * @throws IOException if an error occurred opening the repo. + */ + Repository getRepository() throws IOException; + + /** + * Get a walk for this project. + * + *

The repository will be opened lazily if necessary; callers should not close the walk. + * + * @return walk. + * @throws IOException if an error occurred opening the repo. + */ + RevWalk getRevWalk() throws IOException; + + /** @return the timestamp at which this update takes place. */ + Timestamp getWhen(); + + /** + * @return the time zone in which this update takes place. In the current implementation, this is + * always the time zone of the server. + */ + TimeZone getTimeZone(); + + /** + * @return an open ReviewDb database. Callers should not manage transactions or call mutating + * methods on the Changes table. Mutations on other tables (including other entities in the + * change entity group) are fine. + */ + ReviewDb getDb(); + + /** + * @return user performing the update. In the current implementation, this is always an {@link + * IdentifiedUser} or {@link com.google.gerrit.server.InternalUser}. + */ + CurrentUser getUser(); + + /** @return order in which operations are executed in this update. */ + Order getOrder(); + + /** + * @return identified user performing the update; throws an unchecked exception if the user is not + * an {@link IdentifiedUser} + */ + default IdentifiedUser getIdentifiedUser() { + return checkNotNull(getUser()).asIdentifiedUser(); + } + + /** + * @return account of the user performing the update; throws if the user is not an {@link + * IdentifiedUser} + */ + default Account getAccount() { + return getIdentifiedUser().getAccount(); + } + + /** + * @return account ID of the user performing the update; throws if the user is not an {@link + * IdentifiedUser} + */ + default Account.Id getAccountId() { + return getIdentifiedUser().getAccountId(); + } +} diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/update/Order.java b/gerrit-server/src/main/java/com/google/gerrit/server/update/Order.java new file mode 100644 index 0000000000..fb64b7ba0c --- /dev/null +++ b/gerrit-server/src/main/java/com/google/gerrit/server/update/Order.java @@ -0,0 +1,34 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gerrit.server.update; + +/** Order of execution of the various phases of a {@link BatchUpdate}. */ +public enum Order { + /** + * Update the repository and execute all ref updates before touching the database. + * + *

The default and most common, as Gerrit does not behave well when a patch set has no + * corresponding ref in the repo. + */ + REPO_BEFORE_DB, + + /** + * Update the database before touching the repository. + * + *

Generally only used when deleting patch sets, which should be deleted first from the + * database (for the same reason as above.) + */ + DB_BEFORE_REPO; +} diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/update/RepoContext.java b/gerrit-server/src/main/java/com/google/gerrit/server/update/RepoContext.java new file mode 100644 index 0000000000..825f6d1604 --- /dev/null +++ b/gerrit-server/src/main/java/com/google/gerrit/server/update/RepoContext.java @@ -0,0 +1,41 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gerrit.server.update; + +import java.io.IOException; +import org.eclipse.jgit.lib.ObjectInserter; +import org.eclipse.jgit.transport.ReceiveCommand; + +/** Context for performing the {@link BatchUpdate.Op#updateRepo} phase. */ +public interface RepoContext extends Context { + /** + * @return inserter for writing to the repo. Callers should not flush; the walk returned by {@link + * #getRevWalk()} is able to read back objects inserted by this inserter without flushing + * first. + * @throws IOException if an error occurred opening the repo. + */ + ObjectInserter getInserter() throws IOException; + + /** + * Add a command to the pending list of commands. + * + *

Callers should use this method instead of writing directly to the repository returned by + * {@link #getRepository()}. + * + * @param cmd ref update command. + * @throws IOException if an error occurred opening the repo. + */ + void addRefUpdate(ReceiveCommand cmd) throws IOException; +} diff --git a/gerrit-server/src/test/java/com/google/gerrit/server/update/BatchUpdateTest.java b/gerrit-server/src/test/java/com/google/gerrit/server/update/BatchUpdateTest.java index 49724f8f32..0fec8cfc6c 100644 --- a/gerrit-server/src/test/java/com/google/gerrit/server/update/BatchUpdateTest.java +++ b/gerrit-server/src/test/java/com/google/gerrit/server/update/BatchUpdateTest.java @@ -12,7 +12,6 @@ import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.account.AccountManager; import com.google.gerrit.server.account.AuthRequest; import com.google.gerrit.server.schema.SchemaCreator; -import com.google.gerrit.server.update.BatchUpdate.RepoContext; import com.google.gerrit.server.update.BatchUpdate.RepoOnlyOp; import com.google.gerrit.server.util.RequestContext; import com.google.gerrit.server.util.ThreadLocalRequestContext;