in src/main/java/com/googlesource/gerrit/plugins/importer/ReplayInlineCommentsStep.java [116:157]
void replay()
throws RestApiException, OrmException, IOException, NoSuchChangeException,
NoSuchAccountException, ConfigInvalidException, PatchListNotAvailableException {
ChangeNotes notes = changeNotesFactory.createChecked(db, change);
for (PatchSet ps : ChangeUtil.PS_ID_ORDER.sortedCopy(psUtil.byChange(db, notes))) {
Iterable<CommentInfo> comments = api.getComments(changeInfo._number, ps.getRevision().get());
if (resume) {
if (comments == null) {
// the revision does not exist in the source system,
// it must be a revision that was created in the target system after
// the initial import
log.warn(
String.format(
"Project %s was modified in target system: "
+ "Skip replay inline comments for patch set %s"
+ " which doesn't exist in the source system.",
change.getProject().get(), ps.getId().toString()));
continue;
}
comments = filterComments(ps, comments);
} else if (comments == null) {
log.warn(
String.format(
"Cannot retrieve comments for revision %s, "
+ "revision not found in source system: "
+ "Skip replay inline comments for patch set %s of project %s.",
ps.getRevision().get(), ps.getId().toString(), change.getProject().get()));
continue;
}
Multimap<Account.Id, CommentInfo> commentsByAuthor = ArrayListMultimap.create();
for (CommentInfo comment : comments) {
Account.Id id = accountUtil.resolveUser(api, comment.author);
commentsByAuthor.put(id, comment);
}
for (Account.Id id : commentsByAuthor.keySet()) {
insertComments(ps, id, commentsByAuthor.get(id));
}
}
}