Exemplo n.º 1
0
        protected void BranchCyclicalRenameTest()
        {
            MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true);

            MigrationItemStrings folder1 = new MigrationItemStrings("source/folder1/", null, TestEnvironment, true);
            MigrationItemStrings folder2 = new MigrationItemStrings("source/folder2/", null, TestEnvironment, true);
            MigrationItemStrings temp    = new MigrationItemStrings("source/temp/", null, TestEnvironment, true);

            MigrationItemStrings file1 = new MigrationItemStrings("source/folder1/file1.txt", null, TestEnvironment, true);
            MigrationItemStrings file2 = new MigrationItemStrings("source/folder2/file2.txt", null, TestEnvironment, true);

            SourceAdapter.AddFolder(folder1.LocalPath);
            SourceAdapter.AddFolder(folder2.LocalPath);

            SourceAdapter.AddFile(file1.LocalPath);
            SourceAdapter.AddFile(file2.LocalPath);

            SourceAdapter.EditFile(m_extraFile.LocalPath);

            SourceWorkspace.PendRename(folder1.ServerPath, temp.ServerPath);
            SourceWorkspace.PendRename(folder2.ServerPath, folder1.ServerPath);
            SourceWorkspace.PendRename(temp.ServerPath, folder2.ServerPath);
            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), RenameComment);

            SourceAdapter.BranchItem(branch.ServerPath, branch.NewServerPath);

            RunAndValidate();
        }
Exemplo n.º 2
0
        public void RenameDeleteMergeTest2()
        {
            MigrationItemStrings sourceFolder = new MigrationItemStrings(source.Name + "folder/", source.Name + "renamed-folder/", TestEnvironment, true);

            file = new MigrationItemStrings(sourceFolder.Name + "file.txt", sourceFolder.NewName + "file.txt", TestEnvironment, true);
            MigrationItemStrings file2         = new MigrationItemStrings(sourceFolder.Name + "file2.txt", sourceFolder.NewName + "file2.txt", TestEnvironment, true);
            MigrationItemStrings sourceFolder2 = new MigrationItemStrings(source.Name + "folder2/", source.Name + "renamed-folder2/", TestEnvironment, true);

            int changesetId = SourceAdapter.AddFile(file.LocalPath);

            SourceAdapter.AddFile(file2.LocalPath);
            SourceAdapter.AddFolder(sourceFolder2.LocalPath);
            SourceAdapter.BranchItem(source.ServerPath, target.ServerPath);

            PendRenameDelete(sourceFolder, file);
            SourceWorkspace.PendRename(sourceFolder2.LocalPath, sourceFolder2.NewLocalPath);

            CheckinMergeResolve(changesetId);

            if (TestEnvironment.SourceTFSVersion == TFSVersionEnum.TFS2010)
            {
                Run();
                Assert.IsTrue(VerifyContents());
            }
            else
            {
                RunAndValidate();
            }
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
0
        public void RenameDeleteMergeTest2()
        {
            MigrationItemStrings sourceFolder = new MigrationItemStrings(m_source.Name + "folder/", m_source.Name + "renamed-folder/", TestEnvironment, true);

            m_file = new MigrationItemStrings(sourceFolder.Name + "file.txt", sourceFolder.NewName + "file.txt", TestEnvironment, true);
            MigrationItemStrings file2         = new MigrationItemStrings(sourceFolder.Name + "file2.txt", sourceFolder.NewName + "file2.txt", TestEnvironment, true);
            MigrationItemStrings sourceFolder2 = new MigrationItemStrings(m_source.Name + "folder2/", m_source.Name + "renamed-folder2/", TestEnvironment, true);

            int changesetId = SourceAdapter.AddFile(m_file.LocalPath);

            SourceAdapter.AddFile(file2.LocalPath);
            SourceAdapter.AddFolder(sourceFolder2.LocalPath);
            SourceAdapter.BranchItem(m_source, m_target);

            PendRenameDelete(sourceFolder, m_file);
            SourceWorkspace.PendRename(sourceFolder2.LocalPath, sourceFolder2.NewLocalPath);

            CheckinMergeResolve(changesetId);

            if (TestEnvironment.SourceEndPoint.IsTfsAdapter &&
                TestEnvironment.SourceEndPoint.AdapterType >= AdapterType.TFS2010VC)
            {
                Run();
                Assert.IsTrue(VerifyContents());
            }
            else
            {
                RunAndValidate();
            }
        }
Exemplo n.º 5
0
        public void ThreeWayCyclicRenameTest()
        {
            MigrationItemStrings folder1 = new MigrationItemStrings("folder1/", null, TestEnvironment, true);
            MigrationItemStrings folder2 = new MigrationItemStrings("folder2/", null, TestEnvironment, true);
            MigrationItemStrings folder3 = new MigrationItemStrings("folder3/", null, TestEnvironment, true);
            MigrationItemStrings temp    = new MigrationItemStrings("temp/", null, TestEnvironment, true);

            MigrationItemStrings file1 = new MigrationItemStrings("folder1/file1.txt", null, TestEnvironment, true);
            MigrationItemStrings file2 = new MigrationItemStrings("folder2/file2.txt", null, TestEnvironment, true);
            MigrationItemStrings file3 = new MigrationItemStrings("folder3/file3.txt", null, TestEnvironment, true);

            SourceAdapter.AddFolder(folder1.LocalPath);
            SourceAdapter.AddFolder(folder2.LocalPath);
            SourceAdapter.AddFolder(folder3.LocalPath);
            SourceAdapter.AddFile(file1.LocalPath);
            SourceAdapter.AddFile(file2.LocalPath);
            SourceAdapter.AddFile(file3.LocalPath);

            // Create a cyclic rename of the three folders
            SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite);
            SourceWorkspace.PendRename(folder3.ServerPath, temp.ServerPath);
            SourceWorkspace.PendRename(folder2.ServerPath, folder3.ServerPath);
            SourceWorkspace.PendRename(folder1.ServerPath, folder2.ServerPath);
            SourceWorkspace.PendRename(temp.ServerPath, folder1.ServerPath);
            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), RenameComment);

            RunAndValidate();
        }
