private void PendRenameEdit(MigrationItemStrings file) { TestUtils.EditRandomFile(file.LocalPath); SourceWorkspace.PendEdit(file.LocalPath); SourceWorkspace.PendRename(file.LocalPath, file.NewLocalPath); }
private void EditUndelete(MigrationItemStrings file) { SourceAdapter.AddFile(file.LocalPath); PendUndelete(file); TestUtils.EditRandomFile(file.LocalPath); SourceWorkspace.PendEdit(file.LocalPath); }
public void BranchEditTest() { 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); TestUtils.EditRandomFile(file.NewLocalPath); SourceWorkspace.PendEdit(file.NewLocalPath); RunAndValidate(); }
public void RenameFolderEditFileTest() { file = new MigrationItemStrings("folder/file.txt", "newName/file.txt", TestEnvironment, true); MigrationItemStrings folder = new MigrationItemStrings("folder", "newName", TestEnvironment, true); SourceAdapter.AddFile(file.LocalPath); TestUtils.EditRandomFile(file.LocalPath); SourceWorkspace.PendEdit(file.LocalPath); SourceWorkspace.PendRename(folder.LocalPath, folder.NewLocalPath); RunAndValidate(); }
public void EditEditMultipleItemsTest() { // 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); MigrationItemStrings nonConflictFile = new MigrationItemStrings("b.txt", null, TestEnvironment, true); SourceAdapter.AddFile(sourceFile.LocalPath); SourceAdapter.AddFile(nonConflictFile.LocalPath); RunAndValidate(); // 2. source system: a.txt -> edit SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite); TestUtils.EditRandomFile(nonConflictFile.LocalPath); SourceWorkspace.PendEdit(nonConflictFile.LocalPath); // This will checkin both a.txt and b.txt int contentConflictChangeset = 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(2, conflicts.Count, "There should be 2 conflicts"); 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); // TfsCheckinConflict needs to be resolved manually. Otherwise, this test will loop until time-out. // 7. validation // no remaining conflicts conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be NO conflict"); // content should not match Assert.IsFalse(VerifyContents(), "The latest content should be different as a.txt is not migrated."); }
protected void ChainedRenameEdit(bool useSource) { MigrationItemStrings file1 = new MigrationItemStrings("CodeGenProject.vb", null, TestEnvironment, useSource); MigrationItemStrings file2 = new MigrationItemStrings("CodeGenSolution.vb", null, TestEnvironment, useSource); MigrationItemStrings file3 = new MigrationItemStrings("CodeGenTable.vb", null, TestEnvironment, useSource); SourceAdapter.AddFile(file1.LocalPath); SourceAdapter.AddFile(file2.LocalPath); SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite); TestUtils.EditRandomFile(file1.LocalPath); SourceWorkspace.PendEdit(file1.LocalPath); TestUtils.EditRandomFile(file2.LocalPath); SourceWorkspace.PendEdit(file2.LocalPath); SourceWorkspace.PendRename(file1.LocalPath, file3.LocalPath); SourceWorkspace.PendRename(file2.LocalPath, file1.LocalPath); SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), "ChainedRenameEdit test"); }
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 PartialCloakedChangesetTest() { MigrationItemStrings file1 = new MigrationItemStrings("folder/file1.txt", null, TestEnvironment, true); MigrationItemStrings file2 = new MigrationItemStrings("cloakfolder/file2.txt", null, TestEnvironment, true); MappingPair mapping = new MappingPair(TestEnvironment.FirstSourceServerPath + SrcPathSeparator + "cloakfolder", TestEnvironment.FirstTargetServerPath + TarPathSeparator + "cloakfolder", true); TestEnvironment.AddMapping(mapping); SourceAdapter.AddFile(file1.LocalPath); SourceAdapter.AddFile(file2.LocalPath); TestUtils.EditRandomFile(file1.LocalPath); TestUtils.EditRandomFile(file2.LocalPath); SourceWorkspace.PendEdit(file1.LocalPath); SourceWorkspace.PendEdit(file2.LocalPath); SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), "Multiple edits."); RunAndValidate(); }
private void pendEdit(string localPath) { SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite); TestUtils.EditRandomFile(localPath); SourceWorkspace.PendEdit(localPath); }
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 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()); }