Rewrite RebaseChange as a BatchUpdate.Op

This operation does the actual rebase before delegating to a
PatchSetInserter. The actual PatchSetInserter object can't be created
until after we create the rebased commit, which happens in
RebaseChangeOp's updateRepo method. Thus the PatchSetInserter cannot
be added to the enclosing BatchUpdate by the caller, and instead we
hide that instance entirely in RebaseChange, passing through the
subset of setters that is needed.

We need to leave a non-BatchUpdate-related RebaseUtil class that
contains canRebase, which is still used in several places. Refactor
this slightly to avoid double-opening the repository in some cases.

Change-Id: I586a85fe9e6f878fe6a7ba1ab4d641b98b1649ab
This commit is contained in:
Dave Borowitz
2015-10-19 14:06:54 -04:00
parent 668ad57d91
commit ff473bb345
11 changed files with 461 additions and 426 deletions

View File

@@ -36,6 +36,7 @@ import com.google.gerrit.server.cache.h2.DefaultCacheFactory;
import com.google.gerrit.server.change.ChangeKindCacheImpl;
import com.google.gerrit.server.change.MergeabilityCacheImpl;
import com.google.gerrit.server.change.PatchSetInserter;
import com.google.gerrit.server.change.RebaseChangeOp;
import com.google.gerrit.server.config.CanonicalWebUrl;
import com.google.gerrit.server.config.CanonicalWebUrlProvider;
import com.google.gerrit.server.config.DisableReverseDnsLookup;
@@ -110,6 +111,7 @@ public class BatchProgramModule extends FactoryModule {
factory(BatchUpdate.Factory.class);
factory(MergeUtil.Factory.class);
factory(PatchSetInserter.Factory.class);
factory(RebaseChangeOp.Factory.class);
bind(new TypeLiteral<Set<AccountGroup.UUID>>() {})
.annotatedWith(GitUploadPackGroups.class)