public void GetTagsForRevision_RevisionTagged() { var file = new FileInfo("file.txt").WithTag("tag", "1.1"); var tags = file.GetTagsForRevision(Revision.Create("1.1")); Assert.AreEqual(tags.Single(), "tag"); }
public void SingleBranch_PlaysInSequence() { var now = DateTime.Now; var file1 = new FileInfo("file1"); var file2 = new FileInfo("file2").WithBranch("branch", "1.1.0.2"); var commit0 = new Commit("id0") { Index = 1 } .WithRevision(file1, "1.1", time: now) .WithRevision(file2, "1.1", time: now); var commit1 = new Commit("id1") { Index = 2 } .WithRevision(file1, "1.2", time: now + TimeSpan.FromMinutes(2)) .WithRevision(file2, "1.2", time: now + TimeSpan.FromMinutes(2), mergepoint: "1.1.2.1"); var commit2 = new Commit("branch0") { Index = 3 } .WithRevision(file2, "1.1.2.1", time: now + TimeSpan.FromMinutes(1)); var commits = new[] { commit0, commit1, commit2 }; var branchpoints = new Dictionary<string, Commit>() { { "branch", commit0 } }; var branches = new BranchStreamCollection(commits, branchpoints); commit1.MergeFrom = commit2; var player = new CommitPlayer(MockRepository.GenerateStub<ILogger>(), branches); var result = player.Play().Select(c => c.CommitId).ToList(); Assert.IsTrue(result.SequenceEqual("id0", "branch0", "id1")); }
public static Commit WithRevision(this Commit commit, FileInfo file, string revision, DateTime time = default(DateTime), string mergepoint = null, bool isDead = false) { var mergepointRevision = (mergepoint == null) ? Revision.Empty : Revision.Create(mergepoint); var fileRevision = file.CreateRevision(revision, commit.CommitId, time: time, mergepoint: mergepoint, isDead: isDead); commit.Add(fileRevision); file.AddCommit(commit, fileRevision.Revision); return commit; }
public FileRevision(FileInfo file, Revision revision, Revision mergepoint, DateTime time, string author, string commitId, bool isDead = false) { this.File = file; this.Revision = revision; this.Mergepoint = mergepoint; this.Time = time; this.Author = author; this.CommitId = commitId; this.IsDead = isDead; }
public void GetCommit_DeadFile() { var f1 = new FileInfo("file1.txt"); var commit = new Commit("c1").WithRevision(f1, "1.1", isDead: true); var repo = MockRepository.GenerateStub<ICvsRepository>(); var cvs = new Cvs(repo, 1); var revisions = cvs.GetCommit(commit); Assert.IsTrue(revisions.Single().IsDead); }
public void GetCommit_SingleFile() { var f1 = new FileInfo("file1.txt"); var commit = new Commit("c1").WithRevision(f1, "1.1"); var repo = MockRepository.GenerateStub<ICvsRepository>(); repo.Stub(r => r.GetCvsRevision(null)).IgnoreArguments().Do((FileRevision f) => CreateMockContent(f)); var cvs = new Cvs(repo, 1); var revisions = cvs.GetCommit(commit); Assert.IsTrue(Encoding.UTF8.GetString(revisions.Single().Data.Data) == "file1.txt r1.1"); }
public void FileAddedOnTrunk_BranchAddedOnUnchanged() { var file = new FileInfo("file.txt"); var revisions = new[] { file.CreateRevision("1.1", "main", isDead: true).WithMessage("created"), }; var builder = new CommitBuilder(m_log, revisions); var commits = builder.GetCommits().ToList(); var fileRevision = commits.Single().Single(); Assert.AreEqual(fileRevision.File.BranchAddedOn, "MAIN"); }
public void FilesWithSameCommitId_MergedIntoSingleCommit() { var f1 = new FileInfo("file1.txt"); var f2 = new FileInfo("file2.txt"); var revisions = new[] { f1.CreateRevision("1.1", "commit1"), f2.CreateRevision("1.1", "commit1"), }; var builder = new CommitBuilder(m_log, revisions); var commits = builder.GetCommits().ToList(); Assert.IsTrue(commits.Single().Select(f => f.File.Name).SequenceEqual("file1.txt", "file2.txt")); }
public void TestSetup() { m_f1 = new FileInfo("f1").WithBranch("branch", "1.1.0.2"); m_commits = new List<Commit>() { new Commit("1").WithRevision(m_f1, "1.1"), new Commit("2").WithRevision(m_f1, "1.1.2.1"), new Commit("3").WithRevision(m_f1, "1.2", mergepoint: "1.1.2.1") }; m_branchpoints = new Dictionary<string, Commit>() { { "branch", m_commits[0] }, }; }
public void FileAddedOnBranch() { var file = new FileInfo("file.txt"); var revisions = new[] { file.CreateRevision("1.1.2.1", "branch").WithMessage("created"), file.CreateRevision("1.1", "main", isDead: true).WithMessage("file file.txt was initially added on branch branch."), }; var builder = new CommitBuilder(m_log, revisions); var commits = builder.GetCommits().ToList(); var fileRevision = commits.Single().Single(); Assert.IsTrue(fileRevision.Revision.ToString() == "1.1.2.1"); Assert.AreEqual(fileRevision.File.BranchAddedOn, "branch"); }
public void FilesWithoutCommitId_SameMessage_MergedTogether() { var now = DateTime.Now; var f1 = new FileInfo("file1.txt"); var f2 = new FileInfo("file2.txt"); var revisions = new[] { f1.CreateRevision("1.1", "", now - TimeSpan.FromSeconds(1)).WithMessage("message"), f2.CreateRevision("1.1", "", now).WithMessage("message"), }; var builder = new CommitBuilder(m_log, revisions); var commits = builder.GetCommits().ToList(); var commit = commits.Single(); Assert.IsTrue(commit.Select(f => f.File.Name).SequenceEqual("file1.txt", "file2.txt")); Assert.AreEqual(commit.Message, "message"); }
public void SplitsCommitWithExcludedBranch() { var file1 = new FileInfo("file1"); var file2 = new FileInfo("file2"); var id = "id1"; var commit = new Commit(id) { CreateFileRevision(file1, "1.1", id), CreateFileRevision(file2, "1.1.2.1", id), }; var splitter = new SplitMultiBranchCommits(new[] { commit }); var splitCommits = splitter.ToList(); Assert.AreEqual(splitCommits.Count, 2); Assert.AreEqual(splitCommits[0].Branch, "MAIN"); Assert.IsNull(splitCommits[1].Branch); }
public void GetCommit_MultipleFiles() { var files = new FileInfo[6]; var commit = new Commit("c1"); for (int i = 0; i < files.Length; i++) { files[i] = new FileInfo(String.Format("file{0}.txt", i)); commit.WithRevision(files[i], "1.1"); } var repo = MockRepository.GenerateStub<ICvsRepository>(); repo.Stub(r => r.GetCvsRevision(null)).IgnoreArguments().Do((FileRevision f) => CreateMockContent(f)); var cvs = new Cvs(repo, (uint)(files.Length - 1)); var revisions = cvs.GetCommit(commit).ToList(); Assert.AreEqual(revisions.Count, files.Length); Assert.IsTrue(revisions.Select(r => r.Name).OrderBy(i => i).SequenceEqual(files.Select(f => f.Name))); }
public void ApplyCommit_FileDeleted() { var repoState = new RepositoryBranchState("MAIN"); var file1 = new FileInfo("file1"); var file2 = new FileInfo("file2"); var commit1 = new Commit("id1") .WithRevision(file1, "1.1") .WithRevision(file2, "1.1"); var commit2 = new Commit("id2") .WithRevision(file2, "1.2", isDead: true); repoState.Apply(commit1); repoState.Apply(commit2); Assert.AreEqual(repoState[file1.Name], Revision.Create("1.1")); Assert.AreEqual(repoState[file2.Name], Revision.Empty); }
public void SplitsCommitWithTwoBranches() { var file1 = new FileInfo("file1"); var file2 = new FileInfo("file2").WithBranch("branch1", "1.1.0.2"); var id = "id1"; var commit = new Commit(id) { CreateFileRevision(file1, "1.1", id), CreateFileRevision(file2, "1.1.2.1", id), }; var splitter = new SplitMultiBranchCommits(new[] { commit }); var splitCommits = splitter.ToList(); Assert.AreEqual(splitCommits.Count, 2); Assert.AreEqual(splitCommits[0].Single().File.Name, "file1"); Assert.AreEqual(splitCommits[0].Branch, "MAIN"); Assert.AreEqual(splitCommits[1].Single().File.Name, "file2"); Assert.AreEqual(splitCommits[1].Branch, "branch1"); }
public void NoBranches_PlaysInSequence() { var file1 = new FileInfo("file1"); var file2 = new FileInfo("file2"); var commit0 = new Commit("id0") { Index = 1 } .WithRevision(file1, "1.1") .WithRevision(file2, "1.1"); var commit1 = new Commit("id1") { Index = 2 } .WithRevision(file1, "1.2"); var commit2 = new Commit("id2") { Index = 3 } .WithRevision(file2, "1.2"); var commits = new[] { commit0, commit1, commit2 }; var branches = new BranchStreamCollection(commits, new Dictionary<string, Commit>()); var player = new CommitPlayer(MockRepository.GenerateStub<ILogger>(), branches); var result = player.Play().ToList(); Assert.IsTrue(result.SequenceEqual(commits)); }
public void BranchCreatedOn_DefaultsToMain() { var file = new FileInfo("file"); Assert.AreEqual(file.BranchAddedOn, "MAIN"); }
public void AllTags_TagsDefined() { var file = new FileInfo("file.txt").WithTag("tag2", "1.1").WithTag("tag1", "1.2"); ; Assert.IsTrue(file.AllTags.OrderBy(i => i).SequenceEqual("tag1", "tag2")); }
public void AllTags_NoTagsDefined() { var file = new FileInfo("file.txt"); Assert.AreEqual(file.AllTags.Count(), 0); }
public void GetCommit_RevisionDoesNotExist() { var file = new FileInfo("file.txt"); var result = file.GetCommit(Revision.Create("1.5")); Assert.AreSame(result, null); }
public void AllBranches_BranchesDefined() { var file = new FileInfo("file.txt").WithBranch("branch2", "1.1.0.2").WithBranch("branch1", "1.1.0.4"); ; Assert.IsTrue(file.AllBranches.OrderBy(i => i).SequenceEqual("branch1", "branch2")); }
public void GetBranchesAtRevision_RevisionOnTheBranch_NoBranches() { var file = new FileInfo("file.txt").WithBranch("branch", "1.4.0.2"); Assert.IsFalse(file.GetBranchesAtRevision(Revision.Create("1.4.2.1")).Any()); }
public void GetBranchesAtRevision_PredecessorToBranchpoint_NoBranches() { var file = new FileInfo("file.txt").WithBranch("branch", "1.4.0.2"); Assert.IsFalse(file.GetBranchesAtRevision(Revision.Create("1.3")).Any()); }
public void GetBranchesAtRevision_Branchpoint_ReturnsMultipleBranch() { var file = new FileInfo("file.txt") .WithBranch("branch1", "1.4.0.2") .WithBranch("branch2", "1.4.0.4"); Assert.IsTrue(file.GetBranchesAtRevision(Revision.Create("1.4")).OrderBy(i => i).SequenceEqual("branch1", "branch2")); }
protected override IEnumerable<string> GetTagsForFileRevision(FileInfo file, Revision revision) { return file.GetTagsForRevision(revision); }
public void GetTagsForRevision_RevisionUntagged() { var file = new FileInfo("file.txt").WithTag("tag", "1.1"); Assert.IsFalse(file.GetTagsForRevision(Revision.Create("1.2")).Any()); }
public void GetRevisionForTag_TagExists() { var file = new FileInfo("file.txt").WithTag("tag", "1.1"); var r = file.GetRevisionForTag("tag"); Assert.AreEqual(r, Revision.Create("1.1")); }
public void GetCommit_RevisionExists() { var file = new FileInfo("file.txt"); var commit = new Commit("abc").WithRevision(file, "1.1"); var result = file.GetCommit(Revision.Create("1.1")); Assert.AreSame(result, commit); }
protected override Revision GetRevisionForTag(FileInfo file, string tag) { return file.GetRevisionForTag(tag); }
public void GetBranchesAtRevision_Branchpoint_ReturnsBranch() { var file = new FileInfo("file.txt").WithBranch("branch", "1.4.0.2"); Assert.AreEqual(file.GetBranchesAtRevision(Revision.Create("1.4")).Single(), "branch"); }