PatchSetInserter: Remove broken, unused factory method
The only remaining constructor always sets the repository, so we no
longer need to initialize it in init(). As a result, the repo field
and related fields can be made final as well.
Even better, we no longer need to distinguish between the
execute/don't execute cases in insert().
Change-Id: I39af53f954e746eee6b0e8034ccf9f68bb5549ff
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 a760c9b..e728237 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
@@ -76,8 +76,6 @@
public static interface Factory {
PatchSetInserter create(Repository git, RevWalk revWalk, ChangeControl ctl,
RevCommit commit);
- PatchSetInserter create(BatchUpdate batchUpdate, ChangeControl ctl,
- RevCommit commit);
}
/**
@@ -102,10 +100,9 @@
private final RevCommit commit;
private final ChangeControl ctl;
private final IdentifiedUser user;
- private final BatchUpdate batchUpdate;
+ private final Repository git;
+ private final RevWalk revWalk;
- private Repository git;
- private RevWalk revWalk;
private PatchSet patchSet;
private String message;
private SshInfo sshInfo;
@@ -120,34 +117,6 @@
@AssistedInject
public PatchSetInserter(ChangeHooks hooks,
ReviewDb db,
- ApprovalsUtil approvalsUtil,
- ApprovalCopier approvalCopier,
- ChangeMessagesUtil cmUtil,
- PatchSetInfoFactory patchSetInfoFactory,
- CommitValidators.Factory commitValidatorsFactory,
- ReplacePatchSetSender.Factory replacePatchSetFactory,
- @Assisted BatchUpdate batchUpdate,
- @Assisted ChangeControl ctl,
- @Assisted RevCommit commit) {
- this.hooks = hooks;
- this.db = db;
- this.batchUpdateFactory = null;
- this.approvalsUtil = approvalsUtil;
- this.approvalCopier = approvalCopier;
- this.cmUtil = cmUtil;
- this.patchSetInfoFactory = patchSetInfoFactory;
- this.commitValidatorsFactory = commitValidatorsFactory;
- this.replacePatchSetFactory = replacePatchSetFactory;
-
- this.batchUpdate = batchUpdate;
- this.commit = commit;
- this.ctl = ctl;
- this.user = checkUser(ctl);
- }
-
- @AssistedInject
- public PatchSetInserter(ChangeHooks hooks,
- ReviewDb db,
BatchUpdate.Factory batchUpdateFactory,
ApprovalsUtil approvalsUtil,
ApprovalCopier approvalCopier,
@@ -169,7 +138,6 @@
this.commitValidatorsFactory = commitValidatorsFactory;
this.replacePatchSetFactory = replacePatchSetFactory;
- this.batchUpdate = null;
this.git = git;
this.revWalk = revWalk;
this.commit = commit;
@@ -257,26 +225,11 @@
init();
validate();
- // TODO(dborowitz): Kill once callers are migrated.
- // Eventually, callers should always be responsible for executing.
- boolean executeBatch = false;
- BatchUpdate bu = batchUpdate;
- if (batchUpdate == null) {
- bu = batchUpdateFactory.create(
- db, ctl.getChange().getProject(), patchSet.getCreatedOn());
- executeBatch = true;
- }
-
Op op = new Op();
- try {
+ try (BatchUpdate bu = batchUpdateFactory.create(
+ db, ctl.getChange().getProject(), patchSet.getCreatedOn())) {
bu.addOp(ctl, op);
- if (executeBatch) {
- bu.execute();
- }
- } finally {
- if (executeBatch) {
- bu.close();
- }
+ bu.execute();
}
return op.change;
}
@@ -381,10 +334,6 @@
}
private void init() throws IOException {
- if (git == null) {
- git = batchUpdate.getRepository();
- revWalk = batchUpdate.getRevWalk();
- }
if (sshInfo == null) {
sshInfo = new NoSshInfo();
}
diff --git a/plugins/replication b/plugins/replication
index 1fda499..e9fd843 160000
--- a/plugins/replication
+++ b/plugins/replication
@@ -1 +1 @@
-Subproject commit 1fda499fea1052fc7accf96f32a3bb89718a0e0e
+Subproject commit e9fd84329b77544cd6d61bc833f0000c54110299