public void SampleDiff()
        {
            const string parent =
            @"<?xml version='1.0' encoding='utf-8'?>
            <ImportSettings>
            <ScrImportSet guid='0a0be0c1-39c4-44d4-842e-231680c7cd56' >
            <ImportType val='2' />
            </ScrImportSet>
            </ImportSettings>";

            var child = parent.Replace("val='2'", "val='3'");

            using (var repositorySetup = new RepositorySetup("randy"))
            {
                repositorySetup.AddAndCheckinFile(SharedConstants.ImportSettingsFilename, parent);
                repositorySetup.ChangeFileAndCommit(SharedConstants.ImportSettingsFilename, child, "change it");
                var hgRepository = repositorySetup.Repository;
                var allRevisions = (from rev in hgRepository.GetAllRevisions()
                                    orderby rev.Number.LocalRevisionNumber
                                    select rev).ToList();
                var first = allRevisions[0];
                var second = allRevisions[1];
                var firstFiR = hgRepository.GetFilesInRevision(first).First();
                var secondFiR = hgRepository.GetFilesInRevision(second).First();
                var result = FileHandler.Find2WayDifferences(firstFiR, secondFiR, hgRepository).ToList();
                Assert.AreEqual(1, result.Count);
                var onlyReport = result[0];
                Assert.IsInstanceOf<XmlChangedRecordReport>(onlyReport);
                Assert.AreEqual(firstFiR.FullPath, onlyReport.PathToFile);
            }
        }
 public void Find2WayDifferencesShouldReportOneChangeNoMatterHowManyWereMade()
 {
     // There are actually more than one change, but we don't fret about that at this point.
     const string parent =
     @"<?xml version='1.0' encoding='utf-8'?>
     <ProjectLexiconSettings>
     </ProjectLexiconSettings>";
     const string child =
     @"<?xml version='1.0' encoding='utf-8'?>
     <ProjectLexiconSettings>
     <WritingSystems addToSldr='true' />
     </ProjectLexiconSettings>";
     using (var repositorySetup = new RepositorySetup("randy-" + Guid.NewGuid()))
     {
         repositorySetup.AddAndCheckinFile("some.plsx", parent);
         repositorySetup.ChangeFileAndCommit("some.plsx", child, "change it");
         var hgRepository = repositorySetup.Repository;
         var allRevisions = (from rev in hgRepository.GetAllRevisions()
                             orderby rev.Number.LocalRevisionNumber
                             select rev).ToList();
         var first = allRevisions[0];
         var second = allRevisions[1];
         var firstFiR = hgRepository.GetFilesInRevision(first).First();
         var secondFiR = hgRepository.GetFilesInRevision(second).First();
         var result = _projectLexiconSettingsFileHandler.Find2WayDifferences(firstFiR, secondFiR, hgRepository);
         Assert.AreEqual(1, result.Count());
         Assert.AreEqual("Edited", result.First().ActionLabel);
     }
 }
        public void SampleDiff()
        {
            const string parent =
            @"<?xml version='1.0' encoding='utf-8'?>
            <LayoutInventory>
              <layout class='CmLocation' type='jtview' name='publishStemLocation#Stem-612' version='19'>
            <generate class='LexExampleSentence' fieldType='mlstring' restrictions='customOnly' />
              </layout>
            </LayoutInventory>";

            var child = parent.Replace("19", "20");

            using (var repositorySetup = new RepositorySetup("randy"))
            {
                repositorySetup.AddAndCheckinFile("Sample." + SharedConstants.fwlayout, parent);
                repositorySetup.ChangeFileAndCommit("Sample." + SharedConstants.fwlayout, child, "change it");
                var hgRepository = repositorySetup.Repository;
                var allRevisions = (from rev in hgRepository.GetAllRevisions()
                                    orderby rev.Number.LocalRevisionNumber
                                    select rev).ToList();
                var first = allRevisions[0];
                var second = allRevisions[1];
                var firstFiR = hgRepository.GetFilesInRevision(first).First();
                var secondFiR = hgRepository.GetFilesInRevision(second).First();
                var result = FileHandler.Find2WayDifferences(firstFiR, secondFiR, hgRepository).ToList();
                Assert.AreEqual(1, result.Count);
                var onlyReport = result[0];
                Assert.IsInstanceOf<XmlChangedRecordReport>(onlyReport);
                Assert.AreEqual(firstFiR.FullPath, onlyReport.PathToFile);
            }
        }
