if (leftFileRevision == null) {
leftFileRevision = line.substring(CHANGE_LEFT.length());
}
if (isChangeLeft) {
f1l2 = i - 1;
diffList.add((f1l1 > f1l2) ? new Difference(Difference.ADD,
f1l1 - 1, 0, f2l1, f2l2,
text1.toString(),
text2.toString()) : (f2l1 > f2l2) ? new Difference(Difference.DELETE,
f1l1, f1l2, f2l1 - 1, 0,
text1.toString(),
text2.toString())
: new Difference(Difference.CHANGE,
f1l1, f1l2, f2l1, f2l2,
text1.toString(),
text2.toString()));
f1l1 = f1l2 = f2l1 = f2l2 = 0;
text1.delete(0, text1.length());
text2.delete(0, text2.length());
} else {
f1l1 = i;
}
}
isChangeLeft = !isChangeLeft;
continue;
} else if (line.startsWith(CHANGE_RIGHT)) {
if (generateDiffs) {
if (rightFileRevision == null) {
rightFileRevision = line.substring(CHANGE_RIGHT.length());
}
if (isChangeRight) {
f2l2 = j - 1;
diffList.add((f1l1 > f1l2) ? new Difference(Difference.ADD,
f1l1 - 1, 0, f2l1, f2l2,
text1.toString(),
text2.toString()) : (f2l1 > f2l2) ? new Difference(Difference.DELETE,
f1l1, f1l2, f2l1 - 1, 0,
text1.toString(),
text2.toString())
: new Difference(Difference.CHANGE,
f1l1, f1l2, f2l1, f2l2,
text1.toString(),
text2.toString()));
/*
diffList.add(new Difference((f1l1 > f1l2) ? Difference.ADD :
(f2l1 > f2l2) ? Difference.DELETE :
Difference.CHANGE,
f1l1, f1l2, f2l1, f2l2));
*/
f1l1 = f1l2 = f2l1 = f2l2 = 0;
text1.delete(0, text1.length());
text2.delete(0, text2.length());
} else {
f2l1 = j;
}
}
isChangeRight = !isChangeRight;
continue;
} else if (isChangeRight && line.indexOf(CHANGE_RIGHT) != -1) {
String lineText = line.substring(0, line.lastIndexOf(CHANGE_RIGHT));
if (generateDiffs) {
if (rightFileRevision == null) {
rightFileRevision = line.substring(line.lastIndexOf(CHANGE_RIGHT) + CHANGE_RIGHT.length());
}
text2.append(lineText);
f2l2 = j;
diffList.add((f1l1 > f1l2) ? new Difference(Difference.ADD,
f1l1 - 1, 0, f2l1, f2l2,
text1.toString(),
text2.toString()) : (f2l1 > f2l2) ? new Difference(Difference.DELETE,
f1l1, f1l2, f2l1 - 1, 0,
text1.toString(),
text2.toString())
: new Difference(Difference.CHANGE,
f1l1, f1l2, f2l1, f2l2,
text1.toString(),
text2.toString()));
f1l1 = f1l2 = f2l1 = f2l2 = 0;
text1.delete(0, text1.length());