Pass only ref name into ChangeInserter, not ref control

ChangeInserter only needs the ref control when validation is done and
it can just instantiate it for this purpose.

The project and the user are provided by the Context and a provided
ref control may have been created for another project or user. By not
passing in the ref control we avoid this possible inconsistency.

Also remove the getProject() and getUser() methods from
ChangeInserter. They were only used by tests and were needed only
because the API required to pass in the project and user twice, once
through ref control to the ChangeInserter and once to the BatchUpdate.

Change-Id: I2c4faf27e3c1183a474fecfa06dbbbc14a3c143f
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2016-01-18 10:25:13 +01:00
parent 4d1f3c3da9
commit 0242ea54d3
10 changed files with 174 additions and 186 deletions

View File

@@ -1585,7 +1585,7 @@ public class ReceiveCommits {
final List<String> idList = c.getFooterLines(CHANGE_ID);
if (idList.isEmpty()) {
newChanges.add(new CreateRequest(magicBranch.ctl, c));
newChanges.add(new CreateRequest(c, magicBranch.dest.get()));
continue;
}
@@ -1648,7 +1648,7 @@ public class ReceiveCommits {
newChangeIds.add(p.changeKey);
}
newChanges.add(new CreateRequest(magicBranch.ctl, p.commit));
newChanges.add(new CreateRequest(p.commit, magicBranch.dest.get()));
}
} catch (IOException e) {
// Should never happen, the core receive process would have
@@ -1731,11 +1731,11 @@ public class ReceiveCommits {
Change change;
Collection<String> groups;
CreateRequest(RefControl ctl, RevCommit c)
CreateRequest(RevCommit c, String refName)
throws OrmException {
commit = c;
changeId = new Change.Id(seq.nextChangeId());
ins = changeInserterFactory.create(ctl, changeId, c)
ins = changeInserterFactory.create(changeId, c, refName)
.setDraft(magicBranch.draft)
.setTopic(magicBranch.topic)
// Changes already validated in validateNewCommits.