1075: def __normalize_patchset(patchset)
1076: patchset.map do |hunk|
1077: case hunk
1078: when Diff::LCS::ContextChange, Diff::LCS::Change
1079: hunk
1080: when Array
1081: if (not hunk[0].kind_of?(Array)) and hunk[1].kind_of?(Array) and hunk[2].kind_of?(Array)
1082: Diff::LCS::ContextChange.from_a(hunk)
1083: else
1084: hunk.map do |change|
1085: case change
1086: when Diff::LCS::ContextChange, Diff::LCS::Change
1087: change
1088: when Array
1089:
1090:
1091: if change[1].kind_of?(Array)
1092: Diff::LCS::ContextChange.from_a(change)
1093: else
1094: Diff::LCS::Change.from_a(change)
1095: end
1096: end
1097: end
1098: end
1099: else
1100: raise ArgumentError, "Cannot normalise a hunk of class #{hunk.class}."
1101: end
1102: end.flatten
1103: end