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

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

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

            this.head = node;
        }
示例#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));
        }
示例#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();
        }
示例#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;
            }
        }
示例#7
0
 public Branch(String name, Commit initialHead)
 {
     this.head = initialHead;
     this.name = name;
 }