public void SyncNow_AlreadySetupFauxUsbAvailable_UsbGetsSync() { SyncOptions options = new SyncOptions(); Synchronizer synchronizer = Synchronizer.FromProjectConfiguration(_project, _progress); synchronizer.SyncNow(options); options.RepositorySourcesToTry.Add(synchronizer.UsbPath); string usbDirectory = Path.Combine(UsbKeyRepositorySource.RootDirForUsbSourceDuringUnitTest, "foo project"); // synchronizer.MakeClone(usbDirectory, true); HgHighLevel.MakeCloneFromUsbToLocal(synchronizer.Repository.PathToRepo, usbDirectory, _progress); string contents = File.ReadAllText(Path.Combine(usbDirectory, "foo.txt")); Assert.AreEqual("version one", contents); WriteTestFile("version two"); //_progress.ShowVerbose = true; options.CheckinDescription = "Changing to two"; synchronizer.SyncNow(options); var usb = new HgRepository(usbDirectory, _progress); Assert.AreEqual("Changing to two", usb.GetTip().Summary); //did it update too (which we should do with usb, unless we switch to leave them as "bare" .hgs)? contents = File.ReadAllText(Path.Combine(usbDirectory, "foo.txt")); Assert.AreEqual("version two", contents); }
public void SyncNow_BackupAlreadySetUp_GetsSync() { SyncOptions options = new SyncOptions(); _synchronizer.SyncNow(options); string projectDirOnBackup = Path.Combine(_pathToBackupFolder, "foo project.2"); //_synchronizer.MakeClone(projectDirOnBackup, true); HgHighLevel.MakeCloneFromUsbToLocal(_synchronizer.Repository.PathToRepo, projectDirOnBackup, _progress); string contents = File.ReadAllText(Path.Combine(projectDirOnBackup, "foo.txt")); Assert.AreEqual("version one", contents); WriteTestFile("version two"); }
private RepositoryWithFilesSetup(string userName, RepositoryWithFilesSetup cloneFromUser) { Progress = new MultiProgress(new IProgress[] { new ConsoleProgress(), _stringProgress }); RootFolder = new TemporaryFolder("ChorusTest-" + userName + "-" + Guid.NewGuid()); Console.WriteLine("TestRepository Cloned: {0}", RootFolder.Path); string pathToProject = RootFolder.Combine(Path.GetFileName(cloneFromUser.ProjectFolder.Path)); //cloneFromUser.Synchronizer.MakeClone(pathToProject, true); HgHighLevel.MakeCloneFromUsbToLocal(cloneFromUser.Repository.PathToRepo, pathToProject, Progress); ProjectFolder = TemporaryFolder.TrackExisting(RootFolder.Combine("foo project")); string pathToOurLiftFile = ProjectFolder.Combine(Path.GetFileName(cloneFromUser.UserFile.Path)); UserFile = TempFile.TrackExisting(pathToOurLiftFile); Init(userName); }
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); }
/// <summary> /// /// </summary> /// <param name="targetPath">does not inclue the project folder dir</param> public string SetupClone(string targetPath) { //return GetSynchronizer().MakeClone(Path.Combine(targetPath, BobSetup.ProjectFolderName), true); return(HgHighLevel.MakeCloneFromUsbToLocal(_languageProjectPath, Path.Combine(targetPath, BobSetup.ProjectFolderName), _progress)); }
///<summary> /// Makes a Mercurial clone of a repository from sourcePath to parentDirectoryToPutCloneIn ///</summary> ///<param name="sourcePath">Existing Hg repo</param> ///<param name="parentDirectoryToPutCloneIn">Target folder for new clone</param> ///<param name="progress">Progress indicator object</param> ///<returns>Directory that clone was actually placed in (allows for renaming to avoid duplicates)</returns> public string MakeClone(string sourcePath, string parentDirectoryToPutCloneIn, IProgress progress) { return(HgHighLevel.MakeCloneFromUsbToLocal(sourcePath, Path.Combine(parentDirectoryToPutCloneIn, Path.GetFileName(sourcePath)), progress)); }
private void MakeClone(string pathToNewRepo) { HgHighLevel.MakeCloneFromUsbToLocal(ProjectFolder.Path, pathToNewRepo, Progress); }