Пример #4
0
 public void CreateOrLocate_FolderHasAccentedLetter_FindsIt()
 {
     using (var setup = new RepositorySetup("Abé Books"))
     {
         Assert.NotNull(HgRepository.CreateOrUseExisting(setup.Repository.PathToRepo, new ConsoleProgress()));
     }
 }
Пример #5
0
        public void ExcludedVideosFileNotAdded()
        {
            using (var setup = new RepositorySetup("Dan"))
            {
                var atRoot = setup.ProjectFolder.Combine("first.wmv");
                File.WriteAllText(atRoot, "hello");

                var pictures = setup.ProjectFolder.Combine("pictures");
                Directory.CreateDirectory(pictures);
                var videoExtensions = ProjectFolderConfiguration.VideoExtensions.ToList();
                foreach (var videoExtension in videoExtensions)
                {
                    var bad = Path.Combine(pictures, "nested." + videoExtension);
                    File.WriteAllText(bad, "hello");
                }

                setup.ProjectFolderConfig.ExcludePatterns.Clear();
                setup.ProjectFolderConfig.IncludePatterns.Clear();

                LiftFolder.AddLiftFileInfoToFolderConfiguration(setup.ProjectFolderConfig);

                setup.AddAndCheckIn();
                setup.AssertFileDoesNotExistInRepository("first.wmv");
                foreach (var videoExtension in videoExtensions)
                    setup.AssertFileDoesNotExistInRepository("pictures/nested." + videoExtension);
            }
        }
Пример #6
0
 public void GetTip_BeforeAnySyncing_EmptyString()
 {
     using (var setup = new RepositorySetup("Dan"))
     {
         Assert.IsNull(setup.Repository.GetTip());
     }
 }
Пример #7
0
        public void ExplicitlyExcludedNonexistantFileNotFiltered()
        {
            using (var bob = new RepositorySetup("bob"))
            {
                const string largeDictionaryFilename = "ghost.dic";
                var largeDictionaryPathname = Path.Combine("nestedFolder", largeDictionaryFilename);
                var fullDictionaryPathname = Path.Combine(bob.ProjectFolderConfig.FolderPath, largeDictionaryPathname);
                var pathToRepo = bob.Repository.PathToRepo + Path.DirectorySeparatorChar;
                const string randomFile = "random.txt";
                bob.ChangeFile(randomFile, "Some text.");
                var fullRandomPathname = Path.Combine(bob.ProjectFolderConfig.FolderPath, randomFile);
                bob.Repository.TestOnlyAddSansCommit(fullRandomPathname);

                var config = bob.ProjectFolderConfig;
                config.ExcludePatterns.Clear();
                config.ExcludePatterns.Add(Path.Combine("nestedFolder", "ghost.dic"));
                config.IncludePatterns.Clear();
                config.IncludePatterns.Add("**.*");

                var result = LargeFileFilter.FilterFiles(
                    bob.Repository,
                    config,
                    ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers());
                Assert.IsTrue(string.IsNullOrEmpty(result));
                var shortpath = fullDictionaryPathname.Replace(pathToRepo, "");
                Assert.IsTrue(config.ExcludePatterns.Contains(shortpath));
                Assert.IsFalse(config.IncludePatterns.Contains(shortpath));

                shortpath = fullRandomPathname.Replace(pathToRepo, "");
                Assert.IsFalse(config.ExcludePatterns.Contains(shortpath));
                Assert.IsFalse(config.IncludePatterns.Contains(shortpath));
            }
        }
