Esempio n. 1
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();
        }
Esempio n. 2
0
        public void RenameEditUndeleteMergeTest()
        {
            int changesetId = AddBranch();

            MergeDeletePendUndelete(m_file, changesetId);
            SourceWorkspace.PendRename(m_file.ServerPath, m_file.NewServerPath);
            SourceAdapter.EditFile(m_file.NewLocalPath);

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

            resolveConflictAcceptThiers();

            if (TestEnvironment.SourceEndPoint.IsTfsAdapter &&
                TestEnvironment.SourceEndPoint.AdapterType >= AdapterType.TFS2010VC)
            {
                Run();
                Assert.IsTrue(VerifyContents());
            }
            else
            {
                RunAndValidate();
            }
        }
Esempio n. 3
0
        public void RenameUndeleteMergeTest()
        {
            int changesetId = AddBranch();

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

            CheckinMergeResolve(changesetId);

            if (TestEnvironment.SourceTFSVersion == TFSVersionEnum.TFS2010)
            {
                Run();

                // 1 extra merge item on source side is expected in dev10
                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, sourceChangeset.Changes[0].ChangeType);
                //Assert.AreEqual(0, targetChangeset.Changes.Length);

                // verify content matches
                Assert.IsTrue(VerifyContents());
            }
            else
            {
                RunAndValidate();
            }
        }
Esempio n. 4
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();
        }
Esempio n. 5
0
        public void BranchMergeTest()
        {
            file = new MigrationItemStrings(source.Name + "file.txt", target.Name + "file.txt", TestEnvironment, true);

            SourceAdapter.AddFile(file.LocalPath);

            SourceWorkspace.Merge(file.ServerPath, file.NewServerPath, VersionSpec.Latest, VersionSpec.Latest);

            RunAndValidate();
        }
Esempio n. 6
0
        private void CheckinMergeResolve(int changesetId)
        {
            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), MultiActionComment);

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

            resolveConflictAcceptThiers();
        }
Esempio n. 7
0
        /// <summary>
        /// Perform a merge specifying the start and end changeset
        /// </summary>
        /// <param name="branch">The source server pah is the server namd the target path is the NewServerPath</param>
        /// <param name="mergeFrom">changeset to start merge from</param>
        /// <param name="mergeTo">changeset to merge up to</param>
        private void MergeTfsItem(MigrationItemStrings branch, int mergeFrom, int mergeTo)
        {
            string mergeComment = "Migration test merge";

            SourceWorkspace.Merge(branch.ServerPath, branch.NewServerPath,
                                  VersionSpec.ParseSingleSpec(mergeFrom.ToString(), Environment.UserName),
                                  VersionSpec.ParseSingleSpec(mergeTo.ToString(), Environment.UserName), LockLevel.None, RecursionType.Full, MergeOptions.None);

            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), mergeComment);
        }
Esempio n. 8
0
        public void BranchMergeDeleteTest()
        {
            file = new MigrationItemStrings(source.Name + "file.txt", target.Name + "file.txt", TestEnvironment, true);

            SourceAdapter.AddFile(file.LocalPath);

            SourceWorkspace.Merge(source.ServerPath, target.ServerPath, VersionSpec.Latest, VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptions.None);
            int mergeChangeset = SourceAdapter.DeleteItem(file.NewLocalPath);

            RunAndValidate();
        }
Esempio 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.
            }
        }
Esempio n. 10
0
        public void MergeDeleteTest()
        {
            int changesetId = AddBranch();

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

            RunAndValidate();
        }
Esempio n. 11
0
        private void PendMergeUndelete(MigrationItemStrings item, int changesetId)
        {
            MergeDeletePendUndelete(item, changesetId);

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

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

            resolveConflictAcceptThiers();
        }
Esempio n. 12
0
        public void MergeEditTest()
        {
            int changesetId = AddBranch();

            SourceAdapter.EditFile(m_file.LocalPath);

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

            RunAndValidate();
        }
Esempio n. 13
0
        private void MergeDeletePendUndelete(MigrationItemStrings item, int changesetId)
        {
            int deletionId = SourceTfsClient.GetChangeset(SourceAdapter.DeleteItem(item.ServerPath)).Changes[0].Item.DeletionId;

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

            // Check in only the merge|delete; so that the undelete may be merged over
            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), MergeComment);

            // pend undelete
            SourceWorkspace.PendUndelete(item.ServerPath, deletionId);
        }
Esempio n. 14
0
        public void MergeEditUndeleteTest()
        {
            int changesetId = AddBranch();

            MergeDeletePendUndelete(file, changesetId);
            SourceAdapter.EditFile(file.LocalPath);

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

            resolveConflictAcceptThiers();

            RunAndValidate();
        }
Esempio 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();
        }
Esempio n. 16
0
        public void ReverseMergeTest()
        {
            MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true);
            MigrationItemStrings file   = new MigrationItemStrings("source/file.txt", "target/file.txt", TestEnvironment, true);

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

            SourceAdapter.EditFile(file.NewLocalPath);

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

            RunAndValidate();
        }
Esempio n. 17
0
        public void BranchMergeEditTest()
        {
            file = new MigrationItemStrings(source.Name + "file.txt", target.Name + "file.txt", TestEnvironment, true);

            SourceAdapter.AddFile(file.LocalPath);

            SourceWorkspace.Merge(file.ServerPath, file.NewServerPath, VersionSpec.Latest, VersionSpec.Latest);

            int mergeChangeset = SourceAdapter.EditFile(file.NewLocalPath);

            RunAndValidate();

            /* TfsServerDiff diff = RunNoValidate();
             * Assert.AreEqual(1, diff.SourceChanges.Count, "The source system should have 1 unmatched change");
             * Assert.AreEqual(1, diff.TargetChanges.Count, "The target system should have 1 unmatched change");
             * Assert.AreEqual(diff.TargetChanges[0].Changes[1].ChangeType, ChangeType.Encoding | ChangeType.Branch | ChangeType.Edit | ChangeType.Merge, "Wrong change type");
             * Assert.AreEqual(mergeChangeset, diff.SourceChanges[0].ChangesetId, "Wrong changeset");
             */
        }
Esempio n. 18
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();
        }
Esempio n. 19
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());
        }
Esempio n. 20
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();
        }
Esempio n. 21
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);
        }
Esempio n. 22
0
        public void MergeDeleteUndeleteTest()
        {
            MigrationItemStrings folder = new MigrationItemStrings(source.Name + "folder/", null, TestEnvironment, true);

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

            SourceAdapter.AddFile(file.LocalPath);

            int changesetId = SourceAdapter.BranchItem(source.ServerPath, target.ServerPath);

            MergeDeletePendUndelete(folder, changesetId);

            SourceWorkspace.PendDelete(file.ServerPath);
            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), MultiActionComment);

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

            resolveConflictAcceptThiers();

            RunAndValidate();
        }
Esempio n. 23
0
        /// <summary>
        /// Checkin a merge conflict resolved with the specified resolution then verify its migration
        /// </summary>
        /// <param name="resolution">The resolution to test</param>
        private void ResolutionScenario(Resolution resolution)
        {
            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", "target/File2.txt", TestEnvironment, true);

            int changeid = SourceAdapter.AddFile(file1.LocalPath);

            SourceAdapter.AddFile(file2.LocalPath);

            SourceAdapter.BranchItem(source.ServerPath, target.ServerPath);

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

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

            RunAndValidate();
        }
Esempio n. 24
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());
        }
Esempio n. 25
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);
            }
        }
Esempio n. 26
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());
        }