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