Пример #8
0
        public void IncludeFilesInSubFolders()
        {
            using (var setup = new RepositorySetup("Dan"))
            {
                var subpictures = setup.ProjectFolder.Combine("pictures", "subpictures");
                Directory.CreateDirectory(subpictures);
                var goodpicture = setup.ProjectFolder.Combine(subpictures, "good.picture");
                File.WriteAllText(goodpicture, "hello"); // Not a real jpeg file

                var subaudio = setup.ProjectFolder.Combine("audio", "subaudio");
                Directory.CreateDirectory(subaudio);
                var goodaudio = setup.ProjectFolder.Combine(subaudio, "good.audio");
                File.WriteAllText(goodaudio, "hello"); // Not a real mp3 file

                var subothers = setup.ProjectFolder.Combine("others", "subothers");
                Directory.CreateDirectory(subothers);
                var goodother = setup.ProjectFolder.Combine(subothers, "good.other");
                File.WriteAllText(goodother, "hello");

                setup.ProjectFolderConfig.ExcludePatterns.Clear();
                setup.ProjectFolderConfig.IncludePatterns.Clear();

                LiftFolder.AddLiftFileInfoToFolderConfiguration(setup.ProjectFolderConfig);

                setup.AddAndCheckIn();
                setup.AssertFileExistsInRepository("pictures/subpictures/good.picture");
                setup.AssertFileExistsInRepository("audio/subaudio/good.audio");
                setup.AssertFileExistsInRepository("others/subothers/good.other");
            }
        }
        public void SampleDiff()
        {
            const string parent =
            @"<?xml version='1.0' encoding='utf-8'?>
            <TranslatedScripture>
            <Scripture guid='06425922-3258-4094-a9ec-3c2fe5b52b39'>
            <VerseSepr>
            <Uni>,</Uni>
            </VerseSepr>
            </Scripture>
            </TranslatedScripture>";

            var child = parent.Replace("<Uni>,</Uni>", "<Uni>+</Uni>");

            using (var repositorySetup = new RepositorySetup("randy"))
            {
                repositorySetup.AddAndCheckinFile(SharedConstants.ScriptureTransFilename, parent);
                repositorySetup.ChangeFileAndCommit(SharedConstants.ScriptureTransFilename, child, "change it");
                var hgRepository = repositorySetup.Repository;
                var allRevisions = (from rev in hgRepository.GetAllRevisions()
                                    orderby rev.Number.LocalRevisionNumber
                                    select rev).ToList();
                var first = allRevisions[0];
                var second = allRevisions[1];
                var firstFiR = hgRepository.GetFilesInRevision(first).First();
                var secondFiR = hgRepository.GetFilesInRevision(second).First();
                var result = FileHandler.Find2WayDifferences(firstFiR, secondFiR, hgRepository).ToList();
                Assert.AreEqual(1, result.Count);
                var onlyReport = result[0];
                Assert.IsInstanceOf<XmlChangedRecordReport>(onlyReport);
                Assert.AreEqual(firstFiR.FullPath, onlyReport.PathToFile);
            }
        }
Пример #10
0
 public void Find2WayDifferencesShouldReportOneChangeNoMatterHowManyWereMade()
 {
     // There are actually more than one change, but we don't fret about that at this point.
     const string parent =
     @"<?xml version='1.0' encoding='utf-8'?>
     <ldml>
     <special xmlns:palaso='urn://palaso.org/ldmlExtensions/v1' />
     </ldml>";
     const string child =
     @"<?xml version='1.0' encoding='utf-8'?>
     <ldml>
     <identity />
     <special xmlns:fw='urn://fieldworks.sil.org/ldmlExtensions/v1' />
     <special xmlns:palaso='urn://palaso.org/ldmlExtensions/v1' />
     </ldml>";
     using (var repositorySetup = new RepositorySetup("randy-" + Guid.NewGuid()))
     {
         repositorySetup.AddAndCheckinFile("some.ldml", parent);
         repositorySetup.ChangeFileAndCommit("some.ldml", child, "change it");
         var hgRepository = repositorySetup.Repository;
         var allRevisions = (from rev in hgRepository.GetAllRevisions()
                             orderby rev.Number.LocalRevisionNumber
                             select rev).ToList();
         var first = allRevisions[0];
         var second = allRevisions[1];
         var firstFiR = hgRepository.GetFilesInRevision(first).First();
         var secondFiR = hgRepository.GetFilesInRevision(second).First();
         var result = _ldmlFileHandler.Find2WayDifferences(firstFiR, secondFiR, hgRepository);
         Assert.AreEqual(1, result.Count());
         Assert.AreEqual("Edited", result.First().ActionLabel);
     }
 }
