Exemplo n.º 1
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.º 2
0
        protected void UndeleteSourceRenameScenario(bool useSource)
        {
            MigrationItemStrings deletedFile = new MigrationItemStrings("file.txt", null, TestEnvironment, useSource);
            MigrationItemStrings renamedFile = new MigrationItemStrings("file.txt", "renamedFile.txt", TestEnvironment, useSource);

            SourceAdapter.AddFile(deletedFile.LocalPath);
            int deletionChangeSet = SourceAdapter.DeleteItem(deletedFile.ServerPath);

            SourceAdapter.AddFile(renamedFile.LocalPath);

            SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite);
            SourceWorkspace.PendRename(renamedFile.LocalPath, renamedFile.NewLocalPath);
            SourceAdapter.UndeleteFile(deletedFile.ServerPath, deletionChangeSet);
        }
Exemplo n.º 3
0
        public void MergeCrudOutOfScopeTest()
        {
            MigrationItemStrings branch       = new MigrationItemStrings("source/", "target/", TestEnvironment, true);
            MigrationItemStrings addedFile    = new MigrationItemStrings("source/Addedfile.txt", null, TestEnvironment, true);
            MigrationItemStrings editFile     = new MigrationItemStrings("source/Editedfile.txt", null, TestEnvironment, true);
            MigrationItemStrings deleteFile   = new MigrationItemStrings("source/DeletedFile.txt", null, TestEnvironment, true);
            MigrationItemStrings undeleteFile = new MigrationItemStrings("source/UndeletedFile.txt", null, TestEnvironment, true);
            MigrationItemStrings branchedFile = new MigrationItemStrings("source/folder/branchedFile.txt", "source/folder2/branchFile.txt", TestEnvironment, true);
            MigrationItemStrings mergeFile    = new MigrationItemStrings("source/folder/mergeFile.txt", "source/folder2/mergeFile.txt", TestEnvironment, true);

            #region Setup before the branch
            //All the files except for the Added file should exist before the branch
            SourceAdapter.AddFile(editFile.LocalPath);
            SourceAdapter.AddFile(deleteFile.LocalPath);
            SourceAdapter.AddFile(undeleteFile.LocalPath);
            SourceAdapter.AddFile(branchedFile.LocalPath);
            SourceAdapter.AddFile(mergeFile.LocalPath);

            int deletetionChangeset = SourceAdapter.DeleteItem(undeleteFile.ServerPath);
            int mergeFileChangeset  = SourceAdapter.BranchItem(mergeFile.ServerPath, mergeFile.NewServerPath);
            SourceAdapter.EditFile(mergeFile.LocalPath);
            #endregion

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

            #region Setup after Branch operation
            SourceAdapter.AddFile(addedFile.LocalPath);
            SourceAdapter.EditFile(editFile.LocalPath);
            SourceAdapter.DeleteItem(deleteFile.ServerPath);
            SourceAdapter.UndeleteFile(undeleteFile.ServerPath, deletetionChangeset);
            SourceAdapter.BranchItem(branchedFile.ServerPath, branchedFile.NewServerPath);
            SourceAdapter.MergeItem(mergeFile, mergeFileChangeset);
            #endregion Setup after Branch operation

            //The big merge
            SourceAdapter.MergeItem(branch, branchChangeset);

            // Add the mapping scope
            MappingPair rootMapping = TestEnvironment.Mappings[0];
            TestEnvironment.Mappings.Clear();
            TestEnvironment.Mappings.Add(new MappingPair(rootMapping.SourcePath, rootMapping.TargetPath, false, null, null,
                                                         rootMapping.SourcePath + '/' + "target/", rootMapping.TargetPath + '/' + "target/"));

            RunAndValidate(true, true);
        }
