public void Sync_ExceptionInMergeCode_LeftWith2HeadsAndErrorOutputToProgress()
        {
            using (RepositoryWithFilesSetup bob = RepositoryWithFilesSetup.CreateWithLiftFile("bob"))
            {
                using (RepositoryWithFilesSetup sally = RepositoryWithFilesSetup.CreateByCloning("sally", bob))
                {
                    bob.ReplaceSomething("bobWasHere");
                    bob.AddAndCheckIn();
                    sally.ReplaceSomething("sallyWasHere");
                    using (new FailureSimulator("LiftMerger.FindEntryById"))
                    {
                        sally.CheckinAndPullAndMerge(bob);
                    }
                    Assert.That(sally.ProgressString, Does.Contain("InduceChorusFailure"));

                    sally.AssertHeadCount(2);
                    //ok, Bob's the tip, but...
                    Assert.AreEqual("bob", sally.Repository.GetTip().UserId);
                    //make sure we didn't move up to that tip, because we weren't able to merge with it
                    var currentRevision = sally.GetRepository().GetRevisionWorkingSetIsBasedOn();
                    Assert.AreEqual("sally", sally.GetRepository().GetRevision(currentRevision.Number.Hash).UserId);
                    Assert.That(File.ReadAllText(sally.UserFile.Path), Does.Contain("sallyWasHere"));

                    //and over at Bob's house, it's as if Sally had never connected

                    bob.AssertHeadCount(1);
                    Assert.AreEqual("bob", bob.Repository.GetTip().UserId);
                    Assert.That(File.ReadAllText(bob.UserFile.Path), Does.Contain("bobWasHere"));
                }
            }
            File.Delete(Path.Combine(Path.GetTempPath(), "LiftMerger.FindEntryById"));
        }
        public void Sync_BothChangedBinaryFile_FailureReportedOneChosenSingleHead()
        {
            using (RepositoryWithFilesSetup bob = new RepositoryWithFilesSetup("bob", "test.a9a", "original"))
            {
                using (RepositoryWithFilesSetup sally = RepositoryWithFilesSetup.CreateByCloning("sally", bob))
                {
                    bob.ReplaceSomething("bobWasHere");
                    bob.AddAndCheckIn();
                    sally.ReplaceSomething("sallyWasHere");

                    //now we have a merge of a file type that don't know how to merge
                    sally.CheckinAndPullAndMerge(bob);

                    sally.AssertSingleHead();
                    bob.AssertSingleHead();

                    //sally.AssertSingleConflict(c => c.GetType == typeof (UnmergableFileTypeConflict));
                    sally.AssertSingleConflictType <UnmergableFileTypeConflict>();

                    // nb: this is sally because the conflict handling mode is (at the time of this test
                    // writing) set to WeWin.
                    Assert.That(File.ReadAllText(sally.UserFile.Path), Does.Contain("sallyWasHere"));
                }
            }
        }
        public void Sync_WeHaveAFileWhichTheyAlsoEditedButHavenotCheckedIn_TheirsIsRenamedToSafetyAndTheyGetOurs()
        {
            using (RepositoryWithFilesSetup bob = new RepositoryWithFilesSetup("bob", "test.a9a", "original"))
            {
                using (RepositoryWithFilesSetup sally = RepositoryWithFilesSetup.CreateByCloning("sally", bob))
                {
                    File.WriteAllText(bob.ProjectFolder.Combine("problem.txt"), "bob's problem");
                    //notice, we don't alter the include pattern on bob, so this doesn't get checked in
                    // on his side
                    bob.AddAndCheckIn();

                    sally.ReplaceSomething("sallyWasHere");
                    File.WriteAllText(sally.ProjectFolder.Combine("problem.txt"), "sally's problem");
                    sally.ProjectConfiguration.IncludePatterns.Add("problem.txt");

                    sally.CheckinAndPullAndMerge(bob);
                    sally.AssertNoErrorsReported();

                    //ok, so the problem is now lurking in bob's repo, but it doesn't hit him until
                    //he does at least an update

                    bob.CheckinAndPullAndMerge(sally);

                    var rescueFiles = Directory.GetFiles(bob.ProjectFolder.Path, "*.ChorusRescuedFile");
                    Assert.AreEqual(1, rescueFiles.Length);
                    Assert.AreEqual("bob's problem", File.ReadAllText(rescueFiles[0]));
                    sally.AssertFileContents("problem.txt", "sally's problem");
                }
            }
        }
        public void Sync_MergeWhenThereIsMoreThanOneHeadToMergeWith_MergesBoth()
        {
            using (RepositoryWithFilesSetup bob = new RepositoryWithFilesSetup("bob", "test.a9a", "original"))
                using (RepositoryWithFilesSetup sally = RepositoryWithFilesSetup.CreateByCloning("sally", bob))
                {
                    var tip = sally.Repository.GetTip();
                    sally.ReplaceSomething("forbranch1");
                    sally.AddAndCheckIn();
                    sally.Repository.Update(tip.Number.Hash);

                    sally.ReplaceSomething("forbranch1");
                    sally.AddAndCheckIn();
                    sally.Repository.Update(tip.Number.Hash);

                    sally.ReplaceSomething("forbranch2");
                    sally.AddAndCheckIn();
                    sally.Repository.Update(tip.Number.Hash);

                    sally.ReplaceSomething("forbranch3");
                    sally.AddAndCheckIn();
                    sally.Repository.Update(tip.Number.Hash);

                    sally.AssertHeadCount(4);

                    bob.ReplaceSomething("bobWasHere");
                    bob.AddAndCheckIn();
                    sally.ReplaceSomething("sallyWasHere");
                    sally.CheckinAndPullAndMerge(bob);

                    sally.AssertNoErrorsReported();

                    var rescueFiles = Directory.GetFiles(sally.ProjectFolder.Path, "*.ChorusRescuedFile");
                    Assert.AreEqual(0, rescueFiles.Length);

                    sally.AssertHeadCount(1);
                }
        }
 public void Sync_MergeFailure_LeavesNoChorusMergeProcessAlive()
 {
     using (RepositoryWithFilesSetup bob = RepositoryWithFilesSetup.CreateWithLiftFile("bob"))
     {
         using (RepositoryWithFilesSetup sally = RepositoryWithFilesSetup.CreateByCloning("sally", bob))
         {
             bob.ReplaceSomething("bobWasHere");
             bob.AddAndCheckIn();
             sally.ReplaceSomething("sallyWasHere");
             using (new FailureSimulator("LiftMerger.FindEntryById"))
             {
                 sally.CheckinAndPullAndMerge(bob);
             }
             Assert.AreEqual(0, Process.GetProcessesByName("ChorusMerge").Length);
         }
     }
     File.Delete(Path.Combine(Path.GetTempPath(), "LiftMerger.FindEntryById"));
 }
