コード例 #1
0
        public void CreateHeadOnlyCommits_MessageSet()
        {
            var f1            = new FileInfo("file1").WithBranch("branch1", "1.1.0.2");
            var f2            = new FileInfo("file2").WithBranch("branch1", "1.1.0.2");
            var mainCommit1   = new Commit("c1").WithRevision(f1, "1.1").WithRevision(f2, "1.1");
            var branchCommit1 = new Commit("c2").WithRevision(f1, "1.1.2.1").WithRevision(f2, "1.1.2.1");

            var branchpoints = new Dictionary <string, Commit>()
            {
                { "branch1", mainCommit1 },
            };

            IEnumerable <Commit> commits = new[] { mainCommit1, branchCommit1 };
            var streams = new BranchStreamCollection(commits, branchpoints);

            // rename branch1
            var renamer = new Renamer();

            renamer.AddRule(new RenameRule(@"^MAIN$", "master"));
            renamer.AddRule(new RenameRule(@"^branch(\d)", "BRANCH#$1"));
            m_config.Stub(c => c.BranchRename).Return(renamer);

            m_config.Stub(c => c.IncludeFile("file1")).Return(true);
            m_config.Stub(c => c.IncludeFile("file2")).Return(false);
            m_config.Stub(c => c.IsHeadOnly("file1")).Return(false);
            m_config.Stub(c => c.IsHeadOnly("file2")).Return(true);

            var filter = new ExclusionFilter(m_log, m_config);

            commits = filter.Filter(commits).ToListIfNeeded();

            filter.CreateHeadOnlyCommits(new[] { "MAIN", "branch1" }, streams, AllFiles(f1, f2));
            Assert.AreEqual(streams.Head("MAIN").Message, "Adding head-only files to master");
            Assert.AreEqual(streams.Head("branch1").Message, "Adding head-only files to BRANCH#1");
        }
コード例 #2
0
        public void Heads()
        {
            var streams = new BranchStreamCollection(m_commits, m_branchpoints);

            Assert.IsTrue(streams.Head("MAIN") == m_commits[2]);
            Assert.IsTrue(streams.Head("branch") == m_commits[1]);
        }
コード例 #3
0
        public void CreateHeadOnlyCommits_MergeFromBranch()
        {
            var f1            = new FileInfo("file1").WithBranch("branch1", "1.1.0.2");
            var f2            = new FileInfo("file2").WithBranch("branch1", "1.1.0.2");
            var mainCommit1   = new Commit("c1").WithRevision(f1, "1.1").WithRevision(f2, "1.1");
            var branchCommit1 = new Commit("c2").WithRevision(f1, "1.1.2.1").WithRevision(f2, "1.1.2.1");
            var mainCommit2   = new Commit("c3").WithRevision(f1, "1.2", mergepoint: "1.1.2.1").WithRevision(f2, "1.2", mergepoint: "1.1.2.1");

            var branchpoints = new Dictionary <string, Commit>()
            {
                { "branch1", mainCommit2 },
            };

            IEnumerable <Commit> commits = new[] { mainCommit1, branchCommit1, mainCommit2 };
            var streams = new BranchStreamCollection(commits, branchpoints);

            m_config.Stub(c => c.IncludeFile("file1")).Return(true);
            m_config.Stub(c => c.IncludeFile("file2")).Return(false);
            m_config.Stub(c => c.IsHeadOnly("file1")).Return(false);
            m_config.Stub(c => c.IsHeadOnly("file2")).Return(true);
            m_config.Stub(c => c.BranchRename).Return(new Renamer());

            var filter = new ExclusionFilter(m_log, m_config);

            commits = filter.Filter(commits).ToListIfNeeded();

            filter.CreateHeadOnlyCommits(new[] { "MAIN", "branch1" }, streams, AllFiles(f1, f2));
            Assert.AreEqual(streams.Head("MAIN").CommitId, "headonly-MAIN", "Commit created on HEAD");
            Assert.AreEqual(streams.Head("branch1").CommitId, "headonly-branch1", "Commit created on branch1");
            Assert.AreSame(streams.Head("MAIN").MergeFrom, streams.Head("branch1"), "Merge from branch1 to HEAD");
        }
