Exemple #1
0
        private bool HighlightCommit(Commit commit)
        {
            CommitVertex commitVertex = GetCommitVertex(commit);

            if (commitVertex.OnCurrentBranch)
            {
                return(false);
            }

            commitVertex.OnCurrentBranch = true;
            return(true);
        }
Exemple #2
0
        private void HighlightCommitsOnCurrentBranch(Commit commit, CommitVertex commitVertex)
        {
            if (commitVertex.OnCurrentBranch)
            {
                return;
            }
            commitVertex.OnCurrentBranch = true;

            foreach (var parent in commit.Parents)
            {
                HighlightCommitsOnCurrentBranch(parent, GetCommitVertex(parent));
            }
        }
Exemple #3
0
        private CommitVertex GetCommitVertex(Commit commit)
        {
            CommitVertex commitVertex;

            if (!_vertices.TryGetValue(commit.Sha, out commitVertex))
            {
                commitVertex = new CommitVertex(commit.Sha, commit.MessageShort)
                {
                    Description = commit.Message
                };
                _vertices.Add(commit.Sha, commitVertex);
            }

            return(commitVertex);
        }
Exemple #4
0
        private bool AddCommitToGraph(Commit commit, CommitVertex childVertex)
        {
            var commitVertex = GetCommitVertex(commit);

            _graph.AddVertex(commitVertex);
            if (childVertex != null)
            {
                var edge = new CommitEdge(childVertex, commitVertex);
                if (_edges.ContainsKey(edge.Id))
                {
                    return(false);
                }

                _graph.AddEdge(edge);
                _edges.Add(edge.Id, edge);
            }
            return(true);
        }
Exemple #5
0
        private void HighlightCommitsOnCurrentBranch(Commit commit, CommitVertex commitVertex)
        {
            Queue <Commit> queue = new Queue <Commit>();

            queue.Enqueue(commit);

            while (queue.Count != 0)
            {
                commit = queue.Dequeue();
                if (!HighlightCommit(commit))
                {
                    return;
                }

                foreach (var parent in commit.Parents)
                {
                    queue.Enqueue(parent);
                }
            }
        }
Exemple #6
0
        private void AddCommitsToGraph(Commit commit, CommitVertex childVertex)
        {
            var commitVertex = GetCommitVertex(commit);

            _graph.AddVertex(commitVertex);
            if (childVertex != null)
            {
                var edge = new CommitEdge(childVertex, commitVertex);
                if (_edges.ContainsKey(edge.Id))
                {
                    return;
                }
                _graph.AddEdge(edge);
                _edges.Add(edge.Id, edge);
            }

            foreach (var parent in commit.Parents)
            {
                AddCommitsToGraph(parent, commitVertex);
            }
        }
        private void AddCommitsToGraph(Commit commit, CommitVertex childVertex)
        {
            // KeyValuePair is faster than a Tuple in this case.
            // We create as many instances as we pass to the AddCommitToGraph.
            var queue = new Queue <CommitWithChildVertex>();

            queue.Enqueue(new CommitWithChildVertex(commit, childVertex));

            while (queue.Count != 0)
            {
                var commitIter = queue.Dequeue();
                if (!AddCommitToGraph(commitIter.Key, commitIter.Value))
                {
                    continue;
                }

                foreach (var parent in commitIter.Key.Parents)
                {
                    queue.Enqueue(new CommitWithChildVertex(parent, GetCommitVertex(commitIter.Key)));
                }
            }
        }