public void PartialMergeTest() { MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true); MigrationItemStrings file = new MigrationItemStrings("source/file.txt", "target/file.txt", TestEnvironment, true); MigrationItemStrings file2 = new MigrationItemStrings("file2.txt", "target/file2.txt", TestEnvironment, true); SourceAdapter.AddFile(file.LocalPath); SourceAdapter.AddFile(file2.LocalPath); int branchChangeset = SourceAdapter.BranchItem(branch.ServerPath, branch.NewServerPath); SourceAdapter.EditFile(file.LocalPath); SourceAdapter.EditFile(file.LocalPath); SourceAdapter.EditFile(m_extraFile.LocalPath); int mergeOne = SourceAdapter.EditFile(file2.LocalPath); SourceAdapter.EditFile(file.LocalPath); SourceAdapter.EditFile(m_extraFile.LocalPath); SourceAdapter.EditFile(file.LocalPath); int mergeTwo = SourceAdapter.EditFile(file2.LocalPath); SourceAdapter.EditFile(file.LocalPath); SourceAdapter.EditFile(file2.LocalPath); SourceAdapter.EditFile(m_extraFile.LocalPath); SourceAdapter.MergeItem(branch, branchChangeset, mergeOne); SourceAdapter.MergeItem(branch, branchChangeset, mergeTwo); SourceAdapter.MergeItem(branch, branchChangeset, SourceTfsClient.GetLatestChangesetId()); RunAndValidate(); }
public void MapBranchRootTest() { MigrationItemStrings branch = new MigrationItemStrings("source" + SourceAdapter.PathSeparator, "target" + SourceAdapter.PathSeparator, TestEnvironment, true); MigrationItemStrings file = new MigrationItemStrings(branch.Name + SourceAdapter.PathSeparator + "file.txt", branch.NewName + SourceAdapter.PathSeparator + "file.txt", TestEnvironment, true); SourceAdapter.AddFile(file.LocalPath); //Remap the migration string source = TestEnvironment.FirstSourceServerPath; string target = TestEnvironment.FirstTargetServerPath; TestEnvironment.Mappings.Clear(); TestEnvironment.AddMapping(new MappingPair(source + SrcPathSeparator + branch.Name, target + TarPathSeparator + branch.Name, false)); TestEnvironment.AddMapping(new MappingPair(source + SrcPathSeparator + branch.NewName, target + TarPathSeparator + branch.NewName, false)); TestEnvironment.AddMapping(new MappingPair(source + SrcPathSeparator + m_extraFile.Name, target + TarPathSeparator + m_extraFile.Name, false)); int branchChangeset = SourceAdapter.BranchItem(branch.ServerPath, branch.NewServerPath); SourceAdapter.EditFile(file.LocalPath); SourceAdapter.MergeItem(branch, branchChangeset); SourceAdapter.EditFile(m_extraFile.LocalPath); RunAndValidate(); }
public void SnapshotUndeleteTest() { /* * Descripton from the bug: * Item is undeleted *after* snapshot. * Then it is merged from version after snapshot. * After merge, we pend another edit. * This is on the source system. * On the target, since undelete is before snapshot, we change it to add. * But merge is valid because it is after snapshot, * so we pend merge and that becomes branch, merge. * Finally, when we pend edit, it will say that item can not be found or * that you do not have permission to access it - basically, item cannot be found. */ // 0. setup MigrationItemStrings branch = new MigrationItemStrings("main", "main-branch", TestEnvironment, true); MigrationItemStrings filea1 = new MigrationItemStrings("main/a1.txt", null, TestEnvironment, true); MigrationItemStrings filea2 = new MigrationItemStrings("main/a2.txt", null, TestEnvironment, true); MigrationItemStrings fileb1 = new MigrationItemStrings("main-branch/a1.txt", null, TestEnvironment, true); MigrationItemStrings fileb2 = new MigrationItemStrings("main-branch/a2.txt", null, TestEnvironment, true); SourceAdapter.AddFolder(branch.LocalPath); SourceAdapter.AddFile(filea1.LocalPath); SourceAdapter.AddFile(filea2.LocalPath); SourceAdapter.BranchItem(branch.ServerPath, branch.NewServerPath); // delete b1.txt int deleteChangesetId = SourceAdapter.DeleteItem(fileb1.ServerPath); // snapshot changeset id int snapshotChangesetId = SourceAdapter.EditFile(fileb2.LocalPath); // undelete b1.txt SourceAdapter.UndeleteFile(fileb1.ServerPath, deleteChangesetId); // merge from version after snapshot changeset id int mergeAfterSnapshotId = SourceAdapter.EditFile(filea1.LocalPath); SourceAdapter.MergeItem(branch, mergeAfterSnapshotId); // edit the item SourceAdapter.EditFile(fileb1.LocalPath); // migration TestEnvironment.SnapshotStartPoints = new Dictionary <string, string>(); TestEnvironment.SnapshotStartPoints.Add(TestEnvironment.SourceTeamProject, snapshotChangesetId.ToString()); TestEnvironment.SnapshotBatchSize = 100; Run(); // ToDo, ideally, we should compare content at snapshot changeset and compare history after snapshot changeset. //verifyChangesetAfterSnapshot(tfsDiff, snapshotChangesetId); Assert.IsTrue(VerifyContents()); }
public void MergeDeleteTest() { MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true); MigrationItemStrings deleteFile = new MigrationItemStrings("source/DeletedFile.txt", null, TestEnvironment, true); SourceAdapter.AddFile(deleteFile.LocalPath); int branchChangeset = SourceAdapter.BranchItem(branch.ServerPath, branch.NewServerPath); SourceAdapter.DeleteItem(deleteFile.ServerPath); SourceAdapter.MergeItem(branch, branchChangeset); RunAndValidate(); }
public void BatchMergeTest() { MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true); MigrationItemStrings[] mergeFiles = new MigrationItemStrings[200]; // Add files // Create a tree structure so that we can test path compression logic. for (int i = 0; i < 10; i++) { mergeFiles[i] = new MigrationItemStrings(string.Format("source/mergeFile{0}.txt", i), null, TestEnvironment, true); pendAdd(mergeFiles[i].LocalPath); } for (int i = 10; i < 50; i++) { mergeFiles[i] = new MigrationItemStrings(string.Format("source/sub1/mergeFile{0}.txt", i), null, TestEnvironment, true); pendAdd(mergeFiles[i].LocalPath); } for (int i = 50; i < 150; i++) { mergeFiles[i] = new MigrationItemStrings(string.Format("source/sub2/mergeFile{0}.txt", i), null, TestEnvironment, true); pendAdd(mergeFiles[i].LocalPath); } for (int i = 150; i < 200; i++) { mergeFiles[i] = new MigrationItemStrings(string.Format("source/sub1/sub11/mergeFile{0}.txt", i), null, TestEnvironment, true); pendAdd(mergeFiles[i].LocalPath); } SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), AddComment); // The branch int branchChangeset = SourceAdapter.BranchItem(branch); #region Setup after Branch operation for (int i = 0; i < 200; i++) { pendEdit(mergeFiles[i].LocalPath); } #endregion Setup after Branch operation SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), MergeComment); //The big merge SourceAdapter.MergeItem(branch, branchChangeset); RunAndValidate(); }
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.ServerPath, branch.NewServerPath); SourceAdapter.EditFile(mergeFile.LocalPath); SourceAdapter.AddFile(targetFile.LocalPath); SourceAdapter.MergeItem(branch, branchChangeset); RunAndValidate(); }
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); }
public void RenameNamespaceReuseMergeTest() { MigrationItemStrings sourceFolder = new MigrationItemStrings("source/folder", "source/folder-rename", TestEnvironment, true); MigrationItemStrings sourceFile = new MigrationItemStrings("source/folder/file.txt", "source/folder/file.txt", TestEnvironment, true); MigrationItemStrings branchItem = new MigrationItemStrings("source", "target", TestEnvironment, true); SourceAdapter.AddFile(sourceFile.LocalPath); SourceAdapter.BranchItem(branchItem); int deleteChangeset = SourceAdapter.DeleteItem(sourceFile.ServerPath); SourceAdapter.AddFile(sourceFile.LocalPath); SourceAdapter.RenameItem(sourceFolder.ServerPath, sourceFolder.NewServerPath); SourceAdapter.MergeItem(branchItem, deleteChangeset); 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 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 MergeSourceRenameAndDeleteTest() { MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true); MigrationItemStrings folder2 = new MigrationItemStrings("folder2/", null, TestEnvironment, true); MigrationItemStrings file1 = new MigrationItemStrings(branch.Name + "file1.txt", null, TestEnvironment, true); MigrationItemStrings file2 = new MigrationItemStrings(branch.Name + "file2.txt", folder2.Name + "file2.txt", TestEnvironment, true); SourceAdapter.AddFolder(folder2.LocalPath); SourceAdapter.AddFile(file1.LocalPath); SourceAdapter.AddFile(file2.LocalPath); SourceAdapter.BranchItem(branch); SourceAdapter.RenameItem(file2.LocalPath, file2.NewLocalPath); SourceAdapter.DeleteItem(file1.LocalPath); SourceAdapter.MergeItem(branch, 1); RunAndValidate(); }