Пример #11
0
 public void NoMatchingFileHandlers_DoesNothing()
 {
     using (var bob = new RepositorySetup("bob"))
     {
         using(var cop = new CommitCop(bob.Repository , ChorusFileTypeHandlerCollection.CreateWithTestHandlerOnly(), bob.Progress))
         {
             bob.AddAndCheckinFile("test.abc", "hello");
         }
         bob.AssertLocalRevisionNumber(0);
     }
 }
Пример #12
0
        public void LaunchDialog_AutoWithMinimalUI()
        {
            using(var setup = new RepositorySetup("pedro"))
            {
                Application.EnableVisualStyles();
                var dlg = new SyncDialog(setup.ProjectFolderConfig,
                                         SyncUIDialogBehaviors.StartImmediatelyAndCloseWhenFinished,
                                         SyncUIFeatures.Minimal);

                dlg.ShowDialog();
            }
        }
        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 SettingSychronizerAdjunctToNullEndsWithDoNothingDefaultInterfaceImplementation()
		{
			using (var bob = new RepositorySetup("bob", true))
			{
				var synchronizer = bob.CreateSynchronizer();
				Assert.IsNotNull(synchronizer.SynchronizerAdjunct);
				Assert.IsInstanceOf<DefaultSychronizerAdjunct>(synchronizer.SynchronizerAdjunct);

				synchronizer.SynchronizerAdjunct = null;
				Assert.IsNotNull(synchronizer.SynchronizerAdjunct);
				Assert.IsInstanceOf<DefaultSychronizerAdjunct>(synchronizer.SynchronizerAdjunct);
			}
		}
Пример #15
0
 public void HasFileHandlers_Validates_DoesNothing()
 {
     using (var bob = new RepositorySetup("bob"))
     {
         using (var cop = new CommitCop(bob.Repository, ChorusFileTypeHandlerCollection.CreateWithTestHandlerOnly(), bob.Progress))
         {
             bob.AddAndCheckinFile("test.chorusTest", "hello");
             // SUT
             Assert.IsNullOrEmpty(cop.ValidationResult);
         }
         bob.AssertLocalRevisionNumber(0);
     }
 }
Пример #16
0
 public void ShowIt()
 {
     var setup = new RepositorySetup("pedro");
     {
         var c = new Chorus.UI.Misc.ReadinessPanel();
         c.ProjectFolderPath = setup.ProjectFolder.Path;
         var f = new Form();
         f.Width = c.Width + 20;
         f.Height = c.Height + 20;
         c.Dock = DockStyle.Fill;
         f.Controls.Add(c);
         Application.Run(f);
     }
 }
Пример #17
0
 public void IncludeAllButExcludeOne_FileNotAdded()
 {
     using (var setup = new RepositorySetup("Dan"))
     {
         var path = setup.ProjectFolder.Combine("test.1w1");
         File.WriteAllText(path, "hello");
         setup.ProjectFolderConfig.IncludePatterns.Clear();
         setup.ProjectFolderConfig.IncludePatterns.Add("*.*");
         setup.ProjectFolderConfig.ExcludePatterns.Clear();
         setup.ProjectFolderConfig.ExcludePatterns.Add("*.1w1");
         setup.AddAndCheckIn();
         setup.AssertFileDoesNotExistInRepository("test.1w1");
     }
 }