コード例 #4
0
        public void CreateHeadOnlyCommits_FileDeletedInMerge()
        {
            var f1            = new FileInfo("file1").WithBranch("branch1", "1.1.0.2");
            var f2            = new FileInfo("file2").WithBranch("branch1", "1.1.0.2");
            var mainCommit1   = new Commit("c1").WithRevision(f1, "1.1").WithRevision(f2, "1.1");
            var branchCommit1 = new Commit("c2").WithRevision(f1, "1.1.2.1").WithRevision(f2, "1.1.2.1");
            var mainCommit2   = new Commit("c3").WithRevision(f1, "1.2", mergepoint: "1.1.2.1").WithRevision(f2, "1.2", mergepoint: "1.1.2.1");
            var mainCommit3   = new Commit("c4").WithRevision(f2, "1.3", isDead: true);

            var branchpoints = new Dictionary <string, Commit>()
            {
                { "branch1", mainCommit1 },
            };

            IEnumerable <Commit> commits = new[] { mainCommit1, branchCommit1, mainCommit2, mainCommit3 };
            var streams = new BranchStreamCollection(commits, branchpoints);

            m_config.Stub(c => c.IncludeFile("file1")).Return(false);
            m_config.Stub(c => c.IncludeFile("file2")).Return(false);
            m_config.Stub(c => c.IsHeadOnly("file1")).Return(true);
            m_config.Stub(c => c.IsHeadOnly("file2")).Return(true);
            m_config.Stub(c => c.BranchRename).Return(new Renamer());

            var filter = new ExclusionFilter(m_log, m_config);

            commits = filter.Filter(commits).ToListIfNeeded();

            filter.CreateHeadOnlyCommits(new[] { "MAIN", "branch1" }, streams, AllFiles(f1, f2));

            var mainHead = streams.Head("MAIN");

            Assert.IsTrue(mainHead.CommitId == "headonly-MAIN");
            Assert.IsTrue(mainHead.Where(r => !r.IsDead).Single().File.Name == "file1");
            Assert.IsTrue(mainHead.Where(r => r.IsDead).Single().File.Name == "file2");
        }
コード例 #5
0
        public void MoveCommit_ToEnd()
        {
            m_commits.Add(new Commit("4").WithRevision(m_f1, "1.3"));
            m_commits.Add(new Commit("5").WithRevision(m_f1, "1.4"));
            var streams = new BranchStreamCollection(m_commits, m_branchpoints);

            streams.MoveCommit(m_commits[3], m_commits[4]);

            Assert.IsTrue(streams["MAIN"].ToList().Select(c => c.CommitId).SequenceEqual("1", "3", "5", "4"));
            Assert.IsTrue(streams.Head("MAIN").CommitId == "4");
            Assert.IsTrue(streams.Verify());
        }
コード例 #6
0
        public void AppendCommit_ToBranch()
        {
            var streams = new BranchStreamCollection(m_commits, m_branchpoints);

            var commit = new Commit("new").WithRevision(m_f1, "1.1.2.2");

            streams.AppendCommit(commit);

            Assert.AreSame(streams.Head("branch"), commit);
            Assert.AreSame(streams["branch"].Successor, commit);
            Assert.IsTrue(commit.Index > streams["MAIN"].Index, "Index set");
        }
コード例 #7
0
		public void CreateHeadOnlyCommits_MessageSet()
		{
			var f1 = new FileInfo("file1").WithBranch("branch1", "1.1.0.2");
			var f2 = new FileInfo("file2").WithBranch("branch1", "1.1.0.2");
			var mainCommit1 = new Commit("c1").WithRevision(f1, "1.1").WithRevision(f2, "1.1");
			var branchCommit1 = new Commit("c2").WithRevision(f1, "1.1.2.1").WithRevision(f2, "1.1.2.1");

			var branchpoints = new Dictionary<string, Commit>()
			{
				{ "branch1", mainCommit1 },
			};

			IEnumerable<Commit> commits = new[] { mainCommit1, branchCommit1 };
			var streams = new BranchStreamCollection(commits, branchpoints);

			// rename branch1
			var renamer = new Renamer();
			renamer.AddRule(new RenameRule(@"^MAIN$", "master"));
			renamer.AddRule(new RenameRule(@"^branch(\d)", "BRANCH#$1"));
			m_config.Stub(c => c.BranchRename).Return(renamer);

			m_config.Stub(c => c.IncludeFile("file1")).Return(true);
			m_config.Stub(c => c.IncludeFile("file2")).Return(false);
			m_config.Stub(c => c.IsHeadOnly("file1")).Return(false);
			m_config.Stub(c => c.IsHeadOnly("file2")).Return(true);

			var filter = new ExclusionFilter(m_log, m_config);
			commits = filter.Filter(commits).ToListIfNeeded();

			filter.CreateHeadOnlyCommits(new[] { "MAIN", "branch1" }, streams, AllFiles(f1, f2));
			Assert.AreEqual(streams.Head("MAIN").Message, "Adding head-only files to master");
			Assert.AreEqual(streams.Head("branch1").Message, "Adding head-only files to BRANCH#1");
		}
