public static void WriteCommit(DirectoryInfo workspace, CommitInfo commit)
 {
     string commitsDir = Path.Combine(workspace.FullName, Global.SnapshotsDirPath);
     string commitDir = Path.Combine(commitsDir, commit.Id);
     string commitMetaFilePath = Path.Combine(commitDir, Global.CommitMetaFileName);
     string xml = XmlUtility.Obj2XmlStr(commit);
     File.WriteAllText(commitMetaFilePath, xml);
 }
 //востанавливает рабочую директорию по Id коммита,для переключения между ветками
 public static void RestoreWorkspaceFromCommit(DirectoryInfo workspace, CommitInfo commit)
 {
     string snapshotsDir = Path.Combine(workspace.FullName, Global.SnapshotsDirPath);
     string src = Path.Combine(snapshotsDir, commit.Id);
     string dest = workspace.FullName;
     CleanWorkspace(workspace);
     CopyAll(src, dest);
     File.Delete(Path.Combine(dest, Global.CommitMetaFileName));
 }
 //делает коммит используя инфу из снепшота
 public static CommitInfo Commit(SnapshotInfo snapshot, DirectoryInfo workspace, string message)
 {
     string snapshotsDir = Path.Combine(workspace.FullName, Global.SnapshotsDirPath);
     string snapshotDir = Path.Combine(snapshotsDir, snapshot.Id);
     Directory.CreateDirectory(snapshotDir);
     CopyAllExceptRepository(workspace.FullName, snapshotDir);
     var commit = new CommitInfo(snapshot, message);
     WriteCommit(workspace, commit);
     return commit;
 }
Esempio n. 4
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                CommitInfo c;

                if (listView1.SelectedItems[0] is CommitsListItem)
                {
                    var id = ((CommitsListItem) listView1.SelectedItems[0]).CommitId;
                    c = _cvs.GetCommitInfo(id);
                    textBox1.Text = c.Id;
                    textBox2.Text = c.Date.ToString();
                    textBox3.Text = (new SnapshotInfo(c)).Details();
                    textBox4.Text = c.Message;
                }
                else
                {
                    c = new CommitInfo(_cvs.GetCurrentSnaphot(),"");
                    textBox3.Text = (new SnapshotInfo(c)).Details();
                }

            }
            else
            {
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
                textBox4.Text = "";
            }
        }
Esempio n. 5
0
 //начиная с коммита с загружает его предыдущий коммит,делает прдыдущий текущим(обходим ветку загружем все ее коммиты)
 private void LoadCommitList(List<CommitInfo> cs, CommitInfo c)
 {
     if (c.Previos != null)
     {
         CommitInfo p = CommitUtil.GetCommitInfo(_r.Workspace, c.Previos);
         cs.Add(p);
         LoadCommitList(cs, p);
     }
 }
 public SnapshotInfo(CommitInfo commit)
 {
     Id = commit.Id;
     Previos = commit.Previos;
     Files = commit.Files;
 }
 public static void UpdateBranchHead(DirectoryInfo workspace, Branch b, CommitInfo c)
 {
     b.Head = c.Id;
     WriteBranch(workspace, b);
 }