Exemplo n.º 4
0
        protected void TwoDeleteUnDeleteScenario(bool useSource)
        {
            MigrationItemStrings file1 = new MigrationItemStrings("file.txt", null, TestEnvironment, useSource);
            MigrationItemStrings file2 = new MigrationItemStrings("file.txt", null, TestEnvironment, useSource);

            SourceAdapter.AddFile(file1.LocalPath);

            int file1ChangeSetId = SourceAdapter.DeleteItem(file1.ServerPath);

            SourceAdapter.AddFile(file2.LocalPath);

            int file2ChangeSetId = SourceAdapter.DeleteItem(file2.ServerPath);

            SourceAdapter.UndeleteFile(file1.ServerPath, file1ChangeSetId);

            SourceAdapter.DeleteItem(file1.ServerPath);

            SourceAdapter.UndeleteFile(file2.ServerPath, file2ChangeSetId);
        }
Exemplo n.º 5
0
        public void MergeCrudTest()
        {
            MigrationItemStrings branch       = new MigrationItemStrings("source/", "target/", TestEnvironment, true);
            MigrationItemStrings addedFile    = new MigrationItemStrings("source/Addedfile.txt", null, TestEnvironment, true);
            MigrationItemStrings editFile     = new MigrationItemStrings("source/Editedfile.txt", null, TestEnvironment, true);
            MigrationItemStrings deleteFile   = new MigrationItemStrings("source/DeletedFile.txt", null, TestEnvironment, true);
            MigrationItemStrings undeleteFile = new MigrationItemStrings("source/UndeletedFile.txt", null, TestEnvironment, true);
            MigrationItemStrings branchedFile = new MigrationItemStrings("source/folder/branchedFile.txt", "source/folder2/branchFile.txt", TestEnvironment, true);
            MigrationItemStrings mergeFile    = new MigrationItemStrings("source/folder/mergeFile.txt", "source/folder2/mergeFile.txt", TestEnvironment, true);

            #region Setup before the branch
            //All the files except for the Added file should exist before the branch
            SourceAdapter.AddFile(editFile.LocalPath);
            SourceAdapter.AddFile(deleteFile.LocalPath);
            SourceAdapter.AddFile(undeleteFile.LocalPath);
            SourceAdapter.AddFile(branchedFile.LocalPath);
            SourceAdapter.AddFile(mergeFile.LocalPath);

            int deletetionChangeset = SourceAdapter.DeleteItem(undeleteFile.ServerPath);
            int mergeFileChangeset  = SourceAdapter.BranchItem(mergeFile.ServerPath, mergeFile.NewServerPath);
            SourceAdapter.EditFile(mergeFile.LocalPath);
            #endregion

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

            #region Setup after Branch operation
            SourceAdapter.AddFile(addedFile.LocalPath);
            SourceAdapter.EditFile(editFile.LocalPath);
            SourceAdapter.DeleteItem(deleteFile.ServerPath);
            SourceAdapter.UndeleteFile(undeleteFile.ServerPath, deletetionChangeset);
            SourceAdapter.BranchItem(branchedFile.ServerPath, branchedFile.NewServerPath);
            SourceAdapter.MergeItem(mergeFile, mergeFileChangeset);
            #endregion Setup after Branch operation

            //The big merge
            SourceAdapter.MergeItem(branch, branchChangeset);

            RunAndValidate();
        }
