Exemple #1
0
            public void ReturnsTrueIfShasAreSame()
            {
                var commit = new CommitVertex("sha", "whatever");
                var other = new CommitVertex("sha", "doesn't matter");

                Assert.True(commit == other);
            }
Exemple #2
0
            public void ReturnsFalseIfShasAreDifferent()
            {
                var commit = new CommitVertex("sha1", "whatever");
                var other = new CommitVertex("sha2", "doesn't matter");

                Assert.False(commit.Equals(other));
            }
            public void ReturnsTrueIfShasAreSame()
            {
                var commit = new CommitVertex("sha", "whatever");
                var other  = new CommitVertex("sha", "doesn't matter");

                Assert.True(commit == other);
            }
            public void ReturnsFalseIfShasAreDifferent()
            {
                var commit = new CommitVertex("sha1", "whatever");
                var other  = new CommitVertex("sha2", "doesn't matter");

                Assert.False(commit.Equals(other));
                Assert.False(object.Equals(commit, other));
            }
Exemple #5
0
            public void SetsProperties()
            {
                var commit = new CommitVertex("shasha", "commit message");

                Assert.Equal("shasha", commit.Sha);
                Assert.Equal("commit message", commit.Message);
                Assert.NotNull(commit.Branches);
            }
            public void ReturnsFalseIfShasAreDifferent()
            {
                var commit = new CommitVertex("sha", "whatever");
                var other  = new CommitVertex("sha1", "doesn't matter");

                Assert.False(commit == other);
                Assert.True(commit != other);
            }
Exemple #7
0
            public void SetsProperties()
            {
                var commit = new CommitVertex("shasha", "commit message");

                Assert.Equal("shasha", commit.Sha);
                Assert.Equal("commit message", commit.Message);
                Assert.NotNull(commit.Branches);
            }
Exemple #8
0
            public void ReturnsFalseWhenComparedToNull()
            {
                var commit = new CommitVertex("sha", "message");
                CommitVertex other = null;

                Assert.False(commit.Equals(other));
                Assert.False(object.Equals(commit, other));
            }
            public void ReturnsFalseWhenComparedToNull()
            {
                var commit = new CommitVertex("sha", "message");
                const CommitVertex other = null;

                Assert.False(commit.Equals(other));
                Assert.False(object.Equals(commit, other));
            }
            public void SetsProperties()
            {
                var commit = new CommitVertex("shasha", "commit message");

                Assert.Equal("shasha", commit.Sha);
                Assert.Equal("commit message", commit.Message);
                Assert.NotNull(commit.Branches);
                Assert.Equal(8, commit.ShaLength);
                Assert.True(commit.AdornerMessageVisibility);    // expanded is false -> true
                Assert.False(commit.DescriptionShown);
            }
            public void SetsProperties()
            {
                var commit = new CommitVertex("shasha", "commit message");

                Assert.Equal("shasha", commit.Sha);
                Assert.Equal("commit message", commit.Message);
                Assert.NotNull(commit.Branches);
                Assert.Equal(8, commit.ShaLength);
                Assert.Equal(true, commit.AdornerMessageVisibility);    // expanded is false -> true
                Assert.Equal(false, commit.DescriptionShown);
            }
Exemple #12
0
 private void AddCommit(Commit commit)
 {
     var commitVertex = new CommitVertex(commit);
     _contents.AddVertex(commitVertex);
     commit.Parents.ForEach(AddCommit);
     commit.Parents
           .Select(p => new GraphContents.Edge {Source = commit.Sha, Target = p.Sha})
           .ForEach(edge => _contents.AddEdge(edge));
     if (_parameters.IncludeCommitContent)
     {
         AddTree(commit.Tree);
         var edge = new GraphContents.Edge {Source = commit.Sha, Target = commit.Tree.Sha, Tag = "/"};
         _contents.AddEdge(edge);
     }
 }
        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 AddCommit(Commit commit)
        {
            var commitVertex = new CommitVertex(commit);

            _contents.AddVertex(commitVertex);
            commit.Parents.ForEach(AddCommit);
            commit.Parents
            .Select(p => new GraphContents.Edge {
                Source = commit.Sha, Target = p.Sha
            })
            .ForEach(edge => _contents.AddEdge(edge));
            if (_parameters.IncludeCommitContent)
            {
                AddTree(commit.Tree);
                var edge = new GraphContents.Edge {
                    Source = commit.Sha, Target = commit.Tree.Sha, Tag = "/"
                };
                _contents.AddEdge(edge);
            }
        }
        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.
            Queue<CommitWithChildVertex> queue = new Queue<CommitWithChildVertex>();
            CommitWithChildVertex commitIter;
            queue.Enqueue(new CommitWithChildVertex(commit, childVertex));

            while (queue.Count != 0)
            {
                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)));
                }
            }
        }
        private CommitVertex GetCommitVertex(Commit commit)
        {
            CommitVertex commitVertex;
            if (!_vertices.TryGetValue(commit.Sha, out commitVertex))
            {
                commitVertex = new CommitVertex(commit.Sha, commit.MessageShort)
                {
                    Description = commit.Message,
                    Author = commit.Author.Name,
                    CommitDate = commit.Author.When

                };
                _vertices.Add(commit.Sha, commitVertex);
            }

            return commitVertex;
        }
        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;
        }
 private bool CommitIsNotInGraph(CommitVertex v)
 {
     return !_commitsInGraph.Contains(v.Sha);
 }
        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);
            }

            _commitsInGraph.Add(commit.Sha);

            return commitVertex;
        }
        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);
                }
            }
        }