コード例 #1
0
        public void RenameMergeTest()
        {
            MigrationItemStrings file1 = new MigrationItemStrings(source.Name + "file1.txt", source.Name + "renamed-file1.txt", TestEnvironment, true);

            SourceAdapter.AddFile(file1.LocalPath);

            MigrationItemStrings file2 = new MigrationItemStrings(source.Name + "file2.txt", source.Name + "renamed-file2.txt", TestEnvironment, true);

            SourceAdapter.AddFile(file2.LocalPath);

            int changesetId = AddBranch();

            SourceAdapter.RenameItem(file.ServerPath, file.NewServerPath, AddComment);
            SourceAdapter.RenameItem(file1.ServerPath, file1.NewServerPath, AddComment);
            SourceAdapter.RenameItem(file2.ServerPath, file2.NewServerPath, AddComment);

            SourceWorkspace.Merge(source.LocalPath, target.LocalPath,
                                  VersionSpec.ParseSingleSpec(changesetId.ToString(), Environment.UserName),
                                  VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.ForceMerge);

            Conflict[] conflicts = SourceWorkspace.QueryConflicts(new string[] { "$/" }, true);

            foreach (Conflict conflict in conflicts)
            {
                conflict.Resolution = Resolution.AcceptTheirs;
                SourceWorkspace.ResolveConflict(conflict);
            }

            RunAndValidate();
        }
コード例 #2
0
        public void RenameCaseTest()
        {
            MigrationItemStrings folder;
            MigrationItemStrings file;

            if ((SourceAdapter.AdapterType == AdapterType.TFS2008VC) ||
                (SourceAdapter.AdapterType == AdapterType.TFS2010VC))
            {
                // change case only
                folder = new MigrationItemStrings("FOLDER", "folder", TestEnvironment, true);
                file   = new MigrationItemStrings("file.txt", "FILE.txt", TestEnvironment, true);
            }
            else
            {
                // non-TFS adapters don't support case-only rename
                folder = new MigrationItemStrings("FOLDER1", "folder2", TestEnvironment, true);
                file   = new MigrationItemStrings("file1.txt", "FILE2.txt", TestEnvironment, true);
            }

            SourceAdapter.AddFolder(folder.LocalPath);
            SourceAdapter.AddFile(file.LocalPath);

            SourceAdapter.RenameItem(folder.LocalPath, folder.NewLocalPath);
            SourceAdapter.RenameItem(file.LocalPath, file.NewLocalPath);

            RunAndValidate();
        }
コード例 #3
0
        public void MergeMovesTest()
        {
            MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true);
            MigrationItemStrings file   = new MigrationItemStrings("source/file.txt", "source/sub/file.txt", TestEnvironment, true);
            MigrationItemStrings file2  = new MigrationItemStrings("source/file2.txt", "source/sub/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);

            SourceAdapter.RenameItem(file.ServerPath, file.NewServerPath);
            SourceAdapter.RenameItem(file2.ServerPath, file2.NewServerPath);

            SourceWorkspace.Merge(branch.ServerPath, branch.NewServerPath,
                                  VersionSpec.ParseSingleSpec(branchChangeset.ToString(),
                                                              Environment.UserName), VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.None);
            ResolveConflicts(Resolution.AcceptTheirs);
            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), MergeComment);

            RunAndValidate();
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        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 deltaChangeId = SourceAdapter.RenameItem(sourceFile.ServerPath, sourceFile.NewServerPath);

            // 3. target system: a.txt -> c.txt
            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 miChangeId = 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");

            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(true, true);
            Assert.IsTrue(VerifyContents());

            SourceAdapter.EditFile(sourceFile.NewLocalPath);
            Run(true, true);
            Assert.IsTrue(VerifyContents());
        }
コード例 #6
0
        public void RenameCaseTest()
        {
            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);

            SourceAdapter.RenameItem(folder.LocalPath, folder.NewLocalPath);
            SourceAdapter.RenameItem(file.LocalPath, file.NewLocalPath);

            RunAndValidate();
        }
コード例 #7
0
        public void RollbackRenameTest()
        {
            MigrationItemStrings sourceFile = new MigrationItemStrings("a.txt", "b.txt", TestEnvironment, true);

            SourceAdapter.AddFile(sourceFile.LocalPath);

            // 1. rename a.txt
            int renameChangesetId = SourceAdapter.RenameItem(sourceFile.ServerPath, sourceFile.NewServerPath);

            // 2. Rollback the rename
            SourceAdapter.Rollback(renameChangesetId, renameChangesetId);

            RunAndValidate();
        }
コード例 #8
0
        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();
        }
コード例 #9
0
        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();
        }
コード例 #10
0
        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();
        }
コード例 #11
0
        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();
        }