Exemplo n.º 6
0
        public void SnapshotCRUDTest()
        {
            MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true);

            MigrationItemStrings[] files = new MigrationItemStrings[10];

            // Add files
            for (int i = 0; i < 10; i++)
            {
                files[i] = new MigrationItemStrings(string.Format("source/file{0}.txt", i), string.Format("source/file-rename{0}.txt", i), TestEnvironment, true);
                SourceAdapter.AddFile(files[i].LocalPath);
            }

            SourceAdapter.EditFile(files[2].LocalPath);

            SourceAdapter.RenameItem(files[3].ServerPath, files[3].NewServerPath, "Rename before snapshot");

            int deleteChangesetID = SourceAdapter.DeleteItem(files[4].ServerPath);

            SourceAdapter.DeleteItem(files[5].ServerPath);

            SourceAdapter.UndeleteFile(files[4].ServerPath, deleteChangesetID);

            int snapshotChangesetId = SourceAdapter.RenameItem(files[6].ServerPath, files[6].NewServerPath, "Rename before snapshot");

            SourceAdapter.EditFile(files[6].NewLocalPath);
            SourceAdapter.DeleteItem(files[4].ServerPath);
            SourceAdapter.RenameItem(files[3].NewServerPath, files[3].ServerPath, "Rename after snapshot");


            TestEnvironment.SnapshotStartPoints = new Dictionary <string, string>();
            TestEnvironment.SnapshotStartPoints.Add(TestEnvironment.SourceTeamProject, snapshotChangesetId.ToString());
            TestEnvironment.SnapshotBatchSize = 3;

            Run();
            VerifySnapshotMigration(snapshotChangesetId);
            Assert.IsTrue(VerifyContents());
        }
Exemplo n.º 7
0
        public void PathSnapshotBranchTest()
        {
            MigrationItemStrings branch  = new MigrationItemStrings("source/", "target/", TestEnvironment, true);
            MigrationItemStrings branch2 = new MigrationItemStrings("source/", "target2/", TestEnvironment, true);

            MigrationItemStrings[] addFiles = new MigrationItemStrings[10];

            // Add files
            // Create a tree structure so that we can test path compression logic.
            int sessionSnapshotChangesetId = 1;

            for (int i = 0; i < 10; i++)
            {
                addFiles[i] = new MigrationItemStrings(
                    string.Format("source/addFile{0}.txt", i),
                    string.Format("source/addFile{0}-rename.txt", i),
                    TestEnvironment,
                    true);

                SourceAdapter.AddFile(addFiles[i].LocalPath);
            }

            int editBeforeSnapshotChangesetId  = SourceAdapter.EditFile(addFiles[2].LocalPath);
            int editBeforeSnapshotChangesetId2 = SourceAdapter.EditFile(addFiles[2].LocalPath);


            SourceAdapter.RenameItem(addFiles[3].ServerPath, addFiles[3].NewServerPath, "Rename before snapshot");

            int deleteChangesetID = SourceAdapter.DeleteItem(addFiles[4].ServerPath);

            SourceAdapter.DeleteItem(addFiles[5].ServerPath);

            SourceAdapter.UndeleteFile(addFiles[4].ServerPath, deleteChangesetID);

            int path2SnapshotChangesetId = SourceAdapter.RenameItem(addFiles[6].ServerPath, addFiles[6].NewServerPath, "Rename before snapshot");

            int editAfterSnapshotChangesetId  = SourceAdapter.EditFile(addFiles[6].NewLocalPath);
            int editAfterSnapshotChangesetId2 = SourceAdapter.EditFile(addFiles[6].NewLocalPath);

            SourceAdapter.DeleteItem(addFiles[4].ServerPath);
            SourceAdapter.RenameItem(addFiles[3].NewServerPath, addFiles[3].ServerPath, "Rename after snapshot");

            // Branch from a version before the snapshot
            SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite);
            SourceWorkspace.PendBranch(branch.ServerPath, branch.NewServerPath, new ChangesetVersionSpec(editBeforeSnapshotChangesetId));
            SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), "Branch from a version before snapshot");

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



            TestEnvironment.SnapshotStartPoints = new Dictionary <string, string>();
            TestEnvironment.SnapshotStartPoints.Add(TestEnvironment.SourceTeamProject, sessionSnapshotChangesetId.ToString());
            TestEnvironment.SnapshotBatchSize = 3;

            // We need to map to the sub item level
            MappingPair rootMapping = TestEnvironment.Mappings[0];

            TestEnvironment.Mappings.Clear();
            TestEnvironment.Mappings.Add(new MappingPair(rootMapping.SourcePath + "/target", rootMapping.TargetPath + "/target", false));
            TestEnvironment.Mappings.Add(new MappingPair(rootMapping.SourcePath + "/target2", rootMapping.TargetPath + "/target2", false));
            TestEnvironment.Mappings.Add(new MappingPair(rootMapping.SourcePath + "/source", rootMapping.TargetPath + "/source", false, path2SnapshotChangesetId.ToString(), null));

            Run();

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

            Assert.AreEqual(1, conflicts.Count, "There should be only 1 conflict");
            conflictManager.TryResolveConflict(conflicts[0], ConflictConstant.TFSHistoryNotFoundSkipAction, "1-" + path2SnapshotChangesetId);
            Run(true, true);

            // ToDo, ideally, we should compare content at snapshot changeset and compare history after snapshot changeset.
            Assert.IsTrue(VerifyContents());
        }