Exemplo n.º 6
0
        protected void BranchEmptyFolderScenario()
        {
            MigrationItemStrings folder = new MigrationItemStrings("source/folder", "target/folder", TestEnvironment, true);

            SourceAdapter.AddFolder(folder.LocalPath);
            SourceAdapter.BranchItem(folder.ServerPath, folder.NewServerPath);

            RunAndValidate();
        }
Exemplo n.º 7
0
        public void BranchEmptyFolderTest()
        {
            MigrationItemStrings folder = new MigrationItemStrings("source/folder", "target/folder", TestEnvironment, true);

            SourceAdapter.AddFolder(folder.LocalPath);
            SourceAdapter.BranchItem(folder);

            RunAndValidate();
        }
Exemplo n.º 8
0
        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());
        }
Exemplo n.º 9
0
        public void MergeTwoCyclicRenamesTest()
        {
            MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true);

            MigrationItemStrings folder1 = new MigrationItemStrings("source/folder1/", null, TestEnvironment, true);
            MigrationItemStrings folder2 = new MigrationItemStrings("source/folder2/", null, TestEnvironment, true);
            MigrationItemStrings folder3 = new MigrationItemStrings("source/folder3/", null, TestEnvironment, true);
            MigrationItemStrings temp    = new MigrationItemStrings("source/temp/", null, TestEnvironment, true);

            MigrationItemStrings file1    = new MigrationItemStrings("source/folder1/file1.txt", null, TestEnvironment, true);
            MigrationItemStrings file2    = new MigrationItemStrings("source/folder1/file2.txt", null, TestEnvironment, true);
            MigrationItemStrings tempFile = new MigrationItemStrings("source/folder1/tempFile.txt", null, TestEnvironment, true);

            SourceAdapter.AddFolder(folder1.LocalPath);
            SourceAdapter.AddFolder(folder2.LocalPath);
            SourceAdapter.AddFolder(folder3.LocalPath);

            SourceAdapter.AddFile(file1.LocalPath);
            SourceAdapter.AddFile(file2.LocalPath);

            int branchChangeset = SourceAdapter.BranchItem(branch);

            // Create a cyclic rename of two files
            SourceWorkspace.PendRename(file1.ServerPath, tempFile.ServerPath);
            SourceWorkspace.PendRename(file2.ServerPath, file1.ServerPath);
            SourceWorkspace.PendRename(tempFile.ServerPath, file2.ServerPath);

            // Create a three-way cyclic rename of the parent folder with two other folders
            SourceWorkspace.PendRename(folder1.ServerPath, temp.ServerPath);
            SourceWorkspace.PendRename(folder2.ServerPath, folder1.ServerPath);
            SourceWorkspace.PendRename(folder3.ServerPath, folder2.ServerPath);
            SourceWorkspace.PendRename(temp.ServerPath, folder3.ServerPath);
            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), RenameComment);

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

            Run();

            if (TestEnvironment.SourceEndPoint.AdapterType == AdapterType.TFS2008VC)
            {
                VerifyHistory(0, 0);
                // For orcas, there should be no difference.
            }
            else
            {
                VerifyHistory(1, 1);
                // Need more comparison here.
                // On dev 10 server, rename becomes sourceDelete+targetbranch. So the rename-from-name will exist in the original place as a deleted item.
                // The merge will then merge the item as a Merge|Delete. We will skip the change in this case.
            }
        }
