* @see #pullPoTargetComment
*/
protected boolean pushPoTargetComment(PoTargetHeader fromHeader,
HPoTargetHeader toHeader, MergeType mergeType) {
boolean changed = false;
HSimpleComment hComment = toHeader.getComment();
if (hComment == null) {
hComment = new HSimpleComment();
}
String fromComment = fromHeader.getComment();
String toComment = hComment.getComment();
if (!equals(fromComment, toComment)) {
// skip #zanata lines
List<String> fromLines = splitLines(fromComment, ZANATA_TAG);
StringBuilder sb = new StringBuilder(fromComment.length());
switch (mergeType) {
case IMPORT:
for (String line : fromLines) {
if (sb.length() != 0)
sb.append(NEWLINE);
sb.append(line);
changed = true;
}
break;
default: // AUTO or anything else will merge comments
// to merge, we just append new lines, skip old lines
List<String> toLines = Collections.emptyList();
if (toComment != null) {
sb.append(toComment);
toLines = splitLines(toComment, null);
}
for (String line : fromLines) {
if (!toLines.contains(line)) {
if (sb.length() != 0)
sb.append(NEWLINE);
sb.append(line);
changed = true;
}
}
break;
}
if (changed) {
hComment.setComment(sb.toString());
toHeader.setComment(hComment);
}
}
return changed;
}