Example #6
0
        public void ConflictFileIsCheckedIn()
        {
            using (RepositoryWithFilesSetup bob = RepositoryWithFilesSetup.CreateWithLiftFile("bob"))
            {
                using (RepositoryWithFilesSetup sally = RepositoryWithFilesSetup.CreateByCloning("sally", bob))
                {
                    bob.ReplaceSomething("bob");
                    bob.AddAndCheckIn();
                    sally.ReplaceSomething("sally");
                    sally.CheckinAndPullAndMerge(bob);

                    string notesFile = ChorusNotesMergeEventListener.GetChorusNotesFilePath(sally.UserFile.Path);
                    Console.WriteLine("notesFile '{0}'", notesFile);
                    Assert.That(notesFile, Does.Exist, "Conflict file should have been in working set");
                    Assert.That(sally.Synchronizer.Repository.GetFileIsInRepositoryFromFullPath(notesFile), Is.True, "Notes file should have been added to repository");
                }
            }
        }
        public void Sync_WeHaveUntrackedFile_NotRenamed()
        {
            using (RepositoryWithFilesSetup bob = new RepositoryWithFilesSetup("bob", "test.a9a", "original"))
            {
                using (RepositoryWithFilesSetup sally = RepositoryWithFilesSetup.CreateByCloning("sally", bob))
                {
                    File.WriteAllText(bob.ProjectFolder.Combine("somethingNew.txt"), "blah");
                    bob.ProjectConfiguration.IncludePatterns.Add("somethingNew.txt");
                    bob.AddAndCheckIn();
                    sally.ReplaceSomething("sallyWasHere");
                    File.WriteAllText(sally.ProjectFolder.Combine("untracked.txt"), "foo");
                    sally.CheckinAndPullAndMerge(bob);

                    sally.AssertNoErrorsReported();

                    var rescueFiles = Directory.GetFiles(sally.ProjectFolder.Path, "*.ChorusRescuedFile");
                    Assert.AreEqual(0, rescueFiles.Length);
                }
            }
        }
        public void Sync_MergeWhenThereIsMoreThanOneHeadToMergeWith_MergesBoth()
        {
            using (RepositoryWithFilesSetup bob = new RepositoryWithFilesSetup("bob", "test.a9a", "original"))
            using (RepositoryWithFilesSetup sally = RepositoryWithFilesSetup.CreateByCloning("sally", bob))
            {
                var tip = sally.Repository.GetTip();
                sally.ReplaceSomething("forbranch1");
                sally.AddAndCheckIn();
                 sally.Repository.Update(tip.Number.Hash);

                sally.ReplaceSomething("forbranch1");
                sally.AddAndCheckIn();
                 sally.Repository.Update(tip.Number.Hash);

                sally.ReplaceSomething("forbranch2");
                sally.AddAndCheckIn();
                sally.Repository.Update(tip.Number.Hash);

                sally.ReplaceSomething("forbranch3");
                sally.AddAndCheckIn();
                sally.Repository.Update(tip.Number.Hash);

                sally.AssertHeadCount(4);

                bob.ReplaceSomething("bobWasHere");
                bob.AddAndCheckIn();
                sally.ReplaceSomething("sallyWasHere");
                sally.CheckinAndPullAndMerge(bob);

                sally.AssertNoErrorsReported();

                var rescueFiles = Directory.GetFiles(sally.ProjectFolder.Path, "*.ChorusRescuedFile");
                Assert.AreEqual(0, rescueFiles.Length);

                sally.AssertHeadCount(1);
            }

        }
        public void Sync_BothChangedBinaryFile_FailureReportedOneChosenSingleHead()
        {
            using (RepositoryWithFilesSetup bob = new RepositoryWithFilesSetup("bob", "test.a9a", "original"))
            {
                using (RepositoryWithFilesSetup sally = RepositoryWithFilesSetup.CreateByCloning("sally", bob))
                {
                    bob.ReplaceSomething("bobWasHere");
                    bob.AddAndCheckIn();
                    sally.ReplaceSomething("sallyWasHere");

                    //now we have a merge of a file type that don't know how to merge
                    sally.CheckinAndPullAndMerge(bob);

                    sally.AssertSingleHead();
                    bob.AssertSingleHead();

                    //sally.AssertSingleConflict(c => c.GetType == typeof (UnmergableFileTypeConflict));
                    sally.AssertSingleConflictType<UnmergableFileTypeConflict>();

                    // nb: this is sally because the conflict handling mode is (at the time of this test
                    // writing) set to WeWin.
					Assert.IsTrue(File.ReadAllText(sally.UserFile.Path).Contains("sallyWasHere"));
                }

            }
        }