Exemplo n.º 10
0
        public void RenameCaseAddSubitemTest()
        {
            MigrationItemStrings folder = new MigrationItemStrings("FOLDER", "folder", TestEnvironment, true);
            MigrationItemStrings file   = new MigrationItemStrings("folder/file.txt", null, TestEnvironment, true);

            SourceAdapter.AddFolder(folder.LocalPath);

            SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite);
            SourceWorkspace.PendRename(folder.ServerPath, folder.NewServerPath);
            SourceAdapter.AddFile(file.LocalPath);

            RunAndValidate();
        }
Exemplo n.º 11
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();
        }
Exemplo n.º 12
0
        public void MergeAddSourceRename()
        {
            MigrationItemStrings folder = new MigrationItemStrings(m_source.Name + "folder", m_source.Name + "folder-rename", TestEnvironment, true);

            SourceAdapter.AddFolder(folder.LocalPath);
            int changesetId = SourceWorkspace.PendBranch(m_source.ServerPath, m_target.ServerPath, ChangesetVersionSpec.Latest);

            SourceWorkspace.PendRename(folder.LocalPath, folder.NewLocalPath);

            CheckinMergeResolve(changesetId);

            SourceAdapter.AddFolder(folder.LocalPath.Replace("source", "target") + "\\sub"); // Pend an add on the source rename item

            RunAndValidate();
        }
Exemplo n.º 13
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.LocalPath);
            SourceAdapter.AddFile(file.LocalPath);
            SourceAdapter.DeleteItem(file.LocalPath);

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

            RunAndValidate();
        }
Exemplo n.º 14
0
        protected void BranchPopulatedFolderScenario()
        {
            MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true);
            MigrationItemStrings file1  = new MigrationItemStrings("source/folder/file1.txt", null, TestEnvironment, true);
            MigrationItemStrings file2  = new MigrationItemStrings("source/folder/file2.txt", null, TestEnvironment, true);

            SourceAdapter.AddFolder(branch.LocalPath);
            SourceAdapter.AddFile(file1.LocalPath);
            SourceAdapter.AddFile(file2.LocalPath);
            SourceAdapter.EditFile(file2.LocalPath);

            SourceAdapter.BranchItem(branch.ServerPath, branch.NewServerPath);

            RunAndValidate();
        }
Exemplo n.º 15
0
        public void BranchMergeEditFileOnlyTest()
        {
            MigrationItemStrings folder = new MigrationItemStrings(source.Name + "folder", target.Name + "folder", TestEnvironment, true);

            file = new MigrationItemStrings(source.Name + "folder/file.txt", target.Name + "folder/file.txt", TestEnvironment, true);

            SourceAdapter.AddFolder(folder.LocalPath);
            SourceWorkspace.Merge(folder.ServerPath, folder.NewServerPath, VersionSpec.Latest, VersionSpec.Latest);

            SourceAdapter.AddFile(file.LocalPath);
            SourceWorkspace.Merge(file.ServerPath, file.NewServerPath, VersionSpec.Latest, VersionSpec.Latest);
            int mergeChangeset = SourceAdapter.EditFile(file.NewLocalPath);

            RunAndValidate();
        }
