public void AddParent(Commit parent) { if (parent == null) { throw new ArgumentNullException("parent must be a non-null Commit"); } this.parents.Add(parent); }
public Commit(CommitValue value, Commit parent) { this.value = value; if (parent != null) { this.AddParent(parent); } }
public void Commit(Commit node) { if (this.head != null) { node.AddParent(this.head); } this.head = node; }
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)); }
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(); }
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; } }
public Branch(String name, Commit initialHead) { this.head = initialHead; this.name = name; }