public void SingleMerge_NoReordering()
		{
			var streams = CreateSingleMerge();
			var resolver = new MergeResolver(m_logger, streams);
			resolver.Resolve();

			Assert.IsTrue(streams["MAIN"].ToList().Select(c => c.CommitId).SequenceEqual("initial", "merge"));
			Assert.IsTrue(streams["branch"].ToList().Select(c => c.CommitId).SequenceEqual("branch"));
		}
		public void CrossedMerge_Reordered()
		{
			var streams = CreateCrossedMerges();
			var resolver = new MergeResolver(m_logger, streams);
			resolver.Resolve();

			Assert.IsTrue(streams["MAIN"].ToList().Select(c => c.CommitId).SequenceEqual("initial", "merge1", "merge2"));
			Assert.IsTrue(streams["branch"].ToList().Select(c => c.CommitId).SequenceEqual("branch2", "branch1"));
		}
		public void SingleMerge_MergesFilledIn()
		{
			var streams = CreateSingleMerge();
			var resolver = new MergeResolver(m_logger, streams);
			resolver.Resolve();

			Assert.IsTrue(streams["MAIN"].Successor.CommitId == "merge" && streams["MAIN"].Successor.MergeFrom.CommitId == "branch");
			Assert.IsTrue(streams["MAIN"].ToList().Where(c => c.CommitId != "merge").All(c => c.MergeFrom == null));
			Assert.IsTrue(streams["branch"].ToList().All(c => c.MergeFrom == null));
		}
		public void MultipleMerges_MergesFilledIn()
		{
			var streams = CreateMultipleMerges();
			var resolver = new MergeResolver(m_logger, streams);
			resolver.Resolve();

			var main0 = streams["MAIN"];
			var main1 = main0.Successor;
			var main2 = main1.Successor;

			Assert.IsTrue(main0.CommitId == "initial" && main0.MergeFrom == null);
			Assert.IsTrue(main1.CommitId == "merge1" && main1.MergeFrom.CommitId == "branch1");
			Assert.IsTrue(main2.CommitId == "merge2" && main2.MergeFrom.CommitId == "branch2");
			Assert.IsTrue(streams["branch"].ToList().All(c => c.MergeFrom == null));
		}
Exemple #5
0
        private static void Analyse()
        {
            var parser          = new CvsLogParser(m_config.Sandbox, m_config.CvsLogFileName, m_config.BranchMatcher);
            var builder         = new CommitBuilder(m_log, parser.Parse());
            var exclusionFilter = new ExclusionFilter(m_log, m_config);

            IEnumerable <Commit> commits = builder.GetCommits()
                                           .SplitMultiBranchCommits()
                                           .FilterCommitsOnExcludedBranches()
                                           .FilterExcludedFiles(exclusionFilter)
                                           .AddCommitsToFiles()
                                           .Verify(m_log)
                                           .ToListIfNeeded();

            // build lookup of all files
            var allFiles      = new FileCollection(parser.Files);
            var includedFiles = new FileCollection(parser.Files.Where(f => m_config.IncludeFile(f.Name)));

            WriteAllCommitsLog(commits);
            WriteExcludedFileLog(parser);

            var branchResolver = ResolveBranches(commits, includedFiles);

            commits = branchResolver.Commits;

            var tagResolver = ResolveTags(commits, includedFiles);

            commits = tagResolver.Commits;

            WriteTagLog("allbranches.log", branchResolver, parser.ExcludedBranches, m_config.BranchRename);
            WriteTagLog("alltags.log", tagResolver, parser.ExcludedTags, m_config.TagRename);
            WriteUserLog("allusers.log", commits);

            var streams = commits.SplitBranchStreams(branchResolver.ResolvedTags);

            // resolve merges
            var mergeResolver = new MergeResolver(m_log, streams);

            mergeResolver.Resolve();

            WriteBranchLogs(streams);

            // add any "head-only" files
            exclusionFilter.CreateHeadOnlyCommits(m_config.HeadOnlyBranches, streams, allFiles);

            // store data needed for import
            m_streams = streams;
        }