Пример #18
0
 public void EnsureTheseExtensionAreEnabled_noExistingExtensions_AddsThem()
 {
     using (new MercurialIniForTests())
     using (var setup = new RepositorySetup("Dan"))
     {
         setup.EnsureNoHgrcExists();
         var extensions = new Dictionary<string, string>();
         extensions.Add("a","");
         extensions.Add("b", "");
         setup.Repository.EnsureTheseExtensionsAndFormatSet(extensions);
         Assert.AreEqual("a", setup.Repository.GetEnabledExtension().First());
         Assert.AreEqual("b", setup.Repository.GetEnabledExtension().ToArray()[1]);
     }
 }
Пример #19
0
 public void LaunchDialog_BogusTarget_AdmitsError()
 {
     using(var setup = new RepositorySetup("pedro"))
     {
         Application.EnableVisualStyles();
         using (var dlg = new SyncDialog(setup.ProjectFolderConfig,
                                         SyncUIDialogBehaviors.StartImmediatelyAndCloseWhenFinished,
                                         SyncUIFeatures.Minimal))
         {
             dlg.SyncOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create("bogus", @"z:/"));
             dlg.ShowDialog();
             Assert.IsTrue(dlg.FinalStatus.WarningEncountered);
         }
     }
 }
Пример #20
0
        public RepositorySetup(string cloneName, RepositorySetup sourceToClone)
        {
            Init(cloneName);
            string pathToProject = RootFolder.Combine(ProjectNameForTest);

            ProjectFolderConfig            = sourceToClone.ProjectFolderConfig.Clone();
            ProjectFolderConfig.FolderPath = pathToProject;

            sourceToClone.MakeClone(pathToProject);
            ProjectFolder = TemporaryFolder.TrackExisting(RootFolder.Combine(ProjectNameForTest));

            var hg = new HgRepository(pathToProject, Progress);

            hg.SetUserNameInIni(cloneName, Progress);
        }
Пример #21
0
        public void AddUtf8FileName_CloneUpdatedFileExists()
        {
            using (var setup = new RepositorySetup("Dan"))
            {
                const string utf8FilePath = "açesbsun.wav";
                setup.ChangeFile(utf8FilePath, "hello");
                setup.ProjectFolderConfig.IncludePatterns.Add("*.wav");
                setup.AddAndCheckIn();

                using (var other = new RepositorySetup("Bob", setup))
                {
                    other.AssertFileExists(utf8FilePath);
                }

            }
        }
Пример #22
0
        public SyncResults CheckinAndPullAndMerge(RepositorySetup otherUser)
        {
            var options = new SyncOptions
            {
                DoMergeWithOthers = true,
                DoPullFromOthers  = true,
                DoSendToOthers    = true
            };

            if (otherUser != null)
            {
                options.RepositorySourcesToTry.Add(otherUser.GetRepositoryAddress());
            }

            return(SyncWithOptions(options));
        }
Пример #23
0
 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);
     }
 }
Пример #24
0
        public void DeletionReport_Not_ProducedForDeletedAnnotationUsingNotesHandler()
        {
            const string parent = @"<?xml version='1.0' encoding='utf-8'?>
                    <notes version='0'>
                        <annotation guid='old1'/>
                        <annotation guid='soonToBeGoner'/>
                    </notes>";
            const string child = @"<?xml version='1.0' encoding='utf-8'?>
                    <notes version='0'>
                        <annotation guid='old1'/>
                    </notes>";

            // Make sure the common differ code does produce the deletion report.
            using (var parentTempFile = new TempFile(parent))
            using (var childTempFile = new TempFile(child))
            {
                var listener = new ListenerForUnitTests();
                var differ = Xml2WayDiffer.CreateFromFiles(parentTempFile.Path, childTempFile.Path,
                    listener,
                    null,
                    "annotation",
                    "guid");
                differ.ReportDifferencesToListener();
                listener.AssertExpectedChangesCount(1);
                listener.AssertFirstChangeType<XmlDeletionChangeReport>();
            }
            // Now make sure the ChorusNotesFileHandler filters it out, and does not return it,
            // as per the original notes differ code.
            var notesHandler = (from handler in ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers().Handlers
                                where handler.GetType().Name == "ChorusNotesFileHandler"
                                select handler).First();
            using (var repositorySetup = new RepositorySetup("randy"))
            {
                repositorySetup.AddAndCheckinFile("notestest.ChorusNotes", parent);
                repositorySetup.ChangeFileAndCommit("notestest.ChorusNotes", child, "change it");
                var hgRepository = repositorySetup.Repository;
                var allRevisions = (from rev in hgRepository.GetAllRevisions()
                                    orderby rev.Number.LocalRevisionNumber
                                    select rev).ToList();
                var first = allRevisions[0];
                var second = allRevisions[1];
                var firstFiR = hgRepository.GetFilesInRevision(first).First();
                var secondFiR = hgRepository.GetFilesInRevision(second).First();
                var result = notesHandler.Find2WayDifferences(firstFiR, secondFiR, hgRepository);
                Assert.AreEqual(0, result.Count());
            }
        }
