Set<String> affectedPathsBranch = new HashSet<String>();
Set<String> affectedPathsTrunk = new HashSet<String>();
StringBuilder diff = new StringBuilder();
for (int i = commits.size() - 1; i >= 0; i--) {
MongoCommit commit = commits.get(i);
Set<String> affectedPaths = commit.getAffectedPaths();
for (String affectedPath : affectedPaths) {
if (branchId.equals(commit.getBranchId())) {
if (affectedPathsTrunk.contains(affectedPath)) {
return null;
}
affectedPathsBranch.add(affectedPath);
} else if (commit.getBranchId() == null){
if (affectedPathsBranch.contains(affectedPath)) {
return null;
}
affectedPathsTrunk.add(affectedPath);
}
}
if (branchId.equals(commit.getBranchId())) {
try {
diff.append(normalizeDiff(commit.getPath(), commit.getDiff()));
} catch (Exception e) {
LOG.error("Normalization error", e);
}
}
}