Exemplo n.º 16
0
        protected void RenameOrderScenario(bool useSource)
        {
            MigrationItemStrings parentDirectory = new MigrationItemStrings("Parent", "NewDir", TestEnvironment, useSource);
            MigrationItemStrings subDirectory1   = new MigrationItemStrings("Parent/SubDir1", "SubDir1", TestEnvironment, useSource);
            MigrationItemStrings subDirectory2   = new MigrationItemStrings("Parent/SubDir2", "SubDir2", TestEnvironment, useSource);

            SourceAdapter.AddFolder(parentDirectory.LocalPath);
            SourceAdapter.AddFolder(subDirectory1.LocalPath);
            SourceAdapter.AddFolder(subDirectory2.LocalPath);

            SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite);
            SourceWorkspace.PendRename(subDirectory1.LocalPath, subDirectory1.NewLocalPath);
            SourceWorkspace.PendRename(subDirectory2.LocalPath, subDirectory2.NewLocalPath);
            SourceWorkspace.PendRename(parentDirectory.LocalPath, parentDirectory.NewLocalPath);
            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), RenameComment);
        }
Exemplo n.º 17
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();
        }
Exemplo n.º 18
0
        public void MigrateCloakedFolderItselfTest()
        {
            MigrationItemStrings cloakedFile = new MigrationItemStrings("cloak", "cloak", TestEnvironment, true);

            SourceAdapter.AddFolder(cloakedFile.LocalPath);

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

            TestEnvironment.AddMapping(mapping);

            SourceAdapter.EditFile(m_extraFile.LocalPath);

            Run();
            VerifyHistory(0, 0);
        }
Exemplo n.º 19
0
        protected void BranchParitalScenario()
        {
            MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true);
            MigrationItemStrings file1  = new MigrationItemStrings("source/file1.txt", null, TestEnvironment, true);
            MigrationItemStrings file2  = new MigrationItemStrings("source/file2.txt", null, TestEnvironment, true);

            SourceAdapter.AddFolder(branch.LocalPath);
            SourceAdapter.AddFile(file1.LocalPath);
            int branchFrom = SourceAdapter.AddFile(file2.LocalPath);

            SourceAdapter.EditFile(file2.LocalPath);
            SourceAdapter.EditFile(file1.LocalPath);

            SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite);
            SourceWorkspace.PendBranch(branch.ServerPath, branch.NewServerPath, VersionSpec.ParseSingleSpec(branchFrom.ToString(), Environment.UserName));

            RunAndValidate();
        }
Exemplo n.º 20
0
        public void RenameParentAddSubFolderTest()
        {
            MigrationItemStrings parentFolder = new MigrationItemStrings("parent", "new-parent", TestEnvironment, true);
            MigrationItemStrings file         = new MigrationItemStrings("filea.txt", null, TestEnvironment, true);
            MigrationItemStrings subFolder    = new MigrationItemStrings("new-parent/subdir", null, TestEnvironment, true);

            SourceAdapter.AddFolder(parentFolder.LocalPath);
            SourceAdapter.AddFile(Path.Combine(parentFolder.LocalPath, file.Name));

            SourceWorkspace.PendRename(parentFolder.ServerPath, parentFolder.NewServerPath);
            Directory.CreateDirectory(subFolder.LocalPath);
            SourceWorkspace.PendAdd(subFolder.LocalPath);
            SourceWorkspace.PendRename(Path.Combine(parentFolder.NewServerPath, file.Name), Path.Combine(subFolder.ServerPath, file.Name));

            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), "added a new sub folder. moved an item to the sub folder. rename parent folder");

            RunAndValidate();
        }
Exemplo n.º 21
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();
        }