Пример #25
0
        public RepositorySetup(string userName, bool makeRepository)
        {
            Init(userName);

            ProjectFolder = new TemporaryFolder(RootFolder, ProjectName);

            if (makeRepository)
            {
                RepositorySetup.MakeRepositoryForTest(ProjectFolder.Path, userName, Progress);
            }
            else
            {
                // Remove the folder to make way for a clone which requires the folder to be not present.
                Directory.Delete(ProjectFolder.Path);
            }
            ProjectFolderConfig = new ProjectFolderConfiguration(ProjectFolder.Path);
        }
Пример #26
0
 public void SecondCheckin_Invalid_BacksOut()
 {
     using (var bob = new RepositorySetup("bob"))
     {
         bob.AddAndCheckinFile("test.chorusTest", "hello");
         bob.ChangeFile("test.chorusTest",ChorusTestFileHandler.GetInvalidContents());
         using (var cop = new CommitCop(bob.Repository, ChorusFileTypeHandlerCollection.CreateWithTestHandlerOnly(), bob.Progress))
         {
             Assert.IsFalse(string.IsNullOrEmpty(cop.ValidationResult));
             bob.Repository.Commit(false, "bad data");
         }
         Debug.WriteLine(bob.Repository.GetLog(-1));
         bob.AssertHeadCount(1);
         bob.AssertLocalRevisionNumber(2);
         bob.AssertFileContents("test.chorusTest", "hello");
     }
 }
Пример #27
0
 public void InitialFileCommit_Invalid_BacksOut()
 {
     using(var bob = new RepositorySetup("bob"))
     {
         bob.AddAndCheckinFile("validfile.chorustest", "valid contents");
         bob.ChangeFile("test.chorusTest", ChorusTestFileHandler.GetInvalidContents());
         using(var cop = new CommitCop(bob.Repository, ChorusFileTypeHandlerCollection.CreateWithTestHandlerOnly(), bob.Progress))
         {
             bob.Repository.AddAndCheckinFile("test.chorusTest");
             Assert.That(cop.ValidationResult, Is.StringContaining("Failed"));
         }
         Debug.WriteLine(bob.Repository.GetLog(-1));
         bob.AssertHeadCount(1);
         bob.AssertLocalRevisionNumber(2);
         bob.AssertFileDoesNotExistInRepository("test.chorusTest");
         bob.AssertFileExistsInRepository("validfile.chorustest");
     }
 }
Пример #28
0
 public void HasFileHandlers_ValidCommit_Validates_DoesNothing()
 {
     using(var bob = new RepositorySetup("bob"))
     {
         bob.AddAndCheckinFile("test.chorusTest", "hello");
         using(var cop = new CommitCop(bob.Repository, ChorusFileTypeHandlerCollection.CreateWithTestHandlerOnly(), bob.Progress))
         {
             bob.ChangeFile("test.chorusTest", "aloha");
             bob.AddAndCheckinFile("test2.chorusTest", "hi");
             Assert.IsNullOrEmpty(cop.ValidationResult);
         }
         bob.AssertHeadCount(1);
         bob.AssertLocalRevisionNumber(1);
         bob.AssertFileExistsInRepository("test2.chorusTest");
         bob.AssertFileContents("test.chorusTest", "aloha");
         bob.AssertFileContents("test2.chorusTest", "hi");
     }
 }
