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
This commit is contained in:
Dave Borowitz
2015-10-07 16:17:44 -04:00
parent 4865d0f37d
commit 70166683ff
2 changed files with 6 additions and 57 deletions

View File

@@ -76,8 +76,6 @@ public class PatchSetInserter {
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 @@ public class PatchSetInserter {
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;
@@ -117,34 +114,6 @@ public class PatchSetInserter {
private Account.Id uploader;
private boolean allowClosed;
@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,
@@ -169,7 +138,6 @@ public class PatchSetInserter {
this.commitValidatorsFactory = commitValidatorsFactory;
this.replacePatchSetFactory = replacePatchSetFactory;
this.batchUpdate = null;
this.git = git;
this.revWalk = revWalk;
this.commit = commit;
@@ -257,26 +225,11 @@ public class PatchSetInserter {
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 @@ public class PatchSetInserter {
}
private void init() throws IOException {
if (git == null) {
git = batchUpdate.getRepository();
revWalk = batchUpdate.getRevWalk();
}
if (sshInfo == null) {
sshInfo = new NoSshInfo();
}