コード例 #8
0
		public void CreateHeadOnlyCommits_FileDeletedInMerge()
		{
			var f1 = new FileInfo("file1").WithBranch("branch1", "1.1.0.2");
			var f2 = new FileInfo("file2").WithBranch("branch1", "1.1.0.2");
			var mainCommit1 = new Commit("c1").WithRevision(f1, "1.1").WithRevision(f2, "1.1");
			var branchCommit1 = new Commit("c2").WithRevision(f1, "1.1.2.1").WithRevision(f2, "1.1.2.1");
			var mainCommit2 = new Commit("c3").WithRevision(f1, "1.2", mergepoint: "1.1.2.1").WithRevision(f2, "1.2", mergepoint: "1.1.2.1");
			var mainCommit3 = new Commit("c4").WithRevision(f2, "1.3", isDead: true);

			var branchpoints = new Dictionary<string, Commit>()
			{
				{ "branch1", mainCommit1 },
			};

			IEnumerable<Commit> commits = new[] { mainCommit1, branchCommit1, mainCommit2, mainCommit3 };
			var streams = new BranchStreamCollection(commits, branchpoints);

			m_config.Stub(c => c.IncludeFile("file1")).Return(false);
			m_config.Stub(c => c.IncludeFile("file2")).Return(false);
			m_config.Stub(c => c.IsHeadOnly("file1")).Return(true);
			m_config.Stub(c => c.IsHeadOnly("file2")).Return(true);
			m_config.Stub(c => c.BranchRename).Return(new Renamer());

			var filter = new ExclusionFilter(m_log, m_config);
			commits = filter.Filter(commits).ToListIfNeeded();

			filter.CreateHeadOnlyCommits(new[] { "MAIN", "branch1" }, streams, AllFiles(f1, f2));

			var mainHead = streams.Head("MAIN");
			Assert.IsTrue(mainHead.CommitId == "headonly-MAIN");
			Assert.IsTrue(mainHead.Where(r => !r.IsDead).Single().File.Name == "file1");
			Assert.IsTrue(mainHead.Where(r => r.IsDead).Single().File.Name == "file2");
		}
コード例 #9
0
		public void CreateHeadOnlyCommits_MergeFromBranch()
		{
			var f1 = new FileInfo("file1").WithBranch("branch1", "1.1.0.2");
			var f2 = new FileInfo("file2").WithBranch("branch1", "1.1.0.2");
			var mainCommit1 = new Commit("c1").WithRevision(f1, "1.1").WithRevision(f2, "1.1");
			var branchCommit1 = new Commit("c2").WithRevision(f1, "1.1.2.1").WithRevision(f2, "1.1.2.1");
			var mainCommit2 = new Commit("c3").WithRevision(f1, "1.2", mergepoint: "1.1.2.1").WithRevision(f2, "1.2", mergepoint: "1.1.2.1");

			var branchpoints = new Dictionary<string, Commit>()
			{
				{ "branch1", mainCommit2 },
			};

			IEnumerable<Commit> commits = new[] { mainCommit1, branchCommit1, mainCommit2 };
			var streams = new BranchStreamCollection(commits, branchpoints);

			m_config.Stub(c => c.IncludeFile("file1")).Return(true);
			m_config.Stub(c => c.IncludeFile("file2")).Return(false);
			m_config.Stub(c => c.IsHeadOnly("file1")).Return(false);
			m_config.Stub(c => c.IsHeadOnly("file2")).Return(true);
			m_config.Stub(c => c.BranchRename).Return(new Renamer());

			var filter = new ExclusionFilter(m_log, m_config);
			commits = filter.Filter(commits).ToListIfNeeded();

			filter.CreateHeadOnlyCommits(new[] { "MAIN", "branch1" }, streams, AllFiles(f1, f2));
			Assert.AreEqual(streams.Head("MAIN").CommitId, "headonly-MAIN", "Commit created on HEAD");
			Assert.AreEqual(streams.Head("branch1").CommitId, "headonly-branch1", "Commit created on branch1");
			Assert.AreSame(streams.Head("MAIN").MergeFrom, streams.Head("branch1"), "Merge from branch1 to HEAD");
		}