Exemplo n.º 8
0
        public void PathSnapshotCRUDTest()
        {
            MigrationItemStrings branch = new MigrationItemStrings("source/", "target/", TestEnvironment, true);

            MigrationItemStrings[] path1AddFiles = new MigrationItemStrings[10];
            MigrationItemStrings[] path2AddFiles = new MigrationItemStrings[10];

            // Add files
            // Create a tree structure so that we can test path compression logic.
            int sessionSnapshotChangesetId = 0;

            for (int i = 0; i < 10; i++)
            {
                path1AddFiles[i] = new MigrationItemStrings(string.Format("source/path1/addFile{0}.txt", i), null, TestEnvironment, true);
                if (i == 7)
                {
                    sessionSnapshotChangesetId = SourceAdapter.AddFile(path1AddFiles[i].LocalPath);
                }
                else
                {
                    SourceAdapter.AddFile(path1AddFiles[i].LocalPath);
                }
            }

            for (int i = 0; i < 10; i++)
            {
                path2AddFiles[i] = new MigrationItemStrings(string.Format("source/path2/file{0}.txt", i), string.Format("source/path2/file-rename{0}.txt", i), TestEnvironment, true);
                SourceAdapter.AddFile(path2AddFiles[i].LocalPath);
            }

            SourceAdapter.EditFile(path2AddFiles[2].LocalPath);

            SourceAdapter.RenameItem(path2AddFiles[3].ServerPath, path2AddFiles[3].NewServerPath, "Rename before snapshot");

            int deleteChangesetID = SourceAdapter.DeleteItem(path2AddFiles[4].ServerPath);

            SourceAdapter.DeleteItem(path2AddFiles[5].ServerPath);

            SourceAdapter.UndeleteFile(path2AddFiles[4].ServerPath, deleteChangesetID);

            int path2SnapshotChangesetId = SourceAdapter.RenameItem(path2AddFiles[6].ServerPath, path2AddFiles[6].NewServerPath, "Rename before snapshot");

            SourceAdapter.EditFile(path2AddFiles[6].NewLocalPath);
            SourceAdapter.DeleteItem(path2AddFiles[4].ServerPath);
            SourceAdapter.RenameItem(path2AddFiles[3].NewServerPath, path2AddFiles[3].ServerPath, "Rename after snapshot");


            TestEnvironment.SnapshotStartPoints = new Dictionary <string, string>();
            TestEnvironment.SnapshotStartPoints.Add(TestEnvironment.SourceTeamProject, sessionSnapshotChangesetId.ToString());
            TestEnvironment.SnapshotBatchSize = 3;

            // We need to map to the sub item level
            MappingPair rootMapping = TestEnvironment.Mappings[0];

            TestEnvironment.Mappings.Clear();
            TestEnvironment.Mappings.Add(new MappingPair(rootMapping.SourcePath + "/source/path1", rootMapping.TargetPath + "/source/path1", false));
            TestEnvironment.Mappings.Add(new MappingPair(rootMapping.SourcePath + "/source/path2", rootMapping.TargetPath + "/source/path2", false, path2SnapshotChangesetId.ToString(), null));

            Run();

            // ToDo, ideally, we should compare content at snapshot changeset and compare history after snapshot changeset.
            Assert.IsTrue(VerifyContents());
        }