public static void WriteBranch(DirectoryInfo workspace, Branch branch)
 {
     string branchesDirPath = Path.Combine(workspace.FullName, Global.BranchesDirPath);
     string branchDirPath = Path.Combine(branchesDirPath, branch.Name);
     string branchMetaFilePath = Path.Combine(branchDirPath, Global.BranchMetaFilename);
     string xml = XmlUtility.Obj2XmlStr(branch);
     File.WriteAllText(branchMetaFilePath, xml);
 }
        public static Branch CreateBranch(Branch parent, DirectoryInfo workspace, string name)
        {
            string branchesDirPath = Path.Combine(workspace.FullName, Global.BranchesDirPath);
            string branchDirPath = Path.Combine(branchesDirPath, name);

            if (!Directory.Exists(branchDirPath))
            {
                Directory.CreateDirectory(branchDirPath);
                string head = parent != null && parent.Head != null ? parent.Head : Global.MasterCommitName;
                var b = new Branch(name, head);
                WriteBranch(workspace, b);
                return b;
            }
            return null;
        }
 public static void UpdateBranchHead(DirectoryInfo workspace, Branch b, CommitInfo c)
 {
     b.Head = c.Id;
     WriteBranch(workspace, b);
 }