private static void ParseBlameOutput(string output, List<Block> blocks, Dictionary<string, Commit> commits) { // read entire output of "git blame" using (StringReader reader = new StringReader(output)) { string line; while ((line = reader.ReadLine()) != null) { // read beginning line in block, with format "hash origLine startLine lineCount" string[] components = line.Split(' '); string commitId = components[0]; int originalStartLine = int.Parse(components[1], CultureInfo.InvariantCulture); int startLine = int.Parse(components[2], CultureInfo.InvariantCulture); int lineCount = int.Parse(components[3], CultureInfo.InvariantCulture); // read "tag value" pairs from block header, knowing that "filename" tag always ends the block Dictionary<string, string> tagValues = new Dictionary<string, string>(); Tuple<string, string> tagValue; do { line = reader.ReadLine(); tagValue = line.SplitOnSpace(); tagValues.Add(tagValue.Item1, tagValue.Item2); } while (tagValue.Item1 != "filename"); // check if this is a new commit Commit commit; if (!commits.TryGetValue(commitId, out commit)) { commit = CreateCommit(commitId, tagValues); commits.Add(commitId, commit); } // add this block to the output, ordered by its StartLine Block block = new Block(startLine, lineCount, commit, tagValues["filename"], originalStartLine); int index = blocks.BinarySearch(block, new GenericComparer<Block>((l, r) => l.StartLine.CompareTo(r.StartLine))); Debug.Assert(index < 0, "index < 0", "New block should not already be in the list."); if (index < 0) blocks.Insert(~index, block); } } }
public DisplayBlock(Rect authorPosition, Rect commitPosition, Rect summaryPosition, double alpha, int authorIndex, Block block) { m_authorPosition = authorPosition; m_commitPosition = commitPosition; m_summaryPosition = summaryPosition; m_alpha = alpha; m_authorIndex = authorIndex; m_block = block; m_commit = block.Commit; }