Exemple #6
0
		private static void Analyse()
		{
			var parser = new CvsLogParser(m_config.Sandbox, m_config.CvsLogFileName, m_config.BranchMatcher);
			var builder = new CommitBuilder(m_log, parser.Parse());
			var exclusionFilter = new ExclusionFilter(m_log, m_config);

			IEnumerable<Commit> commits = builder.GetCommits()
					.SplitMultiBranchCommits()
					.FilterCommitsOnExcludedBranches()
					.FilterExcludedFiles(exclusionFilter)
					.AddCommitsToFiles()
					.Verify(m_log)
					.ToListIfNeeded();

			// build lookup of all files
			var allFiles = new FileCollection(parser.Files);
			var includedFiles = new FileCollection(parser.Files.Where(f => m_config.IncludeFile(f.Name)));

			WriteAllCommitsLog(commits);
			WriteExcludedFileLog(parser);

			var branchResolver = ResolveBranches(commits, includedFiles);
			commits = branchResolver.Commits;

			var tagResolver = ResolveTags(commits, includedFiles);
			commits = tagResolver.Commits;

			WriteTagLog("allbranches.log", branchResolver, parser.ExcludedBranches, m_config.BranchRename);
			WriteTagLog("alltags.log", tagResolver, parser.ExcludedTags, m_config.TagRename);
			WriteUserLog("allusers.log", commits);

			var streams = commits.SplitBranchStreams(branchResolver.ResolvedTags);

			// resolve merges
			var mergeResolver = new MergeResolver(m_log, streams);
			mergeResolver.Resolve();

			WriteBranchLogs(streams);

			// add any "head-only" files
			exclusionFilter.CreateHeadOnlyCommits(m_config.HeadOnlyBranches, streams, allFiles);

			// store data needed for import
			m_streams = streams;
		}
		public void MergeFromParentBranch_Ignore()
		{
			var commits = new List<Commit>()
			{
				new Commit("initial").WithRevision(m_file, "1.1"),
				new Commit("branch1").WithRevision(m_file, "1.1.2.1"),
				new Commit("main1").WithRevision(m_file, "1.2"),
				new Commit("branch2").WithRevision(m_file, "1.1.2.2", mergepoint: "1.2"),
			};
			m_file.WithBranch("branch", "1.1.0.2");

			var branchpoints = new Dictionary<string, Commit>()
			{
				{ "branch", commits[0] }
			};

			var streams = new BranchStreamCollection(commits, branchpoints);
			var resolver = new MergeResolver(m_logger, streams);
			resolver.Resolve();

			Assert.IsTrue(streams["MAIN"].ToList().All(c => c.MergeFrom == null));
			Assert.IsTrue(streams["branch"].ToList().All(c => c.MergeFrom == null));
		}
		public void SingleMergeOnExcludedBranch_NoMergeFilledIn()
		{
			var commits = new List<Commit>()
			{
				new Commit("initial").WithRevision(m_file, "1.1"),
				new Commit("merge").WithRevision(m_file, "1.2", mergepoint: "1.1.2.1"),
			};

			var branchpoints = new Dictionary<string, Commit>()
			{
				{ "branch", commits[0] }
			};

			var streams = new BranchStreamCollection(commits, branchpoints);
			var resolver = new MergeResolver(m_logger, streams);
			resolver.Resolve();

			Assert.IsTrue(streams["MAIN"].ToList().All(c => c.MergeFrom == null));
		}
		public void CrossedMerge_LongerHistoryOnMergeDestination()
		{
			var commits = new List<Commit>()
			{
				new Commit("initial1").WithRevision(m_file, "1.1"),
				new Commit("initial2").WithRevision(m_file, "1.2"),
				new Commit("initial3").WithRevision(m_file, "1.3"),
				new Commit("branch1").WithRevision(m_file, "1.3.2.1"),
				new Commit("branch2").WithRevision(m_file, "1.3.2.2"),
				new Commit("merge1").WithRevision(m_file, "1.4", mergepoint: "1.3.2.2"),
				new Commit("merge2").WithRevision(m_file, "1.5", mergepoint: "1.3.2.1"),
			};
			m_file.WithBranch("branch", "1.3.0.2");

			var branchpoints = new Dictionary<string, Commit>()
			{
				{ "branch", commits[0] }
			};

			var streams = new BranchStreamCollection(commits, branchpoints);
			var resolver = new MergeResolver(m_logger, streams);
			resolver.Resolve();

			Assert.IsTrue(streams["MAIN"].ToList().Select(c => c.CommitId).SequenceEqual("initial1", "initial2", "initial3", "merge1", "merge2"));
			Assert.IsTrue(streams["branch"].ToList().Select(c => c.CommitId).SequenceEqual("branch2", "branch1"));
		}