Пример #1
0
        public void StartsWithMappingsTest()
        {
            MigrationItemStrings fileOutSideMapping = new MigrationItemStrings("source-integration/file.txt", null, TestEnvironment, true);
            MigrationItemStrings fileUnderMapping   = new MigrationItemStrings("source/file.txt", null, TestEnvironment, true);

            TestUtils.CreateRandomFile(fileOutSideMapping.LocalPath, 10);
            TestUtils.CreateRandomFile(fileUnderMapping.LocalPath, 10);

            string mergeComment = "Migration test merge";

            SourceWorkspace.PendAdd(fileOutSideMapping.LocalPath);
            SourceWorkspace.PendAdd(fileUnderMapping.LocalPath);

            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), mergeComment);

            MappingPair mapping = new MappingPair(TestEnvironment.FirstSourceServerPath + SrcPathSeparator + "source",
                                                  TestEnvironment.FirstTargetServerPath + TarPathSeparator + "source",
                                                  false);
            MappingPair mapping2 = new MappingPair(TestEnvironment.FirstSourceServerPath + SrcPathSeparator + "source-integration",
                                                   TestEnvironment.FirstTargetServerPath + TarPathSeparator + "source-integration",
                                                   false);

            TestEnvironment.Mappings.Clear();

            TestEnvironment.AddMapping(mapping);
            TestEnvironment.AddMapping(mapping2);
            RunAndValidate();
        }
Пример #2
0
        public void RenameWithSourceNotMappedTest()
        {
            MigrationItemStrings folder = new MigrationItemStrings("rename-from", "rename-to", TestEnvironment, true);
            MigrationItemStrings file   = new MigrationItemStrings("rename-from/fld/file.txt", "rename-to/fld/file.txt", TestEnvironment, true);

            // Add the child item
            SourceAdapter.AddFile(file.LocalPath);

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

            TestEnvironment.AddMapping(mapping);

            SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite);
            SourceWorkspace.PendRename(folder.ServerPath, folder.NewServerPath);

            SourceAdapter.EditFile(file.NewLocalPath);

            Run();
            VerifyHistory(3, 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);
        }
Пример #3
0
        public void MapBranchRootTest()
        {
            MigrationItemStrings branch = new MigrationItemStrings("source" + SourceAdapter.PathSeparator,
                                                                   "target" + SourceAdapter.PathSeparator,
                                                                   TestEnvironment, true);
            MigrationItemStrings file = new MigrationItemStrings(branch.Name + SourceAdapter.PathSeparator + "file.txt",
                                                                 branch.NewName + SourceAdapter.PathSeparator + "file.txt", TestEnvironment, true);

            SourceAdapter.AddFile(file.LocalPath);

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

            TestEnvironment.Mappings.Clear();
            TestEnvironment.AddMapping(new MappingPair(source + SrcPathSeparator + branch.Name,
                                                       target + TarPathSeparator + branch.Name, false));
            TestEnvironment.AddMapping(new MappingPair(source + SrcPathSeparator + branch.NewName,
                                                       target + TarPathSeparator + branch.NewName, false));
            TestEnvironment.AddMapping(new MappingPair(source + SrcPathSeparator + m_extraFile.Name,
                                                       target + TarPathSeparator + m_extraFile.Name, false));

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

            SourceAdapter.EditFile(file.LocalPath);

            SourceAdapter.MergeItem(branch, branchChangeset);

            SourceAdapter.EditFile(m_extraFile.LocalPath);

            RunAndValidate();
        }
Пример #4
0
        public void TrailingSlashInSourcePathTest()
        {
            MigrationItemStrings file = new MigrationItemStrings("file.txt", "FILE.txt", TestEnvironment, true);

            SourceAdapter.AddFile(file.LocalPath);

            string source = TestEnvironment.FirstSourceServerPath + SrcPathSeparator;
            string target = TestEnvironment.FirstTargetServerPath;

            TestEnvironment.Mappings.Clear();
            TestEnvironment.AddMapping(new MappingPair(source, target));

            RunAndValidate();
        }