Exemplo n.º 22
0
        protected void DeleteFolderRenameToSourceScenario(bool useSoruce)
        {
            MigrationItemStrings parent = new MigrationItemStrings("Parent/", "newParent/", TestEnvironment, useSoruce);
            MigrationItemStrings file1  = new MigrationItemStrings("child/def.txt", "Parent/child/def.txt", TestEnvironment, useSoruce);
            MigrationItemStrings file2  = new MigrationItemStrings("Parent/child/def.txt", null, TestEnvironment, useSoruce);
            MigrationItemStrings child  = new MigrationItemStrings("child/", "Parent/child/", TestEnvironment, useSoruce);

            SourceAdapter.AddFolder(parent.LocalPath);


            SourceAdapter.AddFile(file1.LocalPath);
            SourceAdapter.AddFile(file2.LocalPath);

            SourceWorkspace.PendDelete(child.NewServerPath);
            SourceWorkspace.PendRename(child.ServerPath, child.NewServerPath);
            SourceWorkspace.PendRename(parent.ServerPath, parent.NewServerPath);

            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), RenameComment);
        }
Exemplo n.º 23
0
        public void AddMappingRoot()
        {
            MigrationItemStrings folderOnSource = new MigrationItemStrings("folder", "folder", TestEnvironment, true);
            MigrationItemStrings folderOnTarget = new MigrationItemStrings("folder", "folder", TestEnvironment, false);

            SourceAdapter.AddFolder(folderOnSource.LocalPath);
            TargetAdapter.AddFolder(folderOnTarget.LocalPath);

            //Remap the migration
            string source = TestEnvironment.FirstSourceServerPath;
            string target = TestEnvironment.FirstTargetServerPath;

            TestEnvironment.Mappings.Clear();
            TestEnvironment.AddMapping(new MappingPair(
                                           source + SrcPathSeparator + folderOnSource.Name,
                                           target + TarPathSeparator + folderOnTarget.Name, false));

            RunAndValidate();
        }
Exemplo n.º 24
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();
        }
Exemplo n.º 25
0
        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());
        }
Exemplo n.º 26
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();
        }
Exemplo n.º 27
0
        public void MergeBaselessTest()
        {
            MigrationItemStrings source = new MigrationItemStrings("source", null, TestEnvironment, true);
            MigrationItemStrings target = new MigrationItemStrings("target", null, TestEnvironment, true);
            MigrationItemStrings file1  = new MigrationItemStrings("source/File.txt", null, TestEnvironment, true);
            MigrationItemStrings file2  = new MigrationItemStrings("source/File2.txt", null, TestEnvironment, true);

            SourceAdapter.AddFolder(source.LocalPath);
            SourceAdapter.AddFolder(target.LocalPath);
            int changeid = SourceAdapter.AddFile(file1.LocalPath);

            SourceAdapter.AddFile(file2.LocalPath);

            SourceAdapter.EditFile(file2.LocalPath);

            SourceWorkspace.Merge(source.ServerPath, target.ServerPath,
                                  VersionSpec.ParseSingleSpec(changeid.ToString(), Environment.UserName),
                                  VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.Baseless);
            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), MergeComment);

            RunAndValidate();
        }
Exemplo n.º 28
0
        public void RenameParentLongerChildshorterTest()
        {
            MigrationItemStrings folder = new MigrationItemStrings("folder", "folder" + stringOf150Chars, TestEnvironment, true);
            MigrationItemStrings file   = new MigrationItemStrings("folder/file" + stringOf150Chars + ".txt", "folder/file.txt", TestEnvironment, true);

            MigrationItemStrings folder2 = new MigrationItemStrings("folder2" + stringOf150Chars, "folder2", TestEnvironment, true);
            MigrationItemStrings file2   = new MigrationItemStrings("folder2" + stringOf150Chars + "/file.txt", "folder2/file.txt" + stringOf150Chars + ".txt", TestEnvironment, true);


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

            SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite);
            SourceWorkspace.PendRename(file.LocalPath, file.NewLocalPath);
            SourceWorkspace.PendRename(folder.LocalPath, folder.NewLocalPath);
            SourceWorkspace.PendRename(folder2.LocalPath, folder2.NewLocalPath);
            SourceWorkspace.PendRename(file2.LocalPath, file2.NewLocalPath);
            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), "Rename folder longer and file shorter");

            RunAndValidate();
        }
Exemplo n.º 29
0
        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();
        }
Exemplo n.º 30
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);
            }
        }