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 BranchMergeDeleteTest() { file = new MigrationItemStrings(source.Name + "file.txt", target.Name + "file.txt", TestEnvironment, true); SourceAdapter.AddFile(file.LocalPath); SourceWorkspace.Merge(source.ServerPath, target.ServerPath, VersionSpec.Latest, VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.None); int mergeChangeset = SourceAdapter.DeleteItem(file.NewLocalPath); RunAndValidate(); }
public void RecursiveDeletesTest() { file = new MigrationItemStrings("folder/subfolder/file.txt", null, TestEnvironment, true); MigrationItemStrings folder = new MigrationItemStrings("folder", null, TestEnvironment, true); SourceAdapter.AddFile(file.LocalPath); SourceAdapter.DeleteItem(folder.ServerPath); RunAndValidate(); }
public void RecursiveBranchDeleteTest() { file = new MigrationItemStrings(source.Name + "file.txt", target.Name + "file.txt", TestEnvironment, true); SourceAdapter.AddFile(file.LocalPath); SourceWorkspace.PendBranch(source.ServerPath, target.ServerPath, VersionSpec.Latest); SourceAdapter.DeleteItem(target.ServerPath); RunAndValidate(); }
public void MergeDeleteTest() { int changesetId = AddBranch(); SourceAdapter.DeleteItem(file.ServerPath); SourceWorkspace.Merge(source.LocalPath, target.LocalPath, VersionSpec.ParseSingleSpec(changesetId.ToString(), Environment.UserName), VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.ForceMerge); RunAndValidate(); }
public void RenameNamespaceReuseTest() { MigrationItemStrings folder = new MigrationItemStrings("folder", "folder-rename", TestEnvironment, true); MigrationItemStrings file = new MigrationItemStrings("folder/file.txt", "folder/file.txt", TestEnvironment, true); SourceAdapter.AddFile(file.LocalPath); SourceAdapter.DeleteItem(file.LocalPath); SourceAdapter.AddFile(file.LocalPath); SourceAdapter.RenameItem(folder.LocalPath, folder.NewLocalPath); RunAndValidate(); }
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(); }
protected void UndeleteSourceRenameScenario(bool useSource) { MigrationItemStrings deletedFile = new MigrationItemStrings("file.txt", null, TestEnvironment, useSource); MigrationItemStrings renamedFile = new MigrationItemStrings("file.txt", "renamedFile.txt", TestEnvironment, useSource); SourceAdapter.AddFile(deletedFile.LocalPath); int deletionChangeSet = SourceAdapter.DeleteItem(deletedFile.ServerPath); SourceAdapter.AddFile(renamedFile.LocalPath); SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite); SourceWorkspace.PendRename(renamedFile.LocalPath, renamedFile.NewLocalPath); SourceAdapter.UndeleteFile(deletedFile.ServerPath, deletionChangeSet); }
private void MergeDeletePendUndelete(MigrationItemStrings item, int changesetId) { int deletionId = SourceTfsClient.GetChangeset(SourceAdapter.DeleteItem(item.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); // Check in only the merge|delete; so that the undelete may be merged over SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), MergeComment); // pend undelete SourceWorkspace.PendUndelete(item.ServerPath, deletionId); }
public void UndeleteEditTest() { MigrationItemStrings UnDeleteFolder = new MigrationItemStrings("UndeleteFolder/", null, TestEnvironment, true); MigrationItemStrings editFile = new MigrationItemStrings(UnDeleteFolder.Name + "file.txt", null, TestEnvironment, true); SourceAdapter.AddFile(editFile.LocalPath); int deleteChangeSetId = SourceAdapter.DeleteItem(UnDeleteFolder.ServerPath); PendUndelete(UnDeleteFolder.ServerPath, deleteChangeSetId); SourceAdapter.EditFile(editFile.LocalPath); RunAndValidate(); }
public void AddEditDeleteTest() { MigrationItemStrings file = new MigrationItemStrings("file.txt", "FILE.txt", TestEnvironment, true); MigrationItemStrings file2 = new MigrationItemStrings("file2.bat", "fIlE2.bat", TestEnvironment, true); MigrationItemStrings file3 = new MigrationItemStrings("file3.cmd", "file3.cmd", TestEnvironment, true); SourceAdapter.AddFile(file.LocalPath); SourceAdapter.AddFile(file2.LocalPath); SourceAdapter.AddFile(file3.LocalPath); SourceAdapter.EditFile(file2.LocalPath); SourceAdapter.DeleteItem(file3.LocalPath); RunAndValidate(); }
public void RenameWithDeletes() { MigrationItemStrings folder = new MigrationItemStrings("folder", "folder1", TestEnvironment, true); MigrationItemStrings file = new MigrationItemStrings("folder/file.txt", "folder/file.txt", TestEnvironment, true); SourceAdapter.AddFolder(folder.LocalPath); SourceAdapter.AddFile(file.LocalPath); SourceAdapter.DeleteItem(file.ServerPath); SourceAdapter.AddFile(file.LocalPath); SourceAdapter.DeleteItem(file.ServerPath); SourceAdapter.RenameItem(folder.ServerPath, folder.NewServerPath); RunAndValidate(); }
public void RollbackUnDeleteTest() { string fileName = "a.txt"; MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, null, TestEnvironment, true); SourceAdapter.AddFile(sourceFile.LocalPath); // 1. delete a.txt int deleteChangesetId = SourceAdapter.DeleteItem(sourceFile.LocalPath); // 2. Rollback the delete SourceAdapter.Rollback(deleteChangesetId, deleteChangesetId); RunAndValidate(); }
public void RollbackUndeleteEditTest() { MigrationItemStrings sourceFile = new MigrationItemStrings("a.txt", null, TestEnvironment, true); SourceAdapter.AddFile(sourceFile.LocalPath); // 1. edit a.txt int editChangesetId = SourceAdapter.EditFile(sourceFile.LocalPath); int deleteChangesetId = SourceAdapter.DeleteItem(sourceFile.LocalPath); // 2. Rollback the edit SourceAdapter.Rollback(editChangesetId, deleteChangesetId); RunAndValidate(); }
public void UndeleteParentButNotChildTest() { MigrationItemStrings file = new MigrationItemStrings("folder/file.txt", "folder/file.txt", TestEnvironment, true); MigrationItemStrings folder = new MigrationItemStrings("folder", "folder", TestEnvironment, true); SourceAdapter.AddFile(file.LocalPath); int deleteChangesetId = SourceAdapter.DeleteItem(folder.ServerPath); Item item = SourceTfsClient.GetChangeset(deleteChangesetId).Changes[0].Item; SourceWorkspace.Get(); SourceWorkspace.PendUndelete(folder.ServerPath, item.DeletionId); SourceWorkspace.Undo(file.ServerPath); SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), "Migration Test undelete"); RunAndValidate(); }
public void DeleteRenameParentTest() { MigrationItemStrings folder = new MigrationItemStrings("folder/", "renamedfolder/", TestEnvironment, true); MigrationItemStrings file1 = new MigrationItemStrings(folder.Name + "1.txt", null, TestEnvironment, true); MigrationItemStrings file2 = new MigrationItemStrings(folder.Name + "2.txt", null, TestEnvironment, true); SourceAdapter.AddFolder(folder.LocalPath); SourceAdapter.AddFile(file1.LocalPath); SourceAdapter.AddFile(file2.LocalPath); SourceAdapter.DeleteItem(file1.ServerPath); // Deleted item will show up as rename SourceAdapter.RenameItem(folder.ServerPath, folder.NewServerPath, "Rename parent folder."); 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(); }
protected void TwoDeleteUnDeleteScenario(bool useSource) { MigrationItemStrings file1 = new MigrationItemStrings("file.txt", null, TestEnvironment, useSource); MigrationItemStrings file2 = new MigrationItemStrings("file.txt", null, TestEnvironment, useSource); SourceAdapter.AddFile(file1.LocalPath); int file1ChangeSetId = SourceAdapter.DeleteItem(file1.ServerPath); SourceAdapter.AddFile(file2.LocalPath); int file2ChangeSetId = SourceAdapter.DeleteItem(file2.ServerPath); SourceAdapter.UndeleteFile(file1.ServerPath, file1ChangeSetId); SourceAdapter.DeleteItem(file1.ServerPath); SourceAdapter.UndeleteFile(file2.ServerPath, file2ChangeSetId); }
public void SourceRenameAndDeleteTest() { MigrationItemStrings folder1 = new MigrationItemStrings("folder1/", null, TestEnvironment, true); MigrationItemStrings folder2 = new MigrationItemStrings("folder2/", null, TestEnvironment, true); MigrationItemStrings file1 = new MigrationItemStrings("folder1/file1.txt", null, TestEnvironment, true); MigrationItemStrings file2 = new MigrationItemStrings("folder1/file2.txt", "folder2/file2.txt", TestEnvironment, true); SourceAdapter.AddFolder(folder1.LocalPath); SourceAdapter.AddFolder(folder2.LocalPath); SourceAdapter.AddFile(file1.LocalPath); SourceAdapter.AddFile(file2.LocalPath); SourceAdapter.RenameItem(file2.LocalPath, file2.NewLocalPath); SourceAdapter.DeleteItem(folder1.LocalPath); RunAndValidate(); }
public void BranchMergeDeleteWithSourceNotMappedTest() { 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.DeleteItem(file.NewServerPath); 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 Run(true, true); Assert.IsTrue(VerifyContents()); }
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(); }
public void RollbackEditDeleteTest() { MigrationItemStrings sourceFile = new MigrationItemStrings("a.txt", null, TestEnvironment, true); SourceAdapter.AddFile(sourceFile.LocalPath); int deleteChangesetId = SourceAdapter.DeleteItem(sourceFile.LocalPath); int deletionId = SourceWorkspace.VersionControlServer.GetChangeset(deleteChangesetId).Changes[0].Item.DeletionId; SourceWorkspace.Get(); SourceWorkspace.PendUndelete(sourceFile.ServerPath, deletionId); TestUtils.EditRandomFile(sourceFile.LocalPath); SourceWorkspace.PendEdit(sourceFile.LocalPath); int editChangesetId = SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), "UndeleteEdit"); // 2. Rollback the undelete|edit SourceAdapter.Rollback(editChangesetId, editChangesetId); 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 UndeleteCaseOnlyRenameTest() { MigrationItemStrings folder = new MigrationItemStrings("folder", "Folder", TestEnvironment, true); MigrationItemStrings file = new MigrationItemStrings("file.txt", "File.txt", TestEnvironment, true); SourceAdapter.AddFolder(folder.LocalPath); SourceAdapter.AddFile(file.LocalPath); int deleteChangeset = SourceAdapter.DeleteItem(folder.ServerPath); Item item = SourceTfsClient.GetChangeset(deleteChangeset).Changes[0].Item; SourceWorkspace.Get(); SourceWorkspace.PendUndelete(folder.LocalPath, item.DeletionId); SourceWorkspace.PendUndelete(file.LocalPath, item.DeletionId); SourceWorkspace.PendRename(folder.ServerPath, folder.NewServerPath); SourceWorkspace.PendRename(file.LocalPath, file.NewLocalPath); SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), RenameComment); RunAndValidate(); }
private void PendUndelete(MigrationItemStrings folder) { int deletionId = SourceTfsClient.GetChangeset(SourceAdapter.DeleteItem(folder.ServerPath)).Changes[0].Item.DeletionId; SourceWorkspace.PendUndelete(folder.ServerPath, deletionId); }
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 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()); }