Пример #29
0
        public void LaunchDialog_ExampleForBob()
        {
            using(var setup = new RepositorySetup("pedro"))
            {
                Application.EnableVisualStyles();

                setup.Repository.SetKnownRepositoryAddresses(new RepositoryAddress[]
                                                                 {
                                                                     RepositoryAddress.Create("language depot", "http://*****:*****@hg-public.languagedepot.org"),
                                                                 });
                setup.Repository.SetDefaultSyncRepositoryAliases(new[] {"language depot"});

                using (var dlg = new SyncDialog(setup.ProjectFolderConfig,
                                                SyncUIDialogBehaviors.StartImmediatelyAndCloseWhenFinished,
                                                SyncUIFeatures.Minimal))
                {
                    dlg.ShowDialog();
                }
            }
        }
Пример #30
0
        public void LaunchDialog_GoodForCancelTesting()
        {
            using(var setup = new RepositorySetup("pedro"))
            {
                Application.EnableVisualStyles();

                setup.Repository.SetKnownRepositoryAddresses(new RepositoryAddress[]
                                                                 {
                                                                     RepositoryAddress.Create("language depot", "http://*****:*****@hg-public.languagedepot.org/tpi"),
                                                                 });
                setup.Repository.SetDefaultSyncRepositoryAliases(new[] { "language depot" });

                using (var dlg = new SyncDialog(setup.ProjectFolderConfig,
                                                SyncUIDialogBehaviors.StartImmediately,
                                                SyncUIFeatures.NormalRecommended))
                {
                    dlg.ShowDialog();
                }
            }
        }
Пример #31
0
        public RepositoryWithFilesSetup(string userName, string fileName, string fileContents)
        {
            Progress      = new MultiProgress(new IProgress[] { new ConsoleProgress(), _stringProgress });
            RootFolder    = new TemporaryFolder("ChorusTest-" + userName + "-" + Guid.NewGuid());
            ProjectFolder = new TemporaryFolder(RootFolder, "foo project");
            Console.WriteLine("TestRepository Created: {0}", RootFolder.Path);
            var p = ProjectFolder.Combine(fileName);

            File.WriteAllText(p, fileContents);
            UserFile = TempFile.TrackExisting(p);

            RepositorySetup.MakeRepositoryForTest(ProjectFolder.Path, userName, Progress);
            Init(userName);
            SyncOptions options = new SyncOptions();

            options.DoMergeWithOthers = false;
            options.DoPullFromOthers  = false;
            options.DoSendToOthers    = false;
            Synchronizer.SyncNow(options);
        }
Пример #32
0
        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 Find2WayDifferencesShouldReportOneChangeEvenWhenNoneArePresent()
 {
     // One 'change' reported, even for the exact same file.
     const string parent =
     @"<?xml version='1.0' encoding='utf-8'?>
     <ProjectLexiconSettings>
     </ProjectLexiconSettings>";
     using (var repositorySetup = new RepositorySetup("randy-" + Guid.NewGuid()))
     {
         repositorySetup.AddAndCheckinFile("some.plsx", parent);
         repositorySetup.ChangeFileAndCommit("some.plsx", parent, "change it");
         var hgRepository = repositorySetup.Repository;
         var allRevisions = (from rev in hgRepository.GetAllRevisions()
                             orderby rev.Number.LocalRevisionNumber
                             select rev).ToList();
         var first = allRevisions[0];
         var firstFiR = hgRepository.GetFilesInRevision(first).First();
         var result = _projectLexiconSettingsFileHandler.Find2WayDifferences(firstFiR, firstFiR, hgRepository);
         Assert.AreEqual(1, result.Count());
         Assert.AreEqual("Edited", result.First().ActionLabel);
     }
 }
Пример #34
0
        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();
            }
        }