private void OnStats(object sender, RoutedEventArgs ev) { // method change paths CommitDescription.Text = ""; var graph = this.currentGraph; var subGraph = new Graph(); subGraph.Nodes.AddRange(graph.Nodes.Where(n => n.IsMethodDeclartionNode())); subGraph.Edges.AddRange(graph.Edges.Where(e => e.from.IsMethodDeclartionNode() && e.to.IsMethodDeclartionNode())); var disconnectedSubGraphs = subGraph.GetConnectedSubGraphs(true, false).ToList(); var sinks = subGraph.SinkVertexs(); ConcurrentBag <int> changes = new ConcurrentBag <int>(); ConcurrentBag <Tuple <int, string> > allChanges = new ConcurrentBag <Tuple <int, string> >(); foreach (var methodHistory in subGraph.GetConnectedSubGraphs(true, false)) { var s = methodHistory.Nodes.Where(n => methodHistory.Edges.All(e => e.from != n)).FirstOrDefault(); if (methodHistory.Edges.Count == methodHistory.Nodes.Count - 1) { var changeEdges = methodHistory.Edges.Where(e => e.type != Edge.EdgeType.NoCodeChange).Count(); allChanges.Add(new Tuple <int, string>(changeEdges, NodeDescriber.Decribe(s) + " had " + changeEdges + " changes \n")); changes.Add(changeEdges); } else { var foo = graph.Edges.Where(e => e.to == s).ToList(); allChanges.Add(new Tuple <int, string>(methodHistory.Edges.Count, NodeDescriber.Decribe(s) + " had " + methodHistory.Edges.Count + " changes \n")); } } CommitDescription.Text += "Overall " + changes.Count + " Methods changed " + changes.Min() + " - " + changes.Max() + " avrg. " + changes.Average() + "\n"; var tmp = allChanges.ToList(); tmp.Sort((s1, s2) => s2.Item1.CompareTo(s1.Item1)); // desending foreach (var t in tmp.Take(20)) { CommitDescription.Text += t.Item2; } }
private void CommitButtonPressed(object o, Node n) { HighlightSingleToggleButton(o); this.GraphDisplay.Graph = AddNodeToDisplay(n); ViewCode(this.CodeDisplay, n); CommitDescription.Text = ""; if (n.Type == Node.NodeType.Commit) { BuildFileTreeForNode(n); var changesInThisCommit = currentGraph.GetConnectedSubGraph(n, new Edge.EdgeType[] { Edge.EdgeType.SyntaxHierarchialyAbove, Edge.EdgeType.HierarchialyAbove, Edge.EdgeType.InFile }, false, false); foreach (var node in changesInThisCommit.Nodes) { switch (node.Type) { case Node.NodeType.Commit: CommitDescription.Text += " Summery for commit " + node.Content + "\n"; break; case Node.NodeType.Syntax: { var toNode = currentGraph.Edges.Where(e => e.to == node && e.type.IsCodeModificationEdge()); if (toNode.Any()) { CommitDescription.Text += " Changed " + NodeDescriber.Decribe(node) + "\n"; } else { CommitDescription.Text += " Created " + NodeDescriber.Decribe(node) + "\n"; } } break; default: break; } } } }