Simplify Rebase.CurrentRevision

Rebase.CurrentRevision is just a wrapper around Rebase. Instead of
extending RetryingRestModifyView and calling the applyImpl method from
Rebase to bypass the retrying from Rebase, we can simply implement
RestModifyView and delegate to the apply method of Rebase which takes
care of the retrying.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I307bb24c47100964b9b0e9d3666f95fab6e857a6
This commit is contained in:
Edwin Kempin
2019-10-22 10:17:58 +02:00
parent 789fde0009
commit 2d64d1d263

View File

@@ -260,28 +260,23 @@ public class Rebase extends RetryingRestModifyView<RevisionResource, RebaseInput
return description;
}
public static class CurrentRevision
extends RetryingRestModifyView<ChangeResource, RebaseInput, ChangeInfo> {
public static class CurrentRevision implements RestModifyView<ChangeResource, RebaseInput> {
private final PatchSetUtil psUtil;
private final Rebase rebase;
@Inject
CurrentRevision(RetryHelper retryHelper, PatchSetUtil psUtil, Rebase rebase) {
super(retryHelper);
CurrentRevision(PatchSetUtil psUtil, Rebase rebase) {
this.psUtil = psUtil;
this.rebase = rebase;
}
@Override
protected Response<ChangeInfo> applyImpl(
BatchUpdate.Factory updateFactory, ChangeResource rsrc, RebaseInput input)
throws Exception {
public Response<ChangeInfo> apply(ChangeResource rsrc, RebaseInput input) throws Exception {
PatchSet ps = psUtil.current(rsrc.getNotes());
if (ps == null) {
throw new ResourceConflictException("current revision is missing");
}
return Response.ok(
rebase.applyImpl(updateFactory, new RevisionResource(rsrc, ps), input).value());
return Response.ok(rebase.apply(new RevisionResource(rsrc, ps), input).value());
}
}
}