public void Sync_HgrcInUseByOther_FailsGracefully() { HgRunner.TimeoutSecondsOverrideForUnitTests = 1; using (var setup = new RepositorySetup("bob")) { using (new StreamWriter(setup.ProjectFolder.Combine(".hg", "hgrc"))) { var results = setup.CheckinAndPullAndMerge(); Assert.IsFalse(results.Succeeded); } } }
public void SynchNow_OnDefaultBranchAndAnotherBranchExists_DoesNotMergeWithIt() { using (var repo = new RepositorySetup("bob")) { repo.AddAndCheckinFile("test.txt", "hello"); repo.AssertHeadCount(1); repo.ChangeFileOnNamedBranchAndComeBack("test.txt", "blah", "mybranch"); //NB: this used to pass prior to hg 1.5, but, well, it shouldn't! // Shouldn't there be two heads after the branch, above? (jh, April 2010) // repo.AssertHeadCount(1); repo.ChangeFileAndCommit("test.txt", "hello there", "second"); repo.AssertHeadCount(2); repo.CheckinAndPullAndMerge(); repo.AssertHeadCount(2); } }
public void ChangedUtf8File_FileCanBePulledAndUpdated() { using (var setup = new RepositorySetup("Dan")) { const string utf8FilePath = "açesbsun.wav"; setup.ChangeFile(utf8FilePath, "hello1"); setup.ProjectFolderConfig.IncludePatterns.Add("*.wav"); setup.AddAndCheckIn(); using (var other = new RepositorySetup("Bob", setup)) { setup.ChangeFile(utf8FilePath, "hello2"); setup.Repository.Commit(false, "update"); other.CheckinAndPullAndMerge(setup); // Fix: Currently this modifies Dan adding bogus file unexpectedly. other.AssertFileExists(utf8FilePath); string[] fileNames = Directory.GetFiles(other.ProjectFolder.Path, "*.wav"); Assert.AreEqual(1, fileNames.Length); } } }
public void SynchNow_OnNamedBranchAndDefaultBranchExists_DoesNotMergeWithIt() { using (var repo = new RepositorySetup("bob")) { if (repo.Synchronizer == null) repo.Synchronizer = repo.CreateSynchronizer(); repo.Synchronizer.SynchronizerAdjunct = new ProgrammableSynchronizerAdjunct("default"); repo.AddAndCheckinFile("test.txt", "apple"); var afterFirstCheckin = repo.CreateBookmarkHere(); repo.ChangeFileAndCommit("test.txt", "pear", "second on default"); afterFirstCheckin.Go(); repo.Repository.BranchingHelper.Branch(new ConsoleProgress(), "animals"); repo.Synchronizer.SynchronizerAdjunct = new ProgrammableSynchronizerAdjunct("animals"); repo.ChangeFileAndCommit("test.txt", "dog", "first on animals"); var animalHead = repo.CreateBookmarkHere(); repo.AssertHeadCount(2); repo.CheckinAndPullAndMerge(); repo.AssertHeadCount(2); animalHead.AssertRepoIsAtThisPoint(); } }
public void FileDeletedRemotelyAndChangedLocallyKeepsChanged() { using(var localRepo = new RepositorySetup("unbundleTests")) { var localFilePath = localRepo.ProjectFolder.GetNewTempFile(true).Path; localRepo.AddAndCheckinFile(localFilePath, "file to change and delete"); using(var remoteRepo = new RepositorySetup("remote", localRepo)) { remoteRepo.CheckinAndPullAndMerge(); var remoteFilePath = Path.Combine(remoteRepo.ProjectFolder.Path, Path.GetFileName(localFilePath)); remoteRepo.ChangeFileAndCommit(remoteFilePath, "new contents", "changed file"); File.Delete(localFilePath); localRepo.SyncWithOptions(new SyncOptions { CheckinDescription = "delete file", DoMergeWithOthers = false, DoPullFromOthers = false, DoSendToOthers = false }); localRepo.CheckinAndPullAndMerge(remoteRepo); Assert.That(File.Exists(localFilePath), Is.True, "Did not keep changed file."); var chorusNotesPath = localFilePath + ".ChorusNotes"; Assert.That(File.Exists(chorusNotesPath), "Did not record conflict"); AssertThatXmlIn.File(chorusNotesPath).HasAtLeastOneMatchForXpath("//annotation[@class='mergeconflict']"); } } }
public void Sync_ModifiedFileIsInvalid_CheckedInButThenBackedOut() { /* @ changeset: 2 | summary: [Backout due to validation Failure] | o changeset: 1 | summary: missing checkin description | o changeset: 0 summary: Add test.chorusTest */ using (var bob = new RepositorySetup("bob")) { bob.AddAndCheckinFile("test.chorusTest", "original"); bob.AssertLocalRevisionNumber(0); bob.ChangeFile("test.chorusTest", ChorusTestFileHandler.GetInvalidContents()); bob.CheckinAndPullAndMerge(); bob.AssertLocalRevisionNumber(2); bob.AssertHeadCount(1); bob.AssertLocalRevisionNumber(int.Parse(bob.Repository.GetTip().Number.LocalRevisionNumber)); Debug.WriteLine(bob.Repository.GetLog(-1)); } }
public void Sync_ExistingRejectChangeSet_NotMergedIn() { using (var bob = new RepositorySetup("bob")) { bob.AddAndCheckinFile("test.txt", "original"); bob.CreateRejectForkAndComeBack(); bob.ChangeFileAndCommit("test.txt", "ok", "goodGuy"); //move on so we have two distinct branches bob.AssertHeadCount(2); bob.CheckinAndPullAndMerge(null); Assert.AreEqual("goodGuy", bob.Repository.GetRevisionWorkingSetIsBasedOn().Summary); bob.AssertLocalRevisionNumber(3); bob.AssertHeadCount(2); } }
public void Sync_FileLockedForReadingDuringMerge_LeftWithMultipleHeads() { HgRunner.TimeoutSecondsOverrideForUnitTests = 1; using (var bob = new RepositorySetup("bob")) { bob.ProjectFolderConfig.IncludePatterns.Add("*.txt"); bob.AddAndCheckinFile("one.txt", "hello"); using (var sally = new RepositorySetup("sally", bob)) { bob.AddAndCheckinFile("one.txt", "hello-bob"); using (sally.GetFileLockForReading("one.txt")) { sally.CheckinAndPullAndMerge(bob); } sally.AssertHeadCount(2); } } }
[Ignore] // I (CP) can't get MONO to get an exclusive lock for write. See RepositorySetup::GetFileLockForWriting #endif public void Sync_FileLockedForWritingDuringUpdate_GetUpdatedFileOnceLockIsGone() { HgRunner.TimeoutSecondsOverrideForUnitTests = 1; using (var bob = new RepositorySetup("bob")) { bob.ProjectFolderConfig.IncludePatterns.Add("*.txt"); bob.AddAndCheckinFile("one.txt", "hello"); using (var sally = new RepositorySetup("sally", bob)) { bob.AddAndCheckinFile("one.txt", "hello-bob"); using (sally.GetFileLockForWriting("one.txt")) { // Note: Mono succeeds here Assert.IsFalse(sally.CheckinAndPullAndMerge(bob).Succeeded, "CheckinAndPullAndMerge should have failed"); sally.AssertFileContents("one.txt", "hello"); } sally.AssertSingleHead(); //ok, now whatever was holding that file is done with it, and we try again Assert.IsTrue(sally.CheckinAndPullAndMerge(bob).Succeeded, "ChecinAndPullAndMerge(bob) should have succeeded"); sally.AssertFileContents("one.txt", "hello-bob"); } } }
public void Sync_FirstCheckInButNoFilesAdded_NoProblem() { using (var bob = new RepositorySetup("bob")) { var result = bob.CheckinAndPullAndMerge(); Assert.IsTrue(result.Succeeded, result.ErrorEncountered==null?"":result.ErrorEncountered.Message); } }
public void Sync_MergeFailure_NoneOfTheOtherGuysFilesMakeItIntoWorkingDirectory() { using (var bob = new RepositorySetup("bob")) { bob.ProjectFolderConfig.IncludePatterns.Add("*.txt"); bob.AddAndCheckinFile("aaa.txt", "apple"); bob.AddAndCheckinFile("bbb.txt", "bread"); bob.AddAndCheckinFile("zzz.txt", "zoo"); using (var sally = new RepositorySetup("sally", bob)) { bob.AddAndCheckinFile("aaa.txt", "bob-apple"); bob.AddAndCheckinFile("bbb.txt", "bob-bread"); bob.AddAndCheckinFile("zzz.txt", "bob-zoo"); using (new FailureSimulator("TextMerger-bbb.txt")) { sally.AddAndCheckinFile("aaa.txt", "sally-apple"); sally.AddAndCheckinFile("bbb.txt", "sally-bread"); sally.AddAndCheckinFile("zzz.txt", "sally-zipper"); Assert.IsFalse(sally.CheckinAndPullAndMerge(bob).Succeeded); //make sure we ended up on Sally's revision, even though Bob's are newer var currentRevision = sally.Repository.GetRevisionWorkingSetIsBasedOn(); Assert.AreEqual("sally", sally.Repository.GetRevision(currentRevision.Number.Hash).UserId); //sally should see no changes, because it should all be rolled back sally.AssertFileContents("aaa.txt", "sally-apple"); sally.AssertFileContents("bbb.txt", "sally-bread"); sally.AssertFileContents("zzz.txt", "sally-zipper"); // sally.ShowInTortoise(); sally.AssertHeadCount(2); Assert.IsFalse(sally.GetProgressString().Contains("creates new remote heads")); } } } File.Delete(Path.Combine(Path.GetTempPath(), "TextMerger-bbb.txt")); }