def __normalize_patchset(patchset)
patchset.map do |hunk|
case hunk
when Diff::LCS::ContextChange, Diff::LCS::Change
hunk
when Array
if (not hunk[0].kind_of?(Array)) and hunk[1].kind_of?(Array) and hunk[2].kind_of?(Array)
Diff::LCS::ContextChange.from_a(hunk)
else
hunk.map do |change|
case change
when Diff::LCS::ContextChange, Diff::LCS::Change
change
when Array
if change[1].kind_of?(Array)
Diff::LCS::ContextChange.from_a(change)
else
Diff::LCS::Change.from_a(change)
end
end
end
end
else
raise ArgumentError, "Cannot normalise a hunk of class #{hunk.class}."
end
end.flatten
end