Exemple #1
0
        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.That(Path.Combine(bobSetup._languageProjectPath, "incoming.abc"), Does.Exist);
        }
Exemple #2
0
        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.That(contents, Does.Contain("cat"));
            Assert.That(contents, Does.Contain("dog"));
        }
Exemple #3
0
        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.That(contents, Does.Contain("ant"));
            Assert.That(contents, Does.Contain("dog"));
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        [Category("KnownMonoIssue")]         // Actually, it is an unknown mono issue.
        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.That(bobContents, Does.Not.Contain("cat"), "'cat' should only be on Sally's branch.");
            Assert.That(bobContents, Does.Contain("dog"));
            var sallyContents = File.ReadAllText(sallyPathToLift);

            Assert.That(sallyContents, Does.Contain("cat"));
            Assert.That(sallyContents, Does.Contain("dog"), "Sally should have merged in older branch to hers.");
            Assert.That(sallyContents, Does.Not.Contain("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.That(bobContents, Does.Contain("cat"), "'cat' survived the upgrade to Bob's repo.");
            Assert.That(bobContents, Does.Contain("dog"));
            Assert.That(bobContents, Does.Contain("pig"), "'pig' survived the upgrade to Bob's repo.");
            sallyContents = File.ReadAllText(sallyPathToLift);
            //Debug.Print("Sally's: " + sallyContents);
            Assert.That(sallyContents, Does.Contain("cat"));
            Assert.That(sallyContents, Does.Contain("dog"), "'dog' should be from Bob's older repo.");
            Assert.That(sallyContents, Does.Contain("herring"), "Now we should have everything from Bob's repo.");
            Assert.That(sallyContents, Does.Contain("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.That(result, Is.False, "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.That(result, Is.False, "Sally should be on the latest LIFT0.13 branch.");
        }
Exemple #6
0
        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.That(bobContents, Does.Not.Contain("cat"), "'cat' should only be on Sally's branch.");
            Assert.That(bobContents, Does.Contain("dog"));
            var sallyContents = File.ReadAllText(sallyPathToLift);

            //Debug.WriteLine("sally's: " + sallyContents);
            Assert.That(sallyContents, Does.Contain("cat"));
            Assert.That(sallyContents, Does.Not.Contain("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.That(result, Is.False, "Bob should be on default branch.");

            // Verify Sally is on the right branch
            result = synchronizer.Repository.BranchingHelper.IsLatestBranchDifferent(sallyNewVersion, out dummy);
            Assert.That(result, Is.False, "Sally should be on LIFT0.13 branch.");
        }
Exemple #7
0
        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"));
        }
Exemple #8
0
        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.");
        }
Exemple #9
0
        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.");
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        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")));
        }
Exemple #12
0
        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"));
        }