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");
        }
        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");
        }
        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");
        }
Ejemplo n.º 4
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");
		}
Ejemplo n.º 5
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");
		}
Ejemplo n.º 6
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");
		}