Beispiel #1
0
        public void AddParent(Commit parent)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent must be a non-null Commit");
            }

            this.parents.Add(parent);
        }
Beispiel #2
0
        public Commit(CommitValue value, Commit parent)
        {
            this.value = value;

            if (parent != null)
            {
                this.AddParent(parent);
            }
        }
Beispiel #3
0
        public void Commit(Commit node)
        {
            if (this.head != null)
            {
                node.AddParent(this.head);
            }

            this.head = node;
        }
Beispiel #4
0
        private string StringifyCommit(Commit node)
        {
            if (node == null)
            {
                return "";
            }

            IEnumerator<Commit> parentEnumerator = node.Parents.GetEnumerator ();
            bool hasParents = parentEnumerator.MoveNext();

            return String.Format("{0}{1}{2}", node.Value,
                                 hasParents ? "-->" : "",
                                 StringifyCommit(hasParents ? parentEnumerator.Current : null));
        }
Beispiel #5
0
        public static string Log(Commit start, int depth)
        {
            int currentDepth = 0;
            Commit currentCommit = start;
            StringBuilder log = new StringBuilder();

            while (currentDepth < depth && currentCommit != null)
            {
                log.Append(String.Format("{0}\n", currentCommit.Value));

                currentDepth++;
                currentCommit = Repo.Parent(currentCommit);
                // TODO: Figure out what to do with multiple parents
            }

            return log.ToString();
        }
Beispiel #6
0
        private static Commit Parent(Commit commit)
        {
            IEnumerable<Commit> parents = commit.Parents;

            IEnumerator<Commit> parentsEnumerator = parents.GetEnumerator();

            if (parentsEnumerator.MoveNext())
            {
                return parentsEnumerator.Current;
            }
            else
            {
                return null;
            }
        }
Beispiel #7
0
 public Branch(String name, Commit initialHead)
 {
     this.head = initialHead;
     this.name = name;
 }