private static DiffHunk ReadHunk(LineReader reader)
{
// Read hunk header
string header = reader.Current;
if (String.IsNullOrEmpty(header))
{
return null;
}
Match m = HunkHeaderRegex.Match(header);
if (!m.Success)
{
// End of file diff
return null;
}
reader.NextLine();
SourceCoordinate original = ReadSourceCoord(m.Groups["l1"].Value, m.Groups["c1"].Value);
SourceCoordinate modified = ReadSourceCoord(m.Groups["l2"].Value, m.Groups["c2"].Value);
string comment = m.Groups["c"].Value.Trim();
DiffHunk hunk = new DiffHunk(original, modified, comment);
LineDiff line;
while ((line = ReadLine(reader)) != null)
{
hunk.Lines.Add(line);
}
return hunk;
}