public HgTestSetup() { _progress = new ConsoleProgress(); Root = new TemporaryFolder("ChorusHgWrappingTest"); HgRepository.CreateRepositoryInExistingDir(Root.Path,_progress); Repository = new HgRepository(Root.Path, new NullProgress()); }
public void ErrorsEncountered_ErrorOriginatesWithOneHandler_MultiProgressHasErrorsEncountered() { var multiProgress = new MultiProgress(); var statusProgress = new StatusProgress(); multiProgress.Add(statusProgress); var consoleProgress = new ConsoleProgress(); multiProgress.AddMessageProgress(consoleProgress); statusProgress.WriteError("some error happened!"); Assert.That(multiProgress.ErrorEncountered, Is.True); }
public void ErrorsEncountered_ErrorOriginatesWithMultiProgress_BothHandlersHaveErrorsEncountered() { var multiProgress = new MultiProgress(); var statusProgress = new StatusProgress(); multiProgress.Add(statusProgress); var consoleProgress = new ConsoleProgress(); multiProgress.AddMessageProgress(consoleProgress); multiProgress.WriteError("error!"); Assert.That(consoleProgress.ErrorEncountered, Is.True); Assert.That(statusProgress.ErrorEncountered, Is.True); }
public void Setup() { _progress = new ConsoleProgress(); _testRoot = new TemporaryFolder("ChorusRetrieveTest"); _tempFile = new TempFileFromFolder(_testRoot); File.WriteAllText(_tempFile.Path,"one"); HgRepository.CreateRepositoryInExistingDir(_testRoot.Path,_progress); _repo = new HgRepository(_testRoot.Path, new NullProgress()); _repo.AddAndCheckinFile(_tempFile.Path); _repo.Commit(true, "initial"); File.WriteAllText(_tempFile.Path, "two"); _repo.AddAndCheckinFile(_tempFile.Path); _repo.Commit(true, "changed to two"); _changesets = _repo.GetAllRevisions(); Assert.AreEqual(2, _changesets.Count); }
public BobSetup(ConsoleProgress progress, string pathToTestRoot) { _progress = progress; BobSourcePath = Path.Combine(pathToTestRoot, "Bob"); Directory.CreateDirectory(BobSourcePath); string languageProjectPath = Path.Combine(BobSourcePath, ProjectFolderName); Directory.CreateDirectory(languageProjectPath); _languageProjectPath = languageProjectPath; _lexiconProjectPath = Path.Combine(_languageProjectPath, "lexicon"); Directory.CreateDirectory(_lexiconProjectPath); PathToText = Path.Combine(_lexiconProjectPath, "foo.abc"); File.WriteAllText(PathToText, "version one of my pretend txt"); _pathToLift = Path.Combine(_lexiconProjectPath, "foo.lift"); File.WriteAllText(_pathToLift, "<lift version='0.12'></lift>"); string picturesPath = Path.Combine(_lexiconProjectPath, "pictures"); Directory.CreateDirectory(picturesPath); File.WriteAllText(Path.Combine(picturesPath, "dog.jpg"), "Not really a picture"); string cachePath = Path.Combine(_lexiconProjectPath, "cache"); Directory.CreateDirectory(cachePath); File.WriteAllText(Path.Combine(cachePath, "cache.abc"), "Some cache stuff"); _projectFolderConfiguration = CreateFolderConfig(languageProjectPath); SyncOptions options = new SyncOptions(); options.DoPullFromOthers = false; options.DoMergeWithOthers = false; options.CheckinDescription = "Added"; RepositorySetup.MakeRepositoryForTest(languageProjectPath, "bob", _progress); SyncResults results = GetSynchronizer().SyncNow(options); }
public void TipUpdatedPostMerge() { ConsoleProgress progress = new ConsoleProgress(); BobSetup bobSetup = new BobSetup(progress, _pathToTestRoot); var bobSynchronizer = bobSetup.GetSynchronizer(); //set up two branches to trigger issue SetAdjunctModelVersion(bobSynchronizer, "notdefault"); // Bob is on 'default' branch bobSetup.ChangeTextFile(bobSynchronizer); //Ok, this is unrealistic, but we just clone Bob onto Sally var hubRoot = Path.Combine(_pathToTestRoot, "Hub"); var sallyMachineRoot = Path.Combine(_pathToTestRoot, "sally"); Directory.CreateDirectory(sallyMachineRoot); Directory.CreateDirectory(hubRoot); var sallyProjectRoot = bobSetup.SetupClone(sallyMachineRoot); var hubProjectRoot = bobSetup.SetupClone(hubRoot); var sallyProject = BobSetup.CreateFolderConfig(sallyProjectRoot); var hubProject = BobSetup.CreateFolderConfig(hubProjectRoot); var repository = HgRepository.CreateOrUseExisting(sallyProject.FolderPath, progress); repository.SetUserNameInIni("sally", progress); // bob makes a change and syncs File.WriteAllText(bobSetup._pathToLift, LiftFileStrings.lift12Dog); var bobOptions = new SyncOptions { CheckinDescription = "added 'dog'", DoMergeWithOthers = true, DoSendToOthers = true, DoPullFromOthers = true }; bobOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create("Hub", hubProject.FolderPath, false)); //now Sally modifies the original file, not having seen Bob's changes yet var sallyPathToLift = Path.Combine(sallyProject.FolderPath, Path.Combine("lexicon", "foo.lift")); File.WriteAllText(sallyPathToLift, LiftFileStrings.lift12Cat); //Sally syncs, pulling in Bob's change, and encountering a need to merge (no conflicts) var sallyOptions = new SyncOptions { CheckinDescription = "adding cat", DoPullFromOthers = true, DoSendToOthers = true, DoMergeWithOthers = true }; sallyOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create("Hub", hubProject.FolderPath, false)); var sallySyncer = Synchronizer.FromProjectConfiguration(sallyProject, progress); SetAdjunctModelVersion(sallySyncer, "notdefault"); sallySyncer.SyncNow(sallyOptions); bobSynchronizer.SyncNow(bobOptions); // bob makes a change and syncs File.WriteAllText(bobSetup._pathToLift, LiftFileStrings.lift12DogAnt); bobSynchronizer.SyncNow(bobOptions); sallyOptions.DoSendToOthers = false; sallySyncer.SyncNow(sallyOptions); //Debug.WriteLine("bob's: " + File.ReadAllText(bobSetup._pathToLift)); var contents = File.ReadAllText(sallyPathToLift); //Debug.WriteLine("sally's: " + contents); Assert.IsTrue(contents.Contains("ant")); Assert.IsTrue(contents.Contains("dog")); }
public void TestNewVersion_SallyUpgrades_BobNotYet() { ConsoleProgress progress = new ConsoleProgress(); BobSetup bobSetup = new BobSetup(progress, _pathToTestRoot); bobSetup.ChangeTextFile(); //Ok, this is unrealistic, but we just clone Bob onto Sally string sallyMachineRoot = Path.Combine(_pathToTestRoot, "sally"); Directory.CreateDirectory(sallyMachineRoot); string sallyProjectRoot = bobSetup.SetupClone(sallyMachineRoot); ProjectFolderConfiguration sallyProject = new ProjectFolderConfiguration(sallyProjectRoot); sallyProject.IncludePatterns.Add("**.abc"); sallyProject.IncludePatterns.Add("**.lift"); var repository = HgRepository.CreateOrUseExisting(sallyProject.FolderPath, progress); repository.SetUserNameInIni("sally", progress); // bob makes a change and syncs File.WriteAllText(bobSetup._pathToLift, LiftFileStrings.lift12Dog); var bobOptions = GetFullSyncOptions("added dog"); bobOptions.DoMergeWithOthers = false; // just want a fast checkin bobOptions.DoSendToOthers = false; // just want a fast checkin bobOptions.DoPullFromOthers = false; // just want a fast checkin var bobSyncer = bobSetup.GetSynchronizer(); SetAdjunctModelVersion(bobSyncer, ""); // Bob is on 'default' branch bobSyncer.SyncNow(bobOptions); //now Sally modifies the original file, not having seen Bob's changes yet var sallyPathToLift = Path.Combine(sallyProject.FolderPath, "lexicon/foo.lift"); File.WriteAllText(sallyPathToLift, LiftFileStrings.lift12Cat); //Sally syncs, pulling in Bob's change, and encountering a need to merge (no conflicts) var sallyOptions = GetFullSyncOptions("adding cat"); var bobAddress = RepositoryAddress.Create("bob's machine", bobSetup.BobProjectPath, false); sallyOptions.RepositorySourcesToTry.Add(bobAddress); var synchronizer = Synchronizer.FromProjectConfiguration(sallyProject, progress); const string sallyNewVersion = "LIFT0.13"; SetAdjunctModelVersion(synchronizer, sallyNewVersion); synchronizer.SyncNow(sallyOptions); // Verification var bobContents = File.ReadAllText(bobSetup._pathToLift); Assert.IsFalse(bobContents.Contains("cat"), "'cat' should only be on Sally's branch."); Assert.IsTrue(bobContents.Contains("dog")); var sallyContents = File.ReadAllText(sallyPathToLift); //Debug.WriteLine("sally's: " + sallyContents); Assert.IsTrue(sallyContents.Contains("cat")); Assert.IsFalse(sallyContents.Contains("dog"), "'dog' should only be in Bob's repo."); // Verify Bob is still on the default branch (empty string) string dummy; var result = bobSyncer.Repository.BranchingHelper.IsLatestBranchDifferent("", out dummy); Assert.IsFalse(result, "Bob should be on default branch."); // Verify Sally is on the right branch result = synchronizer.Repository.BranchingHelper.IsLatestBranchDifferent(sallyNewVersion, out dummy); Assert.IsFalse(result, "Sally should be on LIFT0.13 branch."); }
public void TestNewVersion_SallyUpgradesToBobVersion() { ConsoleProgress progress = new ConsoleProgress(); BobSetup bobSetup = new BobSetup(progress, _pathToTestRoot); bobSetup.ChangeTextFile(); //Ok, this is unrealistic, but we just clone Bob onto Sally string sallyMachineRoot = Path.Combine(_pathToTestRoot, "sally"); Directory.CreateDirectory(sallyMachineRoot); string sallyProjectRoot = bobSetup.SetupClone(sallyMachineRoot); ProjectFolderConfiguration sallyProject = new ProjectFolderConfiguration(sallyProjectRoot); sallyProject.IncludePatterns.Add("**.abc"); sallyProject.IncludePatterns.Add("**.lift"); var repository = HgRepository.CreateOrUseExisting(sallyProject.FolderPath, progress); repository.SetUserNameInIni("sally", progress); // bob makes a change and syncs File.WriteAllText(bobSetup._pathToLift, LiftFileStrings.lift12Dog); var bobOptions = GetFullSyncOptions("added dog"); bobOptions.DoMergeWithOthers = false; // just want a fast checkin bobOptions.DoSendToOthers = false; // just want a fast checkin bobOptions.DoPullFromOthers = false; // just want a fast checkin var bobsyncer = bobSetup.GetSynchronizer(); SetAdjunctModelVersion(bobsyncer, "LIFT0.12"); // Bob is still on an older branch bobsyncer.SyncNow(bobOptions); // bob makes another change and syncs File.WriteAllText(bobSetup._pathToLift, LiftFileStrings.lift13DogHerring); bobOptions.CheckinDescription = "added 'herring'"; // still just want a fast checkin SetAdjunctModelVersion(bobsyncer, "LIFT0.13"); // Bob is now on a new branch bobsyncer.SyncNow(bobOptions); //now Sally modifies the original file, not having seen Bob's changes yet var sallyPathToLift = Path.Combine(sallyProject.FolderPath, "lexicon/foo.lift"); File.WriteAllText(sallyPathToLift, LiftFileStrings.lift12Cat); //Sally syncs, pulling in Bob's 1st change, and encountering a need to merge (no conflicts) var sallyOptions = GetFullSyncOptions("adding cat"); sallyOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create("bob's machine", bobSetup.BobProjectPath, false)); var synchronizer = Synchronizer.FromProjectConfiguration(sallyProject, progress); SetAdjunctModelVersion(synchronizer, "LIFT0.12"); // Sally is still on the initial branch // SUT synchronizer.SyncNow(sallyOptions); // Verification stage 1 var bobContents = File.ReadAllText(bobSetup._pathToLift); Assert.IsFalse(bobContents.Contains("cat"), "'cat' should only be on Sally's branch."); Assert.IsTrue(bobContents.Contains("dog")); var sallyContents = File.ReadAllText(sallyPathToLift); Assert.IsTrue(sallyContents.Contains("cat")); Assert.IsTrue(sallyContents.Contains("dog"), "Sally should have merged in older branch to hers."); Assert.IsFalse(sallyContents.Contains("herring"), "The red herring is only in Bob's repo; 2nd branch."); // Now Sally upgrades her LIFT-capable program to Bob's version! File.WriteAllText(sallyPathToLift, LiftFileStrings.lift13PigDogCat); //Sally syncs, pulling in Bob's change, and encountering a need to merge (no conflicts) sallyOptions = GetFullSyncOptions("adding pig"); const string lift13version = "LIFT0.13"; SetAdjunctModelVersion(synchronizer, lift13version); // Sally updates to the new version (branch) synchronizer.SyncNow(sallyOptions); bobOptions.DoPullFromOthers = true; bobOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create("sally's machine", sallyProjectRoot, false)); // SUT bobsyncer.SyncNow(bobOptions); // Verification stage 2 bobContents = File.ReadAllText(bobSetup._pathToLift); //Debug.Print("Bob's: " + bobContents); Assert.IsTrue(bobContents.Contains("cat"), "'cat' survived the upgrade to Bob's repo."); Assert.IsTrue(bobContents.Contains("dog")); Assert.IsTrue(bobContents.Contains("pig"), "'pig' survived the upgrade to Bob's repo."); sallyContents = File.ReadAllText(sallyPathToLift); //Debug.Print("Sally's: " + sallyContents); Assert.IsTrue(sallyContents.Contains("cat")); Assert.IsTrue(sallyContents.Contains("dog"), "'dog' should be from Bob's older repo."); Assert.IsTrue(sallyContents.Contains("herring"), "Now we should have everything from Bob's repo."); Assert.IsTrue(sallyContents.Contains("pig"), "'pig' should have survived the upgrade."); // Verify Bob is on the latest branch string dummy; var result = bobsyncer.Repository.BranchingHelper.IsLatestBranchDifferent(lift13version, out dummy); Assert.IsFalse(result, "Bob should be on the latest LIFT0.13 branch."); // Verify Sally is on the right branch result = synchronizer.Repository.BranchingHelper.IsLatestBranchDifferent(lift13version, out dummy); Assert.IsFalse(result, "Sally should be on the latest LIFT0.13 branch."); }
public void TestNewVersion_SallyAndBobUpgradeButFredDelays() { ConsoleProgress progress = new ConsoleProgress(); BobSetup bobSetup = new BobSetup(progress, _pathToTestRoot); // clone Bob onto Sally string sallyMachineRoot = Path.Combine(_pathToTestRoot, "sally"); Directory.CreateDirectory(sallyMachineRoot); string sallyProjectRoot = bobSetup.SetupClone(sallyMachineRoot); ProjectFolderConfiguration sallyProject = new ProjectFolderConfiguration(sallyProjectRoot); sallyProject.IncludePatterns.Add("**.abc"); sallyProject.IncludePatterns.Add("**.lift"); // clone Bob onto Fred string fredMachineRoot = Path.Combine(_pathToTestRoot, "fred"); Directory.CreateDirectory(fredMachineRoot); string fredProjectRoot = bobSetup.SetupClone(fredMachineRoot); ProjectFolderConfiguration fredProject = new ProjectFolderConfiguration(fredProjectRoot); fredProject.IncludePatterns.Add("**.abc"); fredProject.IncludePatterns.Add("**.lift"); // Setup Sally and Fred repositories var sallyRepository = HgRepository.CreateOrUseExisting(sallyProject.FolderPath, progress); sallyRepository.SetUserNameInIni("sally", progress); var fredRepository = HgRepository.CreateOrUseExisting(fredProject.FolderPath, progress); fredRepository.SetUserNameInIni("fred", progress); var sallyRepoAddress = RepositoryAddress.Create("sally's machine", sallyProjectRoot, false); var fredRepoAddress = RepositoryAddress.Create("fred's machine", fredProjectRoot, false); var bobRepoAddress = RepositoryAddress.Create("bob's machine", bobSetup.BobProjectPath, false); // bob makes a change and syncs to everybody File.WriteAllText(bobSetup._pathToLift, LiftFileStrings.lift12Dog); var bobOptions = GetFullSyncOptions("added 'dog'"); bobOptions.RepositorySourcesToTry.Add(sallyRepoAddress); bobOptions.RepositorySourcesToTry.Add(fredRepoAddress); var bobSyncer = bobSetup.GetSynchronizer(); bobSyncer.SyncNow(bobOptions); // Bob syncs with everybody on 'default' branch // Verification Step 1 var sallyPathToLift = Path.Combine(sallyProject.FolderPath, "lexicon/foo.lift"); var fredPathToLift = Path.Combine(fredProject.FolderPath, "lexicon/foo.lift"); var sallyContents = File.ReadAllText(sallyPathToLift); Assert.IsTrue(sallyContents.Contains("dog"), "'dog' should be in Sally repo."); var fredContents = File.ReadAllText(fredPathToLift); Assert.IsTrue(fredContents.Contains("dog"), "'dog' should be in Fred repo."); // bob makes another change and syncs to new version File.WriteAllText(bobSetup._pathToLift, LiftFileStrings.lift13DogCat); var newBobOptions = GetFullSyncOptions("added 'cat'"); newBobOptions.DoMergeWithOthers = false; // just want a fast checkin newBobOptions.DoPullFromOthers = false; // just want a fast checkin newBobOptions.DoSendToOthers = false; // just want a fast checkin const string lift13version = "LIFT0.13"; SetAdjunctModelVersion(bobSyncer, lift13version); // Bob is now on the new version of LIFT bobSyncer.SyncNow(newBobOptions); // now Fred modifies default branch to add 'ant' File.WriteAllText(fredPathToLift, LiftFileStrings.lift12DogAnt); var fredOptions = GetFullSyncOptions("added 'ant'"); fredOptions.RepositorySourcesToTry.Add(bobRepoAddress); fredOptions.RepositorySourcesToTry.Add(sallyRepoAddress); var fredSyncer = Synchronizer.FromProjectConfiguration(fredProject, progress); fredSyncer.SyncNow(fredOptions); // Verification Step 2 fredContents = File.ReadAllText(fredPathToLift); Assert.IsFalse(fredContents.Contains("cat"), "'cat' should only be on Bob's branch."); Assert.IsTrue(fredContents.Contains("ant")); sallyContents = File.ReadAllText(sallyPathToLift); Assert.IsTrue(sallyContents.Contains("ant"), "'ant' was propogated to Sally's branch."); Assert.IsFalse(sallyContents.Contains("cat"), "'cat' should only be on Bob's branch."); var bobContents = File.ReadAllText(bobSetup._pathToLift); Assert.IsFalse(bobContents.Contains("ant"), "'ant' is only on 'default' branch."); // Verify Bob is on the latest branch string dummy; var result = bobSyncer.Repository.BranchingHelper.IsLatestBranchDifferent(lift13version, out dummy); Assert.IsFalse(result, "Bob should be on the new LIFT0.13 branch."); // And Fred isn't result = fredSyncer.Repository.BranchingHelper.IsLatestBranchDifferent(lift13version, out dummy); Assert.IsTrue(result, "Fred should still be on the 'default' branch."); // Now Sally modifies the file, not having seen Bob's changes yet, but having seen Fred's changes. // She adds 'herring' and has upgraded to Bob's version of LIFT File.WriteAllText(sallyPathToLift, LiftFileStrings.lift13DogAntHerring); //Sally syncs, pulling in Bob's 1st change, and encountering a need to merge (no conflicts) var sallyOptions = GetFullSyncOptions("adding 'herring'"); sallyOptions.RepositorySourcesToTry.Add(bobRepoAddress); sallyOptions.RepositorySourcesToTry.Add(fredRepoAddress); // Why not? Even though he's still on 'default' branch var sallySyncer = Synchronizer.FromProjectConfiguration(sallyProject, progress); SetAdjunctModelVersion(sallySyncer, lift13version); // Sally is now on the Bob's later version // Below is the line with the hg error sallySyncer.SyncNow(sallyOptions); // Verification Step 3 bobContents = File.ReadAllText(bobSetup._pathToLift); Assert.IsTrue(bobContents.Contains("herring"), "'herring' should be pulled in from Sally's branch."); Assert.IsTrue(bobContents.Contains("ant"), "'ant' should be pulled in from Sally's branch."); sallyContents = File.ReadAllText(sallyPathToLift); Assert.IsTrue(sallyContents.Contains("cat"), "'cat' should be pulled in from Bob's branch."); Assert.IsTrue(sallyContents.Contains("dog"), "Everybody should have 'dog' from before."); fredContents = File.ReadAllText(fredPathToLift); Assert.IsFalse(fredContents.Contains("herring"), "The red herring is only in the new version for now."); Assert.IsFalse(fredContents.Contains("cat"), "'cat' is only in the new version for now."); // Verify Sally is now on the latest branch result = sallySyncer.Repository.BranchingHelper.IsLatestBranchDifferent(lift13version, out dummy); Assert.IsFalse(result, "Sally should be on the new LIFT0.13 branch."); // And Fred still shouldn't be result = fredSyncer.Repository.BranchingHelper.IsLatestBranchDifferent(lift13version, out dummy); Assert.IsTrue(result, "Fred should still be on the 'default' branch."); // Now Fred checks in 'pig' to the 'default' branch File.WriteAllText(fredPathToLift, LiftFileStrings.lift12DogAntPig); // Fred syncs, not finding anybody else's changes fredOptions.CheckinDescription = "adding 'pig'"; fredSyncer.SyncNow(fredOptions); // Verification Step 4 bobContents = File.ReadAllText(bobSetup._pathToLift); Assert.IsFalse(bobContents.Contains("pig"), "'pig' should only be on 'default' branch."); sallyContents = File.ReadAllText(sallyPathToLift); Assert.IsFalse(sallyContents.Contains("pig"), "'pig' should only be on 'default' branch."); fredContents = File.ReadAllText(fredPathToLift); Assert.IsFalse(fredContents.Contains("herring"), "'herring' should still only be in the new version."); // Just check Fred hasn't changed branches result = fredSyncer.Repository.BranchingHelper.IsLatestBranchDifferent(lift13version, out dummy); Assert.IsTrue(result, "Fred should still be on the 'default' branch."); // Now Bob checks in 'deer' in the new version File.WriteAllText(bobSetup._pathToLift, LiftFileStrings.lift13DogCatHerringAntDeer); bobOptions.CheckinDescription = "adding 'deer'"; bobSyncer.SyncNow(bobOptions); // Verification Step 5 // Check that Fred hasn't changed fredContents = File.ReadAllText(fredPathToLift); Assert.IsFalse(fredContents.Contains("deer"), "'deer' should only be on new version."); result = fredSyncer.Repository.BranchingHelper.IsLatestBranchDifferent(lift13version, out dummy); Assert.IsTrue(result, "Fred should still be on the 'default' branch."); // Check that Sally got her 'deer' sallyContents = File.ReadAllText(sallyPathToLift); Assert.IsTrue(sallyContents.Contains("deer"), "'deer' should have propagated to Sally."); // Make sure that 'pig' hasn't migrated to the new version Assert.IsFalse(sallyContents.Contains("pig"), "'pig' should still only be on 'default' branch."); // Now Fred has finally upgraded and will check in 'fox' -- LAST CHECK-IN FOR THIS TEST! File.WriteAllText(fredPathToLift, LiftFileStrings.lift13DogAntPigFox); fredOptions.CheckinDescription = "adding 'fox'"; SetAdjunctModelVersion(fredSyncer, lift13version); // Fred finally updates to the new version (branch) fredSyncer.SyncNow(fredOptions); // Verification Step 6 (Last) bobContents = File.ReadAllText(bobSetup._pathToLift); Assert.IsTrue(bobContents.Contains("cat"), "'cat' should survive the big hairy test in Bob's repo."); Assert.IsTrue(bobContents.Contains("dog"), "'dog' should survive the big hairy test in Bob's repo."); Assert.IsTrue(bobContents.Contains("pig"), "'pig' should survive the big hairy test in Bob's repo."); Assert.IsTrue(bobContents.Contains("herring"), "'herring' should survive the big hairy test in Bob's repo."); Assert.IsTrue(bobContents.Contains("deer"), "'deer' should survive the big hairy test in Bob's repo."); Assert.IsTrue(bobContents.Contains("ant"), "'ant' should survive the big hairy test in Bob's repo."); Assert.IsTrue(bobContents.Contains("fox"), "'fox' should survive the big hairy test in Bob's repo."); sallyContents = File.ReadAllText(sallyPathToLift); Assert.IsTrue(sallyContents.Contains("cat"), "'cat' should survive the big hairy test in Sally's repo."); Assert.IsTrue(sallyContents.Contains("dog"), "'dog' should survive the big hairy test in Sally's repo."); Assert.IsTrue(sallyContents.Contains("herring"), "'herring' should survive the big hairy test in Sally's repo."); Assert.IsTrue(sallyContents.Contains("pig"), "'pig' should survive the big hairy test in Sally's repo."); Assert.IsTrue(sallyContents.Contains("deer"), "'deer' should survive the big hairy test in Sally's repo."); Assert.IsTrue(sallyContents.Contains("ant"), "'ant' should survive the big hairy test in Sally's repo."); Assert.IsTrue(sallyContents.Contains("fox"), "'fox' should survive the big hairy test in Sally's repo."); fredContents = File.ReadAllText(fredPathToLift); Assert.IsTrue(fredContents.Contains("cat"), "'cat' should survive the big hairy test in Fred's repo."); Assert.IsTrue(fredContents.Contains("dog"), "'dog' should survive the big hairy test in Fred's repo."); Assert.IsTrue(fredContents.Contains("herring"), "'herring' should survive the big hairy test in Fred's repo."); Assert.IsTrue(fredContents.Contains("pig"), "'pig' should survive the big hairy test in Fred's repo."); Assert.IsTrue(fredContents.Contains("deer"), "'deer' should survive the big hairy test in Fred's repo."); Assert.IsTrue(fredContents.Contains("ant"), "'ant' should survive the big hairy test in Fred's repo."); Assert.IsTrue(fredContents.Contains("fox"), "'fox' should survive the big hairy test in Fred's repo."); // Verify Bob is on the latest branch result = bobSyncer.Repository.BranchingHelper.IsLatestBranchDifferent(lift13version, out dummy); Assert.IsFalse(result, "Bob should be on the new LIFT0.13 branch."); // Verify Sally is on the right branch result = sallySyncer.Repository.BranchingHelper.IsLatestBranchDifferent(lift13version, out dummy); Assert.IsFalse(result, "Sally should be on the new LIFT0.13 branch."); // Verify Fred is finally on the new branch result = fredSyncer.Repository.BranchingHelper.IsLatestBranchDifferent(lift13version, out dummy); Assert.IsFalse(result, "Fred should finally be on the new LIFT0.13 branch."); }
public void CanShareConflictingChangeViaUsb() { ConsoleProgress progress = new ConsoleProgress(); BobSetup bobSetup = new BobSetup(progress, _pathToTestRoot); bobSetup.ChangeTextFile(); string usbSourcePath = Path.Combine(_pathToTestRoot, "USB-A"); Directory.CreateDirectory(usbSourcePath); string usbProjectPath = bobSetup.SetupClone(usbSourcePath); Synchronizer usbRepo = Synchronizer.FromProjectConfiguration(BobSetup.CreateFolderConfig(usbProjectPath), progress); Synchronizer bobSynchronizer = bobSetup.GetSynchronizer(); //Sally gets the usb and uses it to clone herself a repository string sallySourcePath = Path.Combine(_pathToTestRoot, "sally"); Directory.CreateDirectory(sallySourcePath); //string sallyRepoPath = usbRepo.MakeClone(Path.Combine(sallySourcePath, BobSetup.ProjectFolderName), true); string sallyRepoPath = HgHighLevel.MakeCloneFromUsbToLocal(usbRepo.Repository.PathToRepo, Path.Combine(sallySourcePath, BobSetup.ProjectFolderName), progress); //Now bob sets up the conflict File.WriteAllText(bobSetup.PathToText, "Bob's new idea"); SyncOptions bobOptions = new SyncOptions(); bobOptions.CheckinDescription = "changed my mind"; bobOptions.DoMergeWithOthers = false; // pretend the usb key isn't there bobOptions.DoPullFromOthers = false; // pretend the usb key isn't there bobOptions.DoSendToOthers = false; RepositoryAddress usbPath = RepositoryAddress.Create( "usba source", Path.Combine(usbSourcePath, RepositoryAddress.ProjectNameVariable),false); bobOptions.RepositorySourcesToTry.Add(usbPath); bobSynchronizer.SyncNow(bobOptions); ProjectFolderConfiguration sallyProject = BobSetup.CreateFolderConfig(sallyRepoPath); Synchronizer sallySynchronizer = Synchronizer.FromProjectConfiguration(sallyProject, progress); sallySynchronizer.Repository.SetUserNameInIni("sally", new NullProgress()); //now she modifies a file File.WriteAllText(Path.Combine(sallyRepoPath, Path.Combine("lexicon", "foo.abc")), "Sally was here"); //and syncs, which pushes back to the usb key SyncOptions sallyOptions = new SyncOptions(); sallyOptions.CheckinDescription = "making sally's mark on foo.abc"; sallyOptions.RepositorySourcesToTry.Add(usbPath); sallyOptions.DoPullFromOthers = true; sallyOptions.DoMergeWithOthers = true; sallyOptions.DoSendToOthers = true; sallySynchronizer.SyncNow(sallyOptions); //bob still doesn't have direct access to sally's repo... it's in some other city // but now the usb comes back to him // SyncOptions bobOptions = new SyncOptions(); bobOptions.CheckinDescription = "Getting from sally, i hope"; bobOptions.DoPullFromOthers = true; bobOptions.DoSendToOthers = true; bobOptions.DoMergeWithOthers = true; bobSynchronizer.SyncNow(bobOptions); // With sync set as 'WeWin' Assert.AreEqual("Bob's new idea", File.ReadAllText(bobSetup.PathToText)); var notesPath = Path.Combine(Path.Combine(Path.Combine(usbSourcePath, BobSetup.ProjectFolderName), "lexicon"), "foo.abc.ChorusNotes"); AssertThatXmlIn.File(notesPath).HasSpecifiedNumberOfMatchesForXpath("//notes/annotation[@class='mergeConflict']", 1); //The conflict has now been created, in the merge with Bob, make a new conflict and make sure that when Sally does the next sync both conflicts are //present in the ChorusNotes. File.WriteAllText(Path.Combine(sallyRepoPath, Path.Combine("lexicon", "foo.abc")), "Sally changed her mind"); File.WriteAllText(bobSetup.PathToText, "Bob changed his mind."); bobOptions.CheckinDescription = "Bob makes conflicting change."; bobSynchronizer.SyncNow(bobOptions); sallyOptions.CheckinDescription = "Sally makes conflicting change."; sallySynchronizer.SyncNow(sallyOptions); AssertThatXmlIn.File(notesPath).HasSpecifiedNumberOfMatchesForXpath("//notes/annotation[@class='mergeConflict']", 2); }
public void CanGetNewFileFromAnotherRep() { ConsoleProgress progress = new ConsoleProgress(); BobSetup bobSetup = new BobSetup(progress, _pathToTestRoot); bobSetup.ChangeTextFile(); string usbPath = Path.Combine(_pathToTestRoot, "USB-A"); Directory.CreateDirectory(usbPath); bobSetup.SetupClone(usbPath); RepositoryAddress otherDirPath = RepositoryAddress.Create("USBA", Path.Combine(usbPath, RepositoryAddress.ProjectNameVariable), false); Synchronizer bob = bobSetup.GetSynchronizer(); bob.ExtraRepositorySources.Add(otherDirPath); //now stick a new file over in the "usb", so we can see if it comes back to us File.WriteAllText(Path.Combine(otherDirPath.GetPotentialRepoUri(bob.Repository.Identifier, BobSetup.ProjectFolderName, progress), "incoming.abc"), "this would be a file coming in"); var options = GetFullSyncOptions("adding a file to the usb for some reason"); ProjectFolderConfiguration usbProject = BobSetup.CreateFolderConfig(Path.Combine(usbPath, BobSetup.ProjectFolderName)); var synchronizer = Synchronizer.FromProjectConfiguration(usbProject, progress); synchronizer.Repository.SetUserNameInIni("usba", progress); synchronizer.SyncNow(options); //now we should get that file options = GetFullSyncOptions("test getting new file from usb"); options.DoMergeWithOthers = false; options.DoSendToOthers = false; options.RepositorySourcesToTry.Add(otherDirPath); bob.SyncNow(options); Assert.IsTrue(File.Exists(Path.Combine(bobSetup._languageProjectPath, "incoming.abc"))); }
public void MakeClone_TargetExists_CreatesCloneInAnotherFolder() { using (var repo = new RepositorySetup("source")) using (var f = new TemporaryFolder("clonetest")) { var model = new CloneFromUsb(); var progress = new ConsoleProgress(); progress.ShowVerbose = true; var extantFolder = f.Combine(RepositorySetup.ProjectNameForTest); Directory.CreateDirectory(extantFolder); // Make a subfolder, which will force it to make a new folder, since an empty folder is deleted. var extantSubfolderPath = Path.Combine(extantFolder, "ChildFolder"); Directory.CreateDirectory(extantSubfolderPath); var cloneFolder = model.MakeClone(repo.ProjectFolder.Path, f.Path, progress); Assert.AreEqual(extantFolder + "1", cloneFolder); Assert.IsTrue(Directory.Exists(extantFolder + "1")); } }
public void Setup() { HgRunner.TimeoutSecondsOverrideForUnitTests = 10000;//reset it in between tests _progress = new ConsoleProgress(); }
public void MakeClone_TargetExists_CreatesCloneInWhenTargetIsEmpty() { using (var repo = new RepositorySetup("source")) using (var f = new TemporaryFolder("clonetest")) { var model = new CloneFromUsb(); var progress = new ConsoleProgress(); progress.ShowVerbose = true; var extantFolder = f.Combine(RepositorySetup.ProjectNameForTest); Directory.CreateDirectory(extantFolder); var cloneFolder = model.MakeClone(repo.ProjectFolder.Path, f.Path, progress); Assert.AreEqual(extantFolder, cloneFolder); Assert.IsTrue(Directory.Exists(extantFolder)); Assert.IsFalse(Directory.Exists(extantFolder + "1")); } }
/// <summary> /// /// </summary> /// <returns>false if it couldn't start</returns> public bool Start() { try { foreach (var hg in Process.GetProcessesByName("hg")) { //EventLog.WriteEntry("Application", "Killing old hg...", EventLogEntryType.Information); hg.Kill(); if (!hg.WaitForExit(10000)) { //EventLog.WriteEntry("Application", "ChorusHub was unable to stop an old hg from running. It will now give up. You should stop the server and run it again after killing whatever 'hg.exe' process is running.", EventLogEntryType.Error); return false; } } //we make directories based on what we see in there, so start it afresh lest we re-create folder names //that the user long ago stopped using if (File.Exists(AccessLogPath)) File.Delete(AccessLogPath); if (!Directory.Exists(_rootFolder)) Directory.CreateDirectory(_rootFolder); //EventLog.WriteEntry("Application", "Starting Mercurial Server", EventLogEntryType.Information); WriteConfigFile(_rootFolder); var arguments = "serve -A accessLog.txt -E log.txt -p " + Port + " --verbose "; const float kHgVersion = (float)1.5; if (kHgVersion < 1.9) { arguments += "--webdir-conf hgweb.config"; } else { arguments += "--web-conf hgweb.config"; } #if CommandWindow _hgServeProcess = new Process(); _hgServeProcess.StartInfo.WorkingDirectory = _rootFolder; _hgServeProcess.StartInfo.FileName = Chorus.MercurialLocation.PathToHgExecutable; _hgServeProcess.StartInfo.Arguments = arguments; _hgServeProcess.StartInfo.ErrorDialog = true; _hgServeProcess.StartInfo.UseShellExecute = false; _hgServeProcess.StartInfo.RedirectStandardOutput = true; _hgServeProcess.Start(); #else _hgServeThread = new Thread(() => { var commandLineRunner = new CommandLineRunner(); try { var progress = new ConsoleProgress(); commandLineRunner.Start( Chorus.MercurialLocation.PathToHgExecutable, arguments, Encoding.UTF8, _rootFolder, -1, progress, s => progress.WriteMessage(s)); } catch (ThreadAbortException) { //Progress.WriteVerbose("Hg Serve command Thread Aborting (that's normal when stopping)"); try { if (!commandLineRunner.Abort(1)) { //EventLog.WriteEntry("Application", "Hg Serve might not have closed down.", EventLogEntryType.Information); } } catch { } } }); _hgServeThread.Start(); #endif return true; } catch (Exception error) { //EventLog.WriteEntry("Application", error.Message, EventLogEntryType.Error); return false; } }
public void Setup() { _progress = new ConsoleProgress(); }
public void Sync_NonExistantLangDepotProject_ExitsGracefullyWithCorrectErrorResult() { _model = new SyncControlModel(_project, SyncUIFeatures.Minimal, null); _model.SyncOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create("languageforge", "http://hg-public.languagedepot.org/dummy")); var progress = new ConsoleProgress() {ShowVerbose = true}; _model.AddMessagesDisplay(progress); SyncResults results = null; _model.SynchronizeOver += new EventHandler((sender, e) => results = (sender as SyncResults)); _model.Sync(true); var start = DateTime.Now; while (results == null) { Thread.Sleep(100); Application.DoEvents(); //else the background worker may starve if ((DateTime.Now.Subtract(start).Minutes > 1)) { Assert.Fail("Gave up waiting."); } } Assert.IsFalse(results.Succeeded); Assert.IsNotNull(results.ErrorEncountered); }
public void CanCollaborateOnLift() { ConsoleProgress progress = new ConsoleProgress(); BobSetup bobSetup = new BobSetup(progress, _pathToTestRoot); bobSetup.ChangeTextFile(); //Ok, this is unrealistic, but we just clone Bob onto Sally string sallyMachineRoot = Path.Combine(_pathToTestRoot, "sally"); Directory.CreateDirectory(sallyMachineRoot); string sallyProjectRoot = bobSetup.SetupClone(sallyMachineRoot); ProjectFolderConfiguration sallyProject = BobSetup.CreateFolderConfig(sallyProjectRoot); var repository = HgRepository.CreateOrUseExisting(sallyProject.FolderPath, progress); repository.SetUserNameInIni("sally",progress); // bob makes a change and syncs File.WriteAllText(bobSetup._pathToLift, LiftFileStrings.lift12Dog); var bobOptions = new SyncOptions { CheckinDescription = "added 'dog'", DoMergeWithOthers = false, // just want a fast checkin DoSendToOthers = false, // just want a fast checkin DoPullFromOthers = false // just want a fast checkin }; bobSetup.GetSynchronizer().SyncNow(bobOptions); //now Sally modifies the original file, not having seen Bob's changes yet var sallyPathToLift = Path.Combine(sallyProject.FolderPath, Path.Combine("lexicon", "foo.lift")); File.WriteAllText(sallyPathToLift, LiftFileStrings.lift12Cat); //Sally syncs, pulling in Bob's change, and encountering a need to merge (no conflicts) var sallyOptions = new SyncOptions { CheckinDescription = "adding cat", DoPullFromOthers = true, DoSendToOthers = true, DoMergeWithOthers = true }; sallyOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create("bob's machine", bobSetup.BobProjectPath, false)); var synchronizer = Synchronizer.FromProjectConfiguration(sallyProject, progress); synchronizer.SyncNow(sallyOptions); //Debug.WriteLine("bob's: " + File.ReadAllText(bobSetup._pathToLift)); var contents = File.ReadAllText(sallyPathToLift); //Debug.WriteLine("sally's: " + contents); Assert.IsTrue(contents.Contains("cat")); Assert.IsTrue(contents.Contains("dog")); }
public void MakeClone_NoProblems_MakesClone() { using(var repo = new RepositorySetup("source")) using (var f = new TemporaryFolder("clonetest")) { var model = new CloneFromUsb(); var progress = new ConsoleProgress(); progress.ShowVerbose = true; model.MakeClone(repo.ProjectFolder.Path, f.Path, progress); Assert.IsTrue(Directory.Exists(f.Combine(RepositorySetup.ProjectNameForTest, ".hg"))); } }