コード例 #12
0
        public void RenameSubstringTest()
        {
            MigrationItemStrings subStringFile     = new MigrationItemStrings("file.txt", "renamed-file.txt", TestEnvironment, true);
            MigrationItemStrings superStringFile   = new MigrationItemStrings("file.txt1", "renamed-file.txt1", TestEnvironment, true);
            MigrationItemStrings subStringFolder   = new MigrationItemStrings("folder", "renamed-folder", TestEnvironment, true);
            MigrationItemStrings superStringFolder = new MigrationItemStrings("folder1", "renamed-folder1", TestEnvironment, true);

            SourceAdapter.AddFile(subStringFile.LocalPath);
            SourceAdapter.AddFile(superStringFile.LocalPath);
            SourceAdapter.AddFolder(subStringFolder.LocalPath);
            SourceAdapter.AddFolder(superStringFolder.LocalPath);

            SourceAdapter.RenameItem(subStringFile.LocalPath, subStringFile.NewLocalPath);
            SourceAdapter.RenameItem(superStringFile.LocalPath, superStringFile.NewLocalPath);

            SourceAdapter.RenameItem(subStringFolder.LocalPath, subStringFolder.NewLocalPath);
            SourceAdapter.RenameItem(superStringFolder.LocalPath, superStringFolder.NewLocalPath);

            RunAndValidate();
        }
コード例 #13
0
        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();
        }
コード例 #14
0
        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();
        }
コード例 #15
0
        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());
        }
コード例 #16
0
        public void CloakedSourceMappingsTest()
        {
            MigrationItemStrings branch = new MigrationItemStrings("source", "target", TestEnvironment, true);
            MigrationItemStrings file   = new MigrationItemStrings("source" + SourceAdapter.PathSeparator + "file.txt",
                                                                   "source" + SourceAdapter.PathSeparator + "renamedFile.txt", TestEnvironment, true);

            SourceAdapter.AddFile(file.LocalPath);

            MappingPair mapping = new MappingPair(TestEnvironment.FirstSourceServerPath + SrcPathSeparator + "source",
                                                  TestEnvironment.FirstTargetServerPath + TarPathSeparator + "source",
                                                  true); // cloaked

            TestEnvironment.AddMapping(mapping);

            int branchChangeset = SourceAdapter.BranchItem(branch.ServerPath, branch.NewServerPath);

            SourceAdapter.EditFile(m_extraFile.LocalPath);
            SourceAdapter.EditFile(file.LocalPath);
            SourceAdapter.RenameItem(file.ServerPath, file.NewServerPath);

            SourceWorkspace.Merge(branch.ServerPath, branch.NewServerPath,
                                  VersionSpec.ParseSingleSpec(branchChangeset.ToString(), Environment.UserName),
                                  VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.None);
            ResolveConflicts(Resolution.AcceptTheirs);
            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), MergeComment);

            Run();
            VerifyHistory(5, 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);
        }
コード例 #17
0
        public void RenameEditConflictUserMergeTest()
        {
            // 1. migrate a.txt -> a.txt
            string fileName = "a.txt";
            MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, "b.txt", TestEnvironment, true);
            MigrationItemStrings targetFile = new MigrationItemStrings(fileName, "b.txt", TestEnvironment, false);

            SourceAdapter.AddFile(sourceFile.LocalPath);
            RunAndValidate();

            // 2. source system: a.txt -> b.txt
            int sourceChangeId = SourceAdapter.RenameItem(sourceFile.ServerPath, sourceFile.NewServerPath);

            // 3. target system: a.txt -> edit a.txt
            int editChangesetId = TargetAdapter.EditFile(targetFile.LocalPath);

            // 4. migrate
            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 merge actions

            // 1) revert edit on a.txt
            // revert edit on a.txt
            PendEditToRevertFile(TargetWorkspace, targetFile, editChangesetId, editChangesetId - 1);
            TargetWorkspace.CheckIn(TargetWorkspace.GetPendingChanges(), "user: revert edit change on a.txt **NOMIGRATION**");

            // 2) rename a.txt to b.txt on target system
            int targetChangeId = TargetAdapter.RenameItem(targetFile.ServerPath, targetFile.NewServerPath,
                                                          "user: rename a.txt to b.txt **NOMIGRATION**");

            int deltaChangeId = sourceChangeId;
            int miChangeId    = targetChangeId;

            if (TestEnvironment.MigrationTestType == MigrationTestType.TwoWayRight)
            {
                deltaChangeId = editChangesetId;
                miChangeId    = sourceChangeId;
            }

            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(), string.Format("$/;{0}", deltaChangeId), dataFields);
            }

            // 6. migrate
            Run();

            // 7. validation
            // no remaining conflicts
            conflicts = conflictResolver.GetConflicts();
            Assert.AreEqual(0, conflicts.Count, "There should be NO conflict");
            // content match
            Assert.IsTrue(VerifyContents());
        }
コード例 #18
0
        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());
        }
コード例 #19
0
        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());
        }
コード例 #20
0
        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);
            }
        }