in src/main/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreator.java [539:561]
private String getBaseChangeId(List<String> parents, String branch)
throws InvalidQueryParameterException, RestApiException {
if (parents.isEmpty()) {
log.info("No base change id for change with no parents.");
return null;
}
// 1) Get topic of first parent
String firstParentTopic = getTopic(parents.get(0));
if (firstParentTopic == null) {
return null;
}
// 2) query that topic and use that to find A'
List<ChangeInfo> changesInTopic = getChangesInTopicAndBranch(firstParentTopic, branch);
String firstParent = parents.get(0);
for (ChangeInfo change : changesInTopic) {
List<CommitInfo> topicChangeParents =
change.revisions.get(change.currentRevision).commit.parents;
if (topicChangeParents.size() > 1 && topicChangeParents.get(1).commit.equals(firstParent)) {
return String.valueOf(change._number);
}
}
return null;
}