Tweak PatchSetInserter to look more like ChangeInserter

Don't pass in the repo and RevWalk, since those should come from the
RepoContext. Change callers to use the same Repository/RevWalk/
ObjectInserter instances and call setRepository on the enclosing
BatchUpdate.

Don't lazily compute patch set ID; have callers compute it themselves
and pass it in at construction time, since we no longer have a
Repository instance in the PatchSetInserter.

Change-Id: I845b887ae7ffc2c1a14bad13c62c41ff1ff6fc34
This commit is contained in:
Dave Borowitz
2015-10-19 14:02:55 -04:00
parent 15eb1e58fd
commit 0b73d356c5
10 changed files with 114 additions and 87 deletions

View File

@@ -31,6 +31,7 @@ import com.google.gerrit.server.git.validators.CommitValidators;
import com.google.gerrit.server.patch.PatchSetInfoFactory;
import com.google.gerrit.server.project.InvalidChangeOperationException;
import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gerrit.server.project.NoSuchProjectException;
import com.google.gwtorm.server.OrmException;
import org.eclipse.jgit.lib.ObjectId;
@@ -117,9 +118,9 @@ public class RebaseIfNecessary extends SubmitStrategy {
setRefLogIdent();
} catch (MergeConflictException e) {
n.setStatusCode(CommitMergeStatus.REBASE_MERGE_CONFLICT);
} catch (NoSuchChangeException | OrmException | IOException
| InvalidChangeOperationException | UpdateException
| RestApiException e) {
} catch (NoSuchChangeException | NoSuchProjectException
| OrmException | IOException | InvalidChangeOperationException
| UpdateException | RestApiException e) {
// TODO(dborowitz): Allow Submit to unwrap ResourceConflictException
// so it can turn into a 409.
throw new MergeException("Cannot rebase " + n.name(), e);