Пример #1
0
		private RepositoryBranchState CreateBranchState(string branch)
		{
			var state = new RepositoryBranchState(branch);

			if (m_setupInitialBranchState)
			{
				foreach (var file in m_allFiles)
				{
					var branchpointRevision = file.GetBranchpointForBranch(branch);
					if (branchpointRevision == Revision.Empty)
						continue;

					var sourceBranch = file.GetBranch(branchpointRevision);
					if (sourceBranch != null)
					{
						var sourceBranchRevision = this[sourceBranch][file.Name];

						if (sourceBranchRevision != Revision.Empty)
							state.SetUnsafe(file.Name, branchpointRevision);
					}
				}
			}

			return state;
		}
Пример #2
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 private RepositoryBranchState(string branch, RepositoryBranchState other) : this(branch)
 {
     foreach (var kvp in other.m_files)
     {
         m_files[kvp.Key] = kvp.Value;
     }
 }
Пример #3
0
        private RepositoryBranchState CreateBranchState(string branch)
        {
            var state = new RepositoryBranchState(branch);

            if (m_setupInitialBranchState)
            {
                foreach (var file in m_allFiles)
                {
                    var branchpointRevision = file.GetBranchpointForBranch(branch);
                    if (branchpointRevision == Revision.Empty)
                    {
                        continue;
                    }

                    var sourceBranch = file.GetBranch(branchpointRevision);
                    if (sourceBranch != null)
                    {
                        var sourceBranchRevision = this[sourceBranch][file.Name];

                        if (sourceBranchRevision != Revision.Empty)
                        {
                            state.SetUnsafe(file.Name, branchpointRevision);
                        }
                    }
                }
            }

            return(state);
        }
        private void CheckAddedRemovedFiles(string tag, RepositoryBranchState candidateBranchState, List <Commit> commits,
                                            CommitMoveRecord moveRecord, ref Commit candidate)
        {
            List <FileInfo> missingFiles = null;
            List <FileInfo> extraFiles   = null;
            var             liveFiles    = new HashSet <string>(candidateBranchState.LiveFiles);

            foreach (var file in m_allFiles)
            {
                if (GetRevisionForTag(file, tag) == Revision.Empty)
                {
                    if (liveFiles.Contains(file.Name))
                    {
                        AddAndCreateList(ref extraFiles, file);
                        m_log.WriteLine("Extra:   {0}", file.Name);

                        if (extraFiles.Count > PartialTagThreshold)
                        {
                            throw new TagResolutionException(String.Format("Tag {0} appears to be a partial tag", tag));
                        }
                    }
                }
                else
                {
                    if (!liveFiles.Contains(file.Name))
                    {
                        AddAndCreateList(ref missingFiles, file);
                        m_log.WriteLine("Missing: {0}", file.Name);
                    }
                }
            }

            if (missingFiles != null)
            {
                HandleMissingFiles(tag, commits, missingFiles, moveRecord, ref candidate);
            }

            if (extraFiles != null)
            {
                HandleExtraFiles(tag, commits, extraFiles, moveRecord, ref candidate);
            }
        }
		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);
		}
		/// <summary>
		/// Copy constructor.
		/// </summary>
		private RepositoryBranchState(string branch, RepositoryBranchState other) : this(branch)
		{
			foreach (var kvp in other.m_files)
				m_files[kvp.Key] = kvp.Value;
		}