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"));
		}
示例#3
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 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");
		}
示例#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;
		}
		public void FilesWithoutCommitId_DifferentMessage_NotMergedTogether()
		{
			var now = DateTime.Now;
			var f1 = new FileInfo("file1.txt");
			var f2 = new FileInfo("file2.txt");
			var revisions = new[]
			{
				f1.CreateRevision("1.1", "", now).WithMessage("message #1"),
				f2.CreateRevision("1.1", "", now).WithMessage("message #2"),
			};

			var builder = new CommitBuilder(m_log, revisions);
			var commits = builder.GetCommits().ToList();

			Assert.AreEqual(commits.Count, 2);
		}
		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 FilesWithoutCommitId_SameMessage_TimeGap()
		{
			var now = DateTime.Now;
			var f1 = new FileInfo("file1.txt");
			var f2 = new FileInfo("file2.txt");
			var f3 = new FileInfo("file3.txt");
			var revisions = new[]
			{
				f1.CreateRevision("1.1", "", now).WithMessage("message"),
				f2.CreateRevision("1.1", "", now).WithMessage("message"),
				f3.CreateRevision("1.1", "", now + TimeSpan.FromMinutes(5)).WithMessage("message"),
			};

			var builder = new CommitBuilder(m_log, revisions);
			var commits = builder.GetCommits().ToList();

			Assert.AreEqual(commits.Count, 2);
			Assert.IsTrue(commits[0].Select(f => f.File.Name).SequenceEqual("file1.txt", "file2.txt"));
			Assert.IsTrue(commits[1].Select(f => f.File.Name).Single() == "file3.txt");
		}