Пример #5
0
        public void VCInvalidPathConflict()
        {
            // Make sure that target mapping path > the source mapping path
            string sourceMapping = TestEnvironment.FirstSourceServerPath;
            string targetMapping = TestEnvironment.FirstTargetServerPath;
            int    lengthDiff    = sourceMapping.Length - targetMapping.Length;

            if (lengthDiff >= 0)
            {
                String path = new String('d', lengthDiff + 1);
                TestEnvironment.Mappings.Clear();
                TestEnvironment.AddMapping(new MappingPair(sourceMapping, TestUtils.URIPathCombine(targetMapping, path), false));
            }

            Assert.IsTrue(TestEnvironment.FirstSourceServerPath.Length < TestEnvironment.FirstTargetServerPath.Length,
                          "This test only works if the source mapping is shorter than the target mapping");

            int fileNameLength = 258 - TestEnvironment.FirstSourceServerPath.Length; // 259 - 1 for '/'

            Assert.IsTrue(fileNameLength > 0, "Source mapping is too long");

            StringBuilder fileNameBuilder = new StringBuilder();

            for (int i = 0; i < fileNameLength; i++)
            {
                fileNameBuilder.Append('a');
            }

            string fileName = fileNameBuilder.ToString();

            MigrationItemStrings file = new MigrationItemStrings(fileName, fileName, TestEnvironment, true);
            MigrationItemStrings fileInTargetSystem = new MigrationItemStrings(fileName, fileName, TestEnvironment, false);

            SourceAdapter.AddFile(file.LocalPath);
            try
            {
                Run();
            }
            catch (Exception)
            {
            }

            ConflictResolver  conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts        = conflictResolver.GetConflicts();

            // verify we have edit/edit conflict
            Assert.IsTrue(conflicts.Count == 1, "There should be invalid field value conflict");
            Assert.IsTrue(ConflictConstant.VCInvalidPathConflict.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName), "It should be an invalid path conflict");
        }
Пример #6
0
        public void BasicCloakTest()
        {
            MigrationItemStrings cloakedFile = new MigrationItemStrings("cloak" + SourceAdapter.PathSeparator + "file.txt", null, TestEnvironment, true);

            SourceAdapter.AddFile(cloakedFile.LocalPath);

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

            TestEnvironment.AddMapping(mapping);

            SourceAdapter.EditFile(m_extraFile.LocalPath);
            SourceAdapter.EditFile(cloakedFile.LocalPath);

            RunAndValidate();
        }
Пример #7
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);
        }
Пример #8
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();
        }
Пример #9
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());
        }
Пример #10
0
        public void CloakedTargetMappingsTest()
        {
            MigrationItemStrings file = new MigrationItemStrings("source" + SourceAdapter.PathSeparator + "file.txt",
                                                                 "target" + SourceAdapter.PathSeparator + "file.txt", TestEnvironment, true);

            SourceAdapter.AddFile(file.LocalPath);

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

            TestEnvironment.AddMapping(mapping);

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

            SourceAdapter.EditFile(m_extraFile.LocalPath);
            SourceAdapter.EditFile(file.LocalPath);

            int mergeChangset = SourceAdapter.MergeItem(file, branchChangeset);

            RunAndValidate();
        }
Пример #11
0
        public void DeleteUnmappedTest()
        {
            MigrationItemStrings cloakedFile = new MigrationItemStrings("cloak" + SourceAdapter.PathSeparator + "file.txt", null, TestEnvironment, true);

            SourceAdapter.AddFile(cloakedFile.LocalPath);

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

            TestEnvironment.AddMapping(mapping);

            SourceAdapter.EditFile(cloakedFile.LocalPath);
            SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite);
            TestUtils.EditRandomFile(cloakedFile.LocalPath);
            SourceWorkspace.PendDelete(cloakedFile.LocalPath);

            // Extra file and deleted file will be checked in together.
            SourceAdapter.EditFile(m_extraFile.LocalPath);

            RunAndValidate();
        }
Пример #12
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);
        }
Пример #13
0
        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();
        }
Пример #14
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);
            }
        }
Пример #15
0
        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());
        }
Пример #16
0
        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());
        }