public void BranchMergeEditFileOnlyTest() { MigrationItemStrings folder = new MigrationItemStrings(m_source.Name + "folder", m_target.Name + "folder", TestEnvironment, true); m_file = new MigrationItemStrings(m_source.Name + "folder/file.txt", m_target.Name + "folder/file.txt", TestEnvironment, true); SourceAdapter.AddFolder(folder.LocalPath); SourceWorkspace.Merge(folder.ServerPath, folder.NewServerPath, VersionSpec.Latest, VersionSpec.Latest); SourceAdapter.AddFile(m_file.LocalPath); SourceWorkspace.Merge(m_file.ServerPath, m_file.NewServerPath, VersionSpec.Latest, VersionSpec.Latest); int mergeChangeset = SourceAdapter.EditFile(m_file.NewLocalPath); RunAndValidate(); VerifyNoExtraMergeCandidates(); }
public void ReverseMergeTest() { MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true); MigrationItemStrings file = new MigrationItemStrings("source/file.txt", "target/file.txt", TestEnvironment, true); SourceAdapter.AddFile(file.LocalPath); int branchChangeset = SourceAdapter.BranchItem(branch); SourceAdapter.EditFile(file.NewLocalPath); SourceWorkspace.Merge(branch.NewServerPath, branch.ServerPath, VersionSpec.ParseSingleSpec(branchChangeset.ToString(), Environment.UserName), VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.None); SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), MergeComment); RunAndValidate(); }
public void AddAddConflictTakeLocalTest() { // initial migration MigrationItemStrings file1 = new MigrationItemStrings("1.txt", "1.txt", TestEnvironment, true); SourceAdapter.AddFile(file1.LocalPath); RunAndValidate(); // add a same file on both ends string fileName = "a.txt"; MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, false); int sourceAdd = SourceAdapter.AddFile(sourceFile.LocalPath); TargetAdapter.AddFile(targetFile.LocalPath); Run(); VerifyHistory(2, 1); // resolve conflicts ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict"); VCContentConflictType contentConflict = new VCContentConflictType(); Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName), "It should be vc content conflict"); // resolve the vc content conflict. The chained conflict will be resolved automatically conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictTakeLocalChangeAction(), "$/"); // continue migration Run(true, true); conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be 0 conflict"); Assert.IsFalse(VerifyContents(), "Content should be different as we skip the add from source system."); SourceAdapter.EditFile(sourceFile.LocalPath); Run(true, true); Assert.IsTrue(VerifyContents()); }
public void BasicCloakTest() { MigrationItemStrings cloakedFile = new MigrationItemStrings("cloak" + SourceAdapter.PathSeparator + "file.txt", null, TestEnvironment, true); SourceAdapter.AddFile(cloakedFile.LocalPath); MappingPair mapping = new MappingPair(TestEnvironment.FirstSourceServerPath + SrcPathSeparator + "cloak", TestEnvironment.FirstTargetServerPath + TarPathSeparator + "cloak", true); // cloaked TestEnvironment.AddMapping(mapping); SourceAdapter.EditFile(m_extraFile.LocalPath); SourceAdapter.EditFile(cloakedFile.LocalPath); RunAndValidate(); }
public void MigrateCloakedFolderItselfTest() { MigrationItemStrings cloakedFile = new MigrationItemStrings("cloak", "cloak", TestEnvironment, true); SourceAdapter.AddFolder(cloakedFile.LocalPath); MappingPair mapping = new MappingPair(TestEnvironment.FirstSourceServerPath + SrcPathSeparator + "cloak", TestEnvironment.FirstTargetServerPath + TarPathSeparator + "cloak", true); // cloaked TestEnvironment.AddMapping(mapping); SourceAdapter.EditFile(m_extraFile.LocalPath); Run(); VerifyHistory(0, 0); }
public void MergeExtraTargetItemTest() { MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true); MigrationItemStrings mergeFile = new MigrationItemStrings(TestUtils.URIPathCombine(branch.Name, "mergeFile.txt"), null, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(TestUtils.URIPathCombine(branch.NewName, "targetFile.txt"), null, TestEnvironment, true); SourceAdapter.AddFile(mergeFile.LocalPath); int branchChangeset = SourceAdapter.BranchItem(branch); SourceAdapter.EditFile(mergeFile.LocalPath); SourceAdapter.AddFile(targetFile.LocalPath); SourceAdapter.MergeItem(branch, branchChangeset); RunAndValidate(); }
public void MergeCyclicRenameTest() { MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true); MigrationItemStrings folder1 = new MigrationItemStrings("source/folder1/", null, TestEnvironment, true); MigrationItemStrings folder2 = new MigrationItemStrings("source/folder2/", null, TestEnvironment, true); MigrationItemStrings temp = new MigrationItemStrings("source/temp/", null, TestEnvironment, true); MigrationItemStrings file1 = new MigrationItemStrings("source/folder1/file1.txt", null, TestEnvironment, true); MigrationItemStrings file2 = new MigrationItemStrings("source/folder2/file2.txt", null, TestEnvironment, true); SourceAdapter.AddFolder(folder1.LocalPath); SourceAdapter.AddFolder(folder2.LocalPath); SourceAdapter.AddFile(file1.LocalPath); SourceAdapter.AddFile(file2.LocalPath); int branchChangeset = SourceAdapter.BranchItem(branch); SourceAdapter.EditFile(m_extraFile.LocalPath); SourceWorkspace.PendRename(folder1.ServerPath, temp.ServerPath); SourceWorkspace.PendRename(folder2.ServerPath, folder1.ServerPath); SourceWorkspace.PendRename(temp.ServerPath, folder2.ServerPath); SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), RenameComment); SourceWorkspace.Merge(branch.ServerPath, branch.NewServerPath, VersionSpec.ParseSingleSpec(branchChangeset.ToString(), Environment.UserName), VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.AlwaysAcceptMine); SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), MergeComment); Run(); if (TestEnvironment.SourceEndPoint.AdapterType == AdapterType.TFS2008VC) { VerifyHistory(0, 0); // For orcas, there should be no difference. } else { VerifyHistory(1, 1); // Need more comparison here. // On dev 10 server, rename becomes sourceDelete+targetbranch. So the rename-from-name will exist in the original place as a deleted item. // The merge will then merge the item as a Merge|Delete. We will skip the change in this case. } }
public void EditEditConflictTakeLocalTest() { // 1. migrate a.txt -> a.txt string fileName = "a.txt"; MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, null, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(fileName, null, TestEnvironment, false); SourceAdapter.AddFile(sourceFile.LocalPath); RunAndValidate(); // 2. source system: a.txt -> edit SourceAdapter.EditFile(sourceFile.LocalPath); // 3. target system: a.txt -> edit TargetAdapter.EditFile(targetFile.LocalPath); // 4. Migration will detect a conflict Run(); VerifyHistory(2, 1); // 5. resolve conflicts ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict"); VCContentConflictType contentConflict = new VCContentConflictType(); Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName), "It should be vc content conflict"); conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictTakeLocalChangeAction(), "$/"); // 6. restart Run(true, true); // 7. validation // no remaining conflicts conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be NO conflict"); // content should match Assert.IsFalse(VerifyContents(), "The latest content should be different as a.txt is not migrated."); SourceAdapter.EditFile(sourceFile.LocalPath); Run(true, true); Assert.IsTrue(VerifyContents()); }
public void MergeCrudOutOfScopeTest() { MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true); MigrationItemStrings addedFile = new MigrationItemStrings("source/Addedfile.txt", null, TestEnvironment, true); MigrationItemStrings editFile = new MigrationItemStrings("source/Editedfile.txt", null, TestEnvironment, true); MigrationItemStrings deleteFile = new MigrationItemStrings("source/DeletedFile.txt", null, TestEnvironment, true); MigrationItemStrings undeleteFile = new MigrationItemStrings("source/UndeletedFile.txt", null, TestEnvironment, true); MigrationItemStrings branchedFile = new MigrationItemStrings("source/folder/branchedFile.txt", "source/folder2/branchFile.txt", TestEnvironment, true); MigrationItemStrings mergeFile = new MigrationItemStrings("source/folder/mergeFile.txt", "source/folder2/mergeFile.txt", TestEnvironment, true); #region Setup before the branch //All the files except for the Added file should exist before the branch SourceAdapter.AddFile(editFile.LocalPath); SourceAdapter.AddFile(deleteFile.LocalPath); SourceAdapter.AddFile(undeleteFile.LocalPath); SourceAdapter.AddFile(branchedFile.LocalPath); SourceAdapter.AddFile(mergeFile.LocalPath); int deletetionChangeset = SourceAdapter.DeleteItem(undeleteFile.ServerPath); int mergeFileChangeset = SourceAdapter.BranchItem(mergeFile.ServerPath, mergeFile.NewServerPath); SourceAdapter.EditFile(mergeFile.LocalPath); #endregion int branchChangeset = SourceAdapter.BranchItem(branch.ServerPath, branch.NewServerPath); #region Setup after Branch operation SourceAdapter.AddFile(addedFile.LocalPath); SourceAdapter.EditFile(editFile.LocalPath); SourceAdapter.DeleteItem(deleteFile.ServerPath); SourceAdapter.UndeleteFile(undeleteFile.ServerPath, deletetionChangeset); SourceAdapter.BranchItem(branchedFile.ServerPath, branchedFile.NewServerPath); SourceAdapter.MergeItem(mergeFile, mergeFileChangeset); #endregion Setup after Branch operation //The big merge SourceAdapter.MergeItem(branch, branchChangeset); // Add the mapping scope MappingPair rootMapping = TestEnvironment.Mappings[0]; TestEnvironment.Mappings.Clear(); TestEnvironment.Mappings.Add(new MappingPair(rootMapping.SourcePath, rootMapping.TargetPath, false, null, null, rootMapping.SourcePath + '/' + "target/", rootMapping.TargetPath + '/' + "target/")); RunAndValidate(true, true); }
protected void BranchParitalScenario() { MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true); MigrationItemStrings file1 = new MigrationItemStrings("source/file1.txt", null, TestEnvironment, true); MigrationItemStrings file2 = new MigrationItemStrings("source/file2.txt", null, TestEnvironment, true); SourceAdapter.AddFolder(branch.LocalPath); SourceAdapter.AddFile(file1.LocalPath); int branchFrom = SourceAdapter.AddFile(file2.LocalPath); SourceAdapter.EditFile(file2.LocalPath); SourceAdapter.EditFile(file1.LocalPath); SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite); SourceWorkspace.PendBranch(branch.ServerPath, branch.NewServerPath, VersionSpec.ParseSingleSpec(branchFrom.ToString(), Environment.UserName)); RunAndValidate(); }
public void BranchMergeEditTest() { file = new MigrationItemStrings(source.Name + "file.txt", target.Name + "file.txt", TestEnvironment, true); SourceAdapter.AddFile(file.LocalPath); SourceWorkspace.Merge(file.ServerPath, file.NewServerPath, VersionSpec.Latest, VersionSpec.Latest); int mergeChangeset = SourceAdapter.EditFile(file.NewLocalPath); RunAndValidate(); /* TfsServerDiff diff = RunNoValidate(); * Assert.AreEqual(1, diff.SourceChanges.Count, "The source system should have 1 unmatched change"); * Assert.AreEqual(1, diff.TargetChanges.Count, "The target system should have 1 unmatched change"); * Assert.AreEqual(diff.TargetChanges[0].Changes[1].ChangeType, ChangeType.Encoding | ChangeType.Branch | ChangeType.Edit | ChangeType.Merge, "Wrong change type"); * Assert.AreEqual(mergeChangeset, diff.SourceChanges[0].ChangesetId, "Wrong changeset"); */ }
public void MergeBaselessTest() { MigrationItemStrings source = new MigrationItemStrings("source", null, TestEnvironment, true); MigrationItemStrings target = new MigrationItemStrings("target", null, TestEnvironment, true); MigrationItemStrings file1 = new MigrationItemStrings("source/File.txt", null, TestEnvironment, true); MigrationItemStrings file2 = new MigrationItemStrings("source/File2.txt", null, TestEnvironment, true); SourceAdapter.AddFolder(source.LocalPath); SourceAdapter.AddFolder(target.LocalPath); int changeid = SourceAdapter.AddFile(file1.LocalPath); SourceAdapter.AddFile(file2.LocalPath); SourceAdapter.EditFile(file2.LocalPath); SourceWorkspace.Merge(source.ServerPath, target.ServerPath, VersionSpec.ParseSingleSpec(changeid.ToString(), Environment.UserName), VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.Baseless); SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), MergeComment); RunAndValidate(); }
public void MergeNonRecursiveTest() { MigrationItemStrings source = new MigrationItemStrings("source", "source2", TestEnvironment, true); MigrationItemStrings target = new MigrationItemStrings("target", null, TestEnvironment, true); MigrationItemStrings file = new MigrationItemStrings("source/file.txt", "target/file.txt", TestEnvironment, true); SourceAdapter.AddFile(file.LocalPath); int branchChangeset = SourceAdapter.BranchItem(source.ServerPath, target.ServerPath); SourceAdapter.EditFile(m_extraFile.LocalPath); SourceAdapter.EditFile(file.LocalPath); SourceAdapter.RenameItem(source.ServerPath, source.NewServerPath, "Rename source"); SourceWorkspace.Merge(source.NewServerPath, target.ServerPath, VersionSpec.ParseSingleSpec(branchChangeset.ToString(), Environment.UserName), VersionSpec.Latest, LockLevel.None, RecursionType.None, MergeOptions.ForceMerge); SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), MergeComment); SourceAdapter.EditFile(m_extraFile.LocalPath); RunAndValidate(); }
public void MergeCrudTest() { MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true); MigrationItemStrings addedFile = new MigrationItemStrings("source/Addedfile.txt", null, TestEnvironment, true); MigrationItemStrings editFile = new MigrationItemStrings("source/Editedfile.txt", null, TestEnvironment, true); MigrationItemStrings deleteFile = new MigrationItemStrings("source/DeletedFile.txt", null, TestEnvironment, true); MigrationItemStrings undeleteFile = new MigrationItemStrings("source/UndeletedFile.txt", null, TestEnvironment, true); MigrationItemStrings branchedFile = new MigrationItemStrings("source/folder/branchedFile.txt", "source/folder2/branchFile.txt", TestEnvironment, true); MigrationItemStrings mergeFile = new MigrationItemStrings("source/folder/mergeFile.txt", "source/folder2/mergeFile.txt", TestEnvironment, true); #region Setup before the branch //All the files except for the Added file should exist before the branch SourceAdapter.AddFile(editFile.LocalPath); SourceAdapter.AddFile(deleteFile.LocalPath); SourceAdapter.AddFile(undeleteFile.LocalPath); SourceAdapter.AddFile(branchedFile.LocalPath); SourceAdapter.AddFile(mergeFile.LocalPath); int deletetionChangeset = SourceAdapter.DeleteItem(undeleteFile.ServerPath); int mergeFileChangeset = SourceAdapter.BranchItem(mergeFile.ServerPath, mergeFile.NewServerPath); SourceAdapter.EditFile(mergeFile.LocalPath); #endregion int branchChangeset = SourceAdapter.BranchItem(branch.ServerPath, branch.NewServerPath); #region Setup after Branch operation SourceAdapter.AddFile(addedFile.LocalPath); SourceAdapter.EditFile(editFile.LocalPath); SourceAdapter.DeleteItem(deleteFile.ServerPath); SourceAdapter.UndeleteFile(undeleteFile.ServerPath, deletetionChangeset); SourceAdapter.BranchItem(branchedFile.ServerPath, branchedFile.NewServerPath); SourceAdapter.MergeItem(mergeFile, mergeFileChangeset); #endregion Setup after Branch operation //The big merge SourceAdapter.MergeItem(branch, branchChangeset); RunAndValidate(); }
public void DeleteUnmappedTest() { MigrationItemStrings cloakedFile = new MigrationItemStrings("cloak" + SourceAdapter.PathSeparator + "file.txt", null, TestEnvironment, true); SourceAdapter.AddFile(cloakedFile.LocalPath); MappingPair mapping = new MappingPair(TestEnvironment.FirstSourceServerPath + SrcPathSeparator + "cloak", TestEnvironment.FirstTargetServerPath + TarPathSeparator + "cloak", true); // cloaked TestEnvironment.AddMapping(mapping); SourceAdapter.EditFile(cloakedFile.LocalPath); SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite); TestUtils.EditRandomFile(cloakedFile.LocalPath); SourceWorkspace.PendDelete(cloakedFile.LocalPath); // Extra file and deleted file will be checked in together. SourceAdapter.EditFile(m_extraFile.LocalPath); RunAndValidate(); }
public void CloakedTargetMappingsTest() { MigrationItemStrings file = new MigrationItemStrings("source" + SourceAdapter.PathSeparator + "file.txt", "target" + SourceAdapter.PathSeparator + "file.txt", TestEnvironment, true); SourceAdapter.AddFile(file.LocalPath); MappingPair mapping = new MappingPair(TestEnvironment.FirstSourceServerPath + SrcPathSeparator + "target", TestEnvironment.FirstTargetServerPath + TarPathSeparator + "target", true); // cloaked TestEnvironment.AddMapping(mapping); int branchChangeset = SourceAdapter.BranchItem(file.ServerPath, file.NewServerPath); SourceAdapter.EditFile(m_extraFile.LocalPath); SourceAdapter.EditFile(file.LocalPath); int mergeChangset = SourceAdapter.MergeItem(file, branchChangeset); RunAndValidate(); }
public void SnapshotCRUDTest() { MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true); MigrationItemStrings[] files = new MigrationItemStrings[10]; // Add files for (int i = 0; i < 10; i++) { files[i] = new MigrationItemStrings(string.Format("source/file{0}.txt", i), string.Format("source/file-rename{0}.txt", i), TestEnvironment, true); SourceAdapter.AddFile(files[i].LocalPath); } SourceAdapter.EditFile(files[2].LocalPath); SourceAdapter.RenameItem(files[3].ServerPath, files[3].NewServerPath, "Rename before snapshot"); int deleteChangesetID = SourceAdapter.DeleteItem(files[4].ServerPath); SourceAdapter.DeleteItem(files[5].ServerPath); SourceAdapter.UndeleteFile(files[4].ServerPath, deleteChangesetID); int snapshotChangesetId = SourceAdapter.RenameItem(files[6].ServerPath, files[6].NewServerPath, "Rename before snapshot"); SourceAdapter.EditFile(files[6].NewLocalPath); SourceAdapter.DeleteItem(files[4].ServerPath); SourceAdapter.RenameItem(files[3].NewServerPath, files[3].ServerPath, "Rename after snapshot"); TestEnvironment.SnapshotStartPoints = new Dictionary <string, string>(); TestEnvironment.SnapshotStartPoints.Add(TestEnvironment.SourceTeamProject, snapshotChangesetId.ToString()); TestEnvironment.SnapshotBatchSize = 3; Run(); VerifySnapshotMigration(snapshotChangesetId); Assert.IsTrue(VerifyContents()); }
public void BranchMergeEditWithSourceNotMappedTest() { MigrationItemStrings branch = new MigrationItemStrings("source", "target", TestEnvironment, true); MigrationItemStrings file = new MigrationItemStrings("source/fld/file.txt", "target/fld/file.txt", TestEnvironment, true); // Add the parent folder at branch from place SourceAdapter.AddFolder(branch.LocalPath); MappingPair mapping = new MappingPair(TestEnvironment.FirstSourceServerPath + SrcPathSeparator + "source", TestEnvironment.FirstTargetServerPath + TarPathSeparator + "source", true); // cloaked TestEnvironment.AddMapping(mapping); // Branch the parent folder int branchChangeset = SourceAdapter.BranchItem(branch.ServerPath, branch.NewServerPath); // Add the child item SourceAdapter.AddFile(file.LocalPath); SourceWorkspace.Merge(branch.ServerPath, branch.NewServerPath, VersionSpec.ParseSingleSpec(branchChangeset.ToString(), Environment.UserName), VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.None); ResolveConflicts(Resolution.AcceptTheirs); SourceAdapter.EditFile(file.NewLocalPath); Run(); VerifyHistory(4, 0); // Resolve "Branch source path not found conflict" using "$/" scope. ConflictResolver conflictManager = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictManager.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be only 1 conflict"); conflictManager.TryResolveConflict(conflicts[0], new VCChangeToAddOnBranchSourceNotMappedAction(), "$/"); // Add on branch source not found RunAndValidate(true, true); }
public void RenameEditUndeleteMergeTest() { int changesetId = AddBranch(); MergeDeletePendUndelete(file, changesetId); SourceWorkspace.PendRename(file.ServerPath, file.NewServerPath); SourceAdapter.EditFile(file.NewLocalPath); SourceWorkspace.Merge(source.LocalPath, target.LocalPath, VersionSpec.ParseSingleSpec(changesetId.ToString(), Environment.UserName), VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.None); resolveConflictAcceptThiers(); if (TestEnvironment.SourceTFSVersion == TFSVersionEnum.TFS2010) { Run(); Assert.IsTrue(VerifyContents()); } else { RunAndValidate(); } }
/// <summary> /// Checkin a merge conflict resolved with the specified resolution then verify its migration /// </summary> /// <param name="resolution">The resolution to test</param> private void ResolutionScenario(Resolution resolution) { MigrationItemStrings source = new MigrationItemStrings("source", null, TestEnvironment, true); MigrationItemStrings target = new MigrationItemStrings("target", null, TestEnvironment, true); MigrationItemStrings file1 = new MigrationItemStrings("source/File.txt", null, TestEnvironment, true); MigrationItemStrings file2 = new MigrationItemStrings("source/File2.txt", "target/File2.txt", TestEnvironment, true); int changeid = SourceAdapter.AddFile(file1.LocalPath); SourceAdapter.AddFile(file2.LocalPath); SourceAdapter.BranchItem(source.ServerPath, target.ServerPath); SourceAdapter.EditFile(file2.LocalPath); SourceAdapter.EditFile(file2.NewLocalPath); SourceWorkspace.Merge(source.ServerPath, target.ServerPath, VersionSpec.ParseSingleSpec(changeid.ToString(), Environment.UserName), VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.None); ResolveConflicts(resolution); SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), MergeComment); RunAndValidate(); }
public void PathSnapshotBranchTest() { MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true); MigrationItemStrings branch2 = new MigrationItemStrings("source/", "target2/", TestEnvironment, true); MigrationItemStrings[] addFiles = new MigrationItemStrings[10]; // Add files // Create a tree structure so that we can test path compression logic. int sessionSnapshotChangesetId = 1; for (int i = 0; i < 10; i++) { addFiles[i] = new MigrationItemStrings( string.Format("source/addFile{0}.txt", i), string.Format("source/addFile{0}-rename.txt", i), TestEnvironment, true); SourceAdapter.AddFile(addFiles[i].LocalPath); } int editBeforeSnapshotChangesetId = SourceAdapter.EditFile(addFiles[2].LocalPath); int editBeforeSnapshotChangesetId2 = SourceAdapter.EditFile(addFiles[2].LocalPath); SourceAdapter.RenameItem(addFiles[3].ServerPath, addFiles[3].NewServerPath, "Rename before snapshot"); int deleteChangesetID = SourceAdapter.DeleteItem(addFiles[4].ServerPath); SourceAdapter.DeleteItem(addFiles[5].ServerPath); SourceAdapter.UndeleteFile(addFiles[4].ServerPath, deleteChangesetID); int path2SnapshotChangesetId = SourceAdapter.RenameItem(addFiles[6].ServerPath, addFiles[6].NewServerPath, "Rename before snapshot"); int editAfterSnapshotChangesetId = SourceAdapter.EditFile(addFiles[6].NewLocalPath); int editAfterSnapshotChangesetId2 = SourceAdapter.EditFile(addFiles[6].NewLocalPath); SourceAdapter.DeleteItem(addFiles[4].ServerPath); SourceAdapter.RenameItem(addFiles[3].NewServerPath, addFiles[3].ServerPath, "Rename after snapshot"); // Branch from a version before the snapshot SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite); SourceWorkspace.PendBranch(branch.ServerPath, branch.NewServerPath, new ChangesetVersionSpec(editBeforeSnapshotChangesetId)); SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), "Branch from a version before snapshot"); SourceAdapter.BranchItem(branch2.ServerPath, branch2.NewServerPath); TestEnvironment.SnapshotStartPoints = new Dictionary <string, string>(); TestEnvironment.SnapshotStartPoints.Add(TestEnvironment.SourceTeamProject, sessionSnapshotChangesetId.ToString()); TestEnvironment.SnapshotBatchSize = 3; // We need to map to the sub item level MappingPair rootMapping = TestEnvironment.Mappings[0]; TestEnvironment.Mappings.Clear(); TestEnvironment.Mappings.Add(new MappingPair(rootMapping.SourcePath + "/target", rootMapping.TargetPath + "/target", false)); TestEnvironment.Mappings.Add(new MappingPair(rootMapping.SourcePath + "/target2", rootMapping.TargetPath + "/target2", false)); TestEnvironment.Mappings.Add(new MappingPair(rootMapping.SourcePath + "/source", rootMapping.TargetPath + "/source", false, path2SnapshotChangesetId.ToString(), null)); Run(); ConflictResolver conflictManager = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictManager.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be only 1 conflict"); conflictManager.TryResolveConflict(conflicts[0], ConflictConstant.TFSHistoryNotFoundSkipAction, "1-" + path2SnapshotChangesetId); Run(true, true); // ToDo, ideally, we should compare content at snapshot changeset and compare history after snapshot changeset. Assert.IsTrue(VerifyContents()); }
public void PathSnapshotCRUDTest() { MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true); MigrationItemStrings[] path1AddFiles = new MigrationItemStrings[10]; MigrationItemStrings[] path2AddFiles = new MigrationItemStrings[10]; // Add files // Create a tree structure so that we can test path compression logic. int sessionSnapshotChangesetId = 0; for (int i = 0; i < 10; i++) { path1AddFiles[i] = new MigrationItemStrings(string.Format("source/path1/addFile{0}.txt", i), null, TestEnvironment, true); if (i == 7) { sessionSnapshotChangesetId = SourceAdapter.AddFile(path1AddFiles[i].LocalPath); } else { SourceAdapter.AddFile(path1AddFiles[i].LocalPath); } } for (int i = 0; i < 10; i++) { path2AddFiles[i] = new MigrationItemStrings(string.Format("source/path2/file{0}.txt", i), string.Format("source/path2/file-rename{0}.txt", i), TestEnvironment, true); SourceAdapter.AddFile(path2AddFiles[i].LocalPath); } SourceAdapter.EditFile(path2AddFiles[2].LocalPath); SourceAdapter.RenameItem(path2AddFiles[3].ServerPath, path2AddFiles[3].NewServerPath, "Rename before snapshot"); int deleteChangesetID = SourceAdapter.DeleteItem(path2AddFiles[4].ServerPath); SourceAdapter.DeleteItem(path2AddFiles[5].ServerPath); SourceAdapter.UndeleteFile(path2AddFiles[4].ServerPath, deleteChangesetID); int path2SnapshotChangesetId = SourceAdapter.RenameItem(path2AddFiles[6].ServerPath, path2AddFiles[6].NewServerPath, "Rename before snapshot"); SourceAdapter.EditFile(path2AddFiles[6].NewLocalPath); SourceAdapter.DeleteItem(path2AddFiles[4].ServerPath); SourceAdapter.RenameItem(path2AddFiles[3].NewServerPath, path2AddFiles[3].ServerPath, "Rename after snapshot"); TestEnvironment.SnapshotStartPoints = new Dictionary <string, string>(); TestEnvironment.SnapshotStartPoints.Add(TestEnvironment.SourceTeamProject, sessionSnapshotChangesetId.ToString()); TestEnvironment.SnapshotBatchSize = 3; // We need to map to the sub item level MappingPair rootMapping = TestEnvironment.Mappings[0]; TestEnvironment.Mappings.Clear(); TestEnvironment.Mappings.Add(new MappingPair(rootMapping.SourcePath + "/source/path1", rootMapping.TargetPath + "/source/path1", false)); TestEnvironment.Mappings.Add(new MappingPair(rootMapping.SourcePath + "/source/path2", rootMapping.TargetPath + "/source/path2", false, path2SnapshotChangesetId.ToString(), null)); Run(); // ToDo, ideally, we should compare content at snapshot changeset and compare history after snapshot changeset. Assert.IsTrue(VerifyContents()); }
public void SnapshotMergeUndeleteRenameTest() { // scenario // branch from source to target where source is cloaked // item1 on source was edited, deleted // item1 on source was undelete, renamed (case-only rename) (snapshot start point) // item1 was merged to target // migration uses a snapshot start point which skips migrating deletion // hence undelete, rename becomes add, rename // cloak branch from path MappingPair mapping = new MappingPair( TestEnvironment.FirstSourceServerPath + SrcPathSeparator + "source", TestEnvironment.FirstTargetServerPath + TarPathSeparator + "source", true); TestEnvironment.AddMapping(mapping); MigrationItemStrings file1 = new MigrationItemStrings("source/folder/file1.txt", "source/Folder/File1.txt", TestEnvironment, true); MigrationItemStrings file2 = new MigrationItemStrings("source/folder/file2.txt", "source/folder/File2.txt", TestEnvironment, true); MigrationItemStrings file3 = new MigrationItemStrings("source/folder/file3.txt", null, TestEnvironment, true); // branch SourceAdapter.AddFile(file1.LocalPath); SourceAdapter.AddFile(file2.LocalPath); SourceAdapter.AddFile(file3.LocalPath); int changesetId = SourceAdapter.BranchItem(source.ServerPath, target.ServerPath); // merge edit // merge delete SourceAdapter.EditFile(file1.LocalPath); int deletionId = SourceTfsClient.GetChangeset(SourceAdapter.DeleteItem(file1.ServerPath)).Changes[0].Item.DeletionId; SourceWorkspace.Merge(source.LocalPath, target.LocalPath, VersionSpec.ParseSingleSpec(changesetId.ToString(), Environment.UserName), VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.None); changesetId = SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), "edit -> delete"); // pend undelete SourceWorkspace.PendUndelete(file1.ServerPath, deletionId); // pend rename SourceWorkspace.PendRename(file1.LocalPath, file1.NewLocalPath); SourceWorkspace.PendRename(file2.LocalPath, file2.NewLocalPath); TestUtils.EditRandomFile(file3.LocalPath); SourceWorkspace.PendEdit(file3.LocalPath); changesetId = SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), "undelete rename"); int snapshotChangesetId = changesetId; // merge undelete,rename skipping deletion // migrating merge,undelete,rename becomes add,rename SourceWorkspace.Merge(source.LocalPath, target.LocalPath, VersionSpec.ParseSingleSpec(changesetId.ToString(), Environment.UserName), VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.None); resolveConflictAcceptThiers(); SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), "merge undelete rename"); // snapshot TestEnvironment.SnapshotStartPoints = new Dictionary <string, string>(); TestEnvironment.SnapshotStartPoints.Add(TestEnvironment.SourceTeamProject, snapshotChangesetId.ToString()); TestEnvironment.SnapshotBatchSize = 100; Run(); // Resolve "Branch source path not found conflict" using "$/" scope. ConflictResolver conflictManager = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictManager.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be only 1 conflict"); conflictManager.TryResolveConflict(conflicts[0], new VCChangeToAddOnBranchSourceNotMappedAction(), "$/"); // Add on branch source not found Run(); Assert.IsTrue(VerifyContents()); }
public void SnapshotMergeRenameEditTest() { // scenario // branch from source to target where source is cloaked // take the snapshot of target branch // item1 on source renamed,edited // item1 was merged to target // VC session converts merge,rename,edit to add,edit // cloak branch from path MappingPair mapping = new MappingPair( TestEnvironment.FirstSourceServerPath + SrcPathSeparator + "source", TestEnvironment.FirstTargetServerPath + TarPathSeparator + "source", true); TestEnvironment.AddMapping(mapping); MigrationItemStrings file1 = new MigrationItemStrings( string.Format("source{0}folder1{1}file1.txt", SrcPathSeparator, SrcPathSeparator), string.Format("source{0}folder2{1}file1.txt", SrcPathSeparator, SrcPathSeparator), TestEnvironment, true); MigrationItemStrings file2 = new MigrationItemStrings( string.Format("source{0}folder2{1}file2.txt", SrcPathSeparator, SrcPathSeparator), null, TestEnvironment, true); MigrationItemStrings file3 = new MigrationItemStrings( string.Format("source{0}folder1{1}file3.txt", SrcPathSeparator, SrcPathSeparator), string.Format("source{0}folder2{1}file3.txt", SrcPathSeparator, SrcPathSeparator), TestEnvironment, true); // branch SourceAdapter.AddFile(file1.LocalPath); SourceAdapter.AddFile(file2.LocalPath); SourceAdapter.AddFile(file3.LocalPath); int changesetId = SourceAdapter.BranchItem(source.ServerPath, target.ServerPath); int snapshotChangesetId = SourceAdapter.EditFile(file2.LocalPath); // pend edit on file1 SourceWorkspace.PendEdit(file1.LocalPath); TestUtils.EditRandomFile(file1.LocalPath); // pend rename (file1 is moved to a different location) SourceWorkspace.PendRename(file1.LocalPath, file1.NewLocalPath); // pend edit on file2 SourceWorkspace.PendEdit(file2.LocalPath); TestUtils.EditRandomFile(file2.LocalPath); // pend rename (file3 is moved to a different location) SourceWorkspace.PendEdit(file3.LocalPath); SourceWorkspace.PendRename(file3.LocalPath, file3.NewLocalPath); SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), "rename, edit"); // merge changes from source to target // - merge,rename,edit on file1 // - merge,edit on file2 // - merge,rename on file3 SourceWorkspace.Merge(source.LocalPath, target.LocalPath, VersionSpec.ParseSingleSpec(changesetId.ToString(), Environment.UserName), VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.None); resolveConflictAcceptThiers(); changesetId = SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), "merge,rename,edit"); // snapshot TestEnvironment.SnapshotStartPoints = new Dictionary <string, string>(); TestEnvironment.SnapshotStartPoints.Add(TestEnvironment.SourceTeamProject, snapshotChangesetId.ToString()); TestEnvironment.SnapshotBatchSize = 100; Run(); // Resolve "Branch source path not found conflict" using "$/" scope. ConflictResolver conflictManager = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictManager.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be only 1 conflict"); conflictManager.TryResolveConflict(conflicts[0], new VCChangeToAddOnBranchSourceNotMappedAction(), "$/"); // Add on branch source not found Run(); Assert.IsTrue(VerifyContents()); }
public void BranchMergeRenameEditTest() { #region repro steps //1. add $/test/main/a/1.txt //2. branch main to main-branch //3. add $/test/main/b/1.txt //4. tf merge $/test/main $/test/main-branch /r //5. rename $/test/main/b/1.txt to $/test/main/b/2.txt //6. tf merge $/test/main $/test/main-branch /r // resolve a conflict by taking the source branch change // edit $/test/main-branch/2.txt // check in // (2.txt == merge,rename,edit) //7. add $/test/main/b/1.txt //8. tf merge $/test/main $/test/main-branch /r //9. create a configuration file and map server paths like below: //<FilterPair> //<FilterItem MigrationSourceUniqueId="1ebfa76e-6f49-4ec8-b25d-03aac1b05085" FilterString="$/test/main-branch" /> //<FilterItem MigrationSourceUniqueId="67502947-0a21-4a6a-b169-7857d7e9e641" FilterString="$/test/main-branch2" /> //</FilterPair> //10. start migration console app using the config file generated in the step 9 //11. conflict detection - branch root not found //12. resolve the conflict and allow $/ for scope //13. re-start the migration consonle app //14. the exception gets thrown #endregion // 1. add $/test/main/a/1.txt MigrationItemStrings path1 = new MigrationItemStrings("main", "main-branch", TestEnvironment, true); MigrationItemStrings file1 = new MigrationItemStrings("main/a/1.txt", null, TestEnvironment, true); SourceAdapter.AddFolder(path1.LocalPath); SourceAdapter.AddFile(file1.LocalPath); // 2. branch main to main-branch SourceAdapter.BranchItem(path1.ServerPath, path1.NewServerPath); // 3. add $/test/main/b/1.txt MigrationItemStrings file2 = new MigrationItemStrings("main/b/1.txt", "main/b/2.txt", TestEnvironment, true); MigrationItemStrings file3 = new MigrationItemStrings("main-branch/b/1.txt", "main-branch/b/2.txt", TestEnvironment, true); int mergeFromVersion = SourceAdapter.AddFile(file2.LocalPath); // 4. tf merge $/test/main $/test/main-branch /r SourceWorkspace.Merge(path1.ServerPath, path1.NewServerPath, VersionSpec.ParseSingleSpec(mergeFromVersion.ToString(), Environment.UserName), VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.None); SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), MergeComment); // 5. rename $/test/main/b/1.txt to $/test/main/b/2.txt SourceAdapter.RenameItem(file2.ServerPath, file2.NewServerPath); // 6. tf merge $/test/main $/test/main-branch /r SourceWorkspace.Merge(path1.ServerPath, path1.NewServerPath, VersionSpec.ParseSingleSpec(mergeFromVersion.ToString(), Environment.UserName), VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.None); ResolveConflicts(Resolution.AcceptTheirs); SourceAdapter.EditFile(file3.NewLocalPath); // merge,rename,edit (edit the pending item 2.txt) // 7. add $/test/main/b/1.txt mergeFromVersion = SourceAdapter.AddFile(file2.LocalPath); // reuse the same file name // 8. tf merge $/test/main $/test/main-branch /r SourceWorkspace.Merge(path1.ServerPath, path1.NewServerPath, VersionSpec.ParseSingleSpec(mergeFromVersion.ToString(), Environment.UserName), VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.None); SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), MergeComment); // 9. migrate main-branch only string source = TestEnvironment.FirstSourceServerPath + SrcPathSeparator + "main-branch"; string target = TestEnvironment.FirstTargetServerPath + TarPathSeparator + "main-branch"; TestEnvironment.Mappings.Clear(); TestEnvironment.AddMapping(new MappingPair(source, target)); // 10. start migration Run(); VerifyHistory(4, 0); // Resolve "Branch source path not found conflict" using "$/" scope. ConflictResolver conflictManager = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictManager.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be only 1 conflict"); conflictManager.TryResolveConflict(conflicts[0], new VCChangeToAddOnBranchSourceNotMappedAction(), "$/"); // Add on branch source not found if (TestEnvironment.SourceTFSVersion == TFSVersionEnum.TFS2010) { Run(true, true); // verify expected differences VerifyHistory(1, 1); //Changeset targetChangeset = diff.TargetChanges[0]; //Changeset sourceChangeset = diff.SourceChanges[0]; //diff.ChangesetDiff(ref targetChangeset, ref sourceChangeset); //Assert.AreEqual(1, sourceChangeset.Changes.Length); //Assert.AreEqual(ChangeType.Merge | ChangeType.Undelete | ChangeType.Edit, // sourceChangeset.Changes[0].ChangeType & ~ChangeType.Encoding); //Assert.AreEqual(1, targetChangeset.Changes.Length); //Assert.AreEqual(ChangeType.Add | ChangeType.Edit, // targetChangeset.Changes[0].ChangeType & ~ChangeType.Encoding); // verify content matches Assert.IsTrue(VerifyContents(), "Content mismatch"); } else { RunAndValidate(true, true); } }
public void EditRenameConflictTakeMergeTest() { // 1. migrate a.txt -> a.txt string fileName = "a.txt"; MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, null, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(fileName, "b.txt", TestEnvironment, false); int changeset; changeset = SourceAdapter.AddFile(sourceFile.LocalPath); TraceManager.TraceInformation("Add Changeset: {0}, {1}", changeset, SourceAdapter.AdapterType); RunAndValidate(); // 2. source system: a.txt -> b.txt int editChangesetId = SourceAdapter.EditFile(sourceFile.LocalPath); TraceManager.TraceInformation("Edit Changeset: {0}, {1}", editChangesetId, SourceAdapter.AdapterType); // 3. target system: a.txt -> edit changeset = TargetAdapter.RenameItem(targetFile.ServerPath, targetFile.NewServerPath); TraceManager.TraceInformation("Rename Changeset: {0}, {1}", changeset, TargetAdapter.AdapterType); // 4. Migration will detect a conflict Run(); // 5. resolve conflicts // 5.1 check if we have correct conflicts in db ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be only 1 conflict"); VCNameSpaceContentConflictType namespaceConflict = new VCNameSpaceContentConflictType(); Assert.AreEqual(namespaceConflict.ReferenceName, conflicts[0].ConflictTypeReference.Value.ReferenceName, "It should be vc namespace content conflict"); // 5.2 user actions // // revert edit on a.txt PendEditToRevertFile(SourceWorkspace, sourceFile, editChangesetId, editChangesetId - 1); int sourceChangeId = SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), "user: revert edit change on a.txt **NOMIGRATION**"); TraceManager.TraceInformation("Undo Edit Changeset: {0}, {1}", sourceChangeId, SourceAdapter.AdapterType); // revert rename on target int targetChangeId = TargetAdapter.RenameItem(targetFile.NewServerPath, targetFile.ServerPath, "Revert rename change on target side **NOMIGRATION**"); TraceManager.TraceInformation("Undo Rename Changeset: {0}, {1}", targetChangeId, TargetAdapter.AdapterType); int deltaChangeId = sourceChangeId; int miChangeId = targetChangeId; if (TestEnvironment.MigrationTestType == MigrationTestType.TwoWayRight) { deltaChangeId = targetChangeId; miChangeId = sourceChangeId; } // resolve conflicts Dictionary <string, string> dataFields = new Dictionary <string, string>(); dataFields.Add(VCContentConflictUserMergeChangeAction.MigrationInstructionChangeId, miChangeId.ToString()); dataFields.Add(VCContentConflictUserMergeChangeAction.DeltaTableChangeId, deltaChangeId.ToString()); foreach (RTConflict conflict in conflicts) { conflictResolver.TryResolveConflict(conflict, new VCContentConflictUserMergeChangeAction(), "$/", dataFields); } // 6. migrate Run(); // 7. validation // no remaining conflicts and content match conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be NO conflict"); // content match Assert.IsTrue(VerifyContents()); }
public void EditEditConflictUserMergeTest() { // 1. migrate a.txt -> a.txt string fileName = "a.txt"; MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, null, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(fileName, null, TestEnvironment, false); SourceAdapter.AddFile(sourceFile.LocalPath); RunAndValidate(); // 2. source system: a.txt -> edit int sourceEditId = SourceAdapter.EditFile(sourceFile.LocalPath); // 3. target system: a.txt -> edit int targetEditId = TargetAdapter.EditFile(targetFile.LocalPath); // 4. Migration will detect a conflict Run(); VerifyHistory(2, 1); // 5. resolve conflicts ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict"); VCContentConflictType contentConflict = new VCContentConflictType(); Assert.AreEqual(contentConflict.ReferenceName, conflicts[0].ConflictTypeReference.Value.ReferenceName, "It should be vc content conflict"); int sourceId = SourceAdapter.EditFile(sourceFile.LocalPath); int targetId = TargetAdapter.EditFile(targetFile.LocalPath, sourceFile.LocalPath); int deltaChangeId = sourceId; int miChangeId = targetId; int contentConflictId = sourceEditId; if (TestEnvironment.MigrationTestType == MigrationTestType.TwoWayRight) { deltaChangeId = targetId; miChangeId = sourceId; contentConflictId = targetEditId; } Dictionary <string, string> dataFields = new Dictionary <string, string>(); dataFields.Add(VCContentConflictUserMergeChangeAction.MigrationInstructionChangeId, miChangeId.ToString()); dataFields.Add(VCContentConflictUserMergeChangeAction.DeltaTableChangeId, deltaChangeId.ToString()); conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictUserMergeChangeAction(), string.Format("$/;{0}", contentConflictId), dataFields); // 6. restart Run(); // 7. validation // no remaining conflicts conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be NO conflict"); // content should match Assert.IsTrue(VerifyContents()); }
public void AddAddConflictTakeOtherNoDeleteTest() { // initial migration MigrationItemStrings file1 = new MigrationItemStrings("1.txt", "1.txt", TestEnvironment, true); SourceAdapter.AddFile(file1.LocalPath); RunAndValidate(); // add a same file on both ends string fileName = "a.txt"; MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, false); int sourceAdd = SourceAdapter.AddFile(sourceFile.LocalPath); TargetAdapter.AddFile(targetFile.LocalPath); Run(); VerifyHistory(2, 1); // resolve conflicts ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict"); VCContentConflictType contentConflict = new VCContentConflictType(); Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName), "It should be vc content conflict"); // resolve the vc content conflict. The chained conflict will be resolved automatically conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictTakeOtherChangesAction(), "$/"); // The user decided to accept other but forgot deleting the items on target system // start a conflict resolution thread to detect 'future' TfsCheckinConflict and resolve it asynchronously ConflictResolutionWorker resolutionWorker = new ConflictResolutionWorker() { ConflictResolver = conflictResolver, }; resolutionWorker.ConflictResolutionList.Add(new ConflictResolutionEntry() { Conflict = ConflictConstant.TfsCheckinConflict, Resolution = ConflictConstant.TfsCheckinSkipAction, }); resolutionWorker.ConflictResolutionList.Add(new ConflictResolutionEntry() { Conflict = ConflictConstant.TFSZeroCheckinConflict, Resolution = new TFSZeroCheckinSkipAction().ReferenceName, }); resolutionWorker.Start(); // restart the migraiton tool // migration tool will be in a loop until the TfsCheckinConflict gets resolved Run(true, true); Assert.IsTrue(VerifyContents(), "Content should be the same."); SourceAdapter.EditFile(sourceFile.LocalPath); Run(true, true); Trace.WriteLine("Stopping ConflictResolutionWorker"); resolutionWorker.Stop(); Assert.IsTrue(VerifyContents(), "Content should match!"); }
public void RenameRenameConflictUserMergeTest() { // 1. migrate a.txt -> a.txt string fileName = "a.txt"; MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, "b.txt", TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(fileName, "c.txt", TestEnvironment, false); MigrationItemStrings targetUserMergeFile = new MigrationItemStrings("c.txt", "b.txt", TestEnvironment, false); SourceAdapter.AddFile(sourceFile.LocalPath); RunAndValidate(); // 2. source system: a.txt -> b.txt int sourceId = SourceAdapter.RenameItem(sourceFile.ServerPath, sourceFile.NewServerPath); // 3. target system: a.txt -> c.txt int targetRenameId = TargetAdapter.RenameItem(targetFile.ServerPath, targetFile.NewServerPath); // 4. migrate Run(); VerifyHistory(2, 1); // 5. resolve conflicts // 5.1 User merge actions // The user decided to accept other so he reverted the rename change on target system. c.txt -> a.txt int targetId = TargetAdapter.RenameItem(targetUserMergeFile.ServerPath, targetUserMergeFile.NewServerPath, "Rename target items to accept other side's renames **NOMIGRATION**"); // 5.2 resolve conflicts by VCContentConflictUserMergeChangeAction ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict"); VCNameSpaceContentConflictType nameSpaceContentConflict = new VCNameSpaceContentConflictType(); Assert.IsTrue(nameSpaceContentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName), "It should be vc namespace content conflict"); int deltaChangeId = sourceId; int miChangeId = targetId; if (TestEnvironment.MigrationTestType == MigrationTestType.TwoWayRight) { deltaChangeId = targetRenameId; miChangeId = sourceId; } Dictionary <string, string> dataFields = new Dictionary <string, string>(); dataFields.Add(VCContentConflictUserMergeChangeAction.MigrationInstructionChangeId, miChangeId.ToString()); dataFields.Add(VCContentConflictUserMergeChangeAction.DeltaTableChangeId, deltaChangeId.ToString()); conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictUserMergeChangeAction(), string.Format("$/;{0}", deltaChangeId), dataFields); // 6. Migration will detect a conflict Run(); Assert.IsTrue(VerifyContents()); SourceAdapter.EditFile(sourceFile.NewLocalPath); Run(); Assert.IsTrue(VerifyContents()); }