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();
            }
        }
Example #2
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'?>
<UserLexiconSettings>
</UserLexiconSettings>";
            const string child =
                @"<?xml version='1.0' encoding='utf-8'?>
<UserLexiconSettings>
<WritingSystems />
</UserLexiconSettings>";

            using (var repositorySetup = new RepositorySetup("randy-" + Guid.NewGuid()))
            {
                repositorySetup.AddAndCheckinFile("some.ulsx", parent);
                repositorySetup.ChangeFileAndCommit("some.ulsx", 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    = _userLexiconSettingsFileHandler.Find2WayDifferences(firstFiR, secondFiR, hgRepository);
                Assert.AreEqual(1, result.Count());
                Assert.AreEqual("Edited", result.First().ActionLabel);
            }
        }
        public void Find2WayDifferencesShouldReportThreeChanges()
        {
            const string parent =
                @"<?xml version='1.0' encoding='utf-8'?>
<AdditionalFields>
<CustomField class='WfiWordform' key='WfiWordformCertified' name='Certified' type='Boolean' />
<CustomField class='WfiWordform' key='WfiWordformGoner' name='Goner' type='Boolean' />
<CustomField class='WfiWordform' key='WfiWordformDirtball' name='Dirtball' type='Boolean' />
</AdditionalFields>";
            // One deletion, one change, and one insertion, and one unchanged.
            const string child =
                @"<?xml version='1.0' encoding='utf-8'?>
<AdditionalFields>
<CustomField class='WfiWordform' key='WfiWordformCertified' name='Certified' type='Boolean' />
<CustomField class='WfiWordform' key='WfiWordformDirtball' name='Dirtball' type='Integer' />
<CustomField class='WfiWordform' key='WfiWordformNewby' name='Newby' type='Boolean' />
</AdditionalFields>";

            using (var repositorySetup = new RepositorySetup("randy"))
            {
                repositorySetup.AddAndCheckinFile(SharedConstants.CustomPropertiesFilename, parent);
                repositorySetup.ChangeFileAndCommit(SharedConstants.CustomPropertiesFilename, 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(3, result.Count);
            }
        }
Example #4
0
 public void FileDeletedLocallyAndChangedRemotelyKeepsChanged()
 {
     using (var localRepo = new RepositorySetup("unbundleTests"))
     {
         var localFilePath = localRepo.ProjectFolder.GetNewTempFile(true).Path;
         localRepo.AddAndCheckinFile(localFilePath, "file to change and delete");
         using (var remoteRepo = new RepositorySetup("remote", localRepo))
         {
             remoteRepo.CheckinAndPullAndMerge();
             var remoteFilePath = Path.Combine(remoteRepo.ProjectFolder.Path, Path.GetFileName(localFilePath));
             Assert.That(File.Exists(remoteFilePath));                     // Make sure that we have a file to delete.
             File.Delete(remoteFilePath);
             remoteRepo.SyncWithOptions(new SyncOptions {
                 CheckinDescription = "delete file", DoMergeWithOthers = false, DoPullFromOthers = false, DoSendToOthers = false
             });
             Assert.That(!File.Exists(remoteFilePath));                     // Make sure we actually got rid of it.
             localRepo.ChangeFileAndCommit(localFilePath, "new file contents", "changed the file");
             localRepo.CheckinAndPullAndMerge(remoteRepo);
             Assert.That(File.Exists(localFilePath), Is.True, "Did not keep changed file.");
             var chorusNotesPath = localFilePath + ".ChorusNotes";
             Assert.That(File.Exists(chorusNotesPath), "Did not record conflict");
             AssertThatXmlIn.File(chorusNotesPath).HasAtLeastOneMatchForXpath("//annotation[@class='mergeconflict']");
         }
     }
 }
        public void 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);
            }
        }
Example #6
0
        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);
            }
        }
        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);
            }
        }
Example #8
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);
            }
        }
Example #9
0
        public void SampleDiff()
        {
            const string parent =
                @"<?xml version='1.0' encoding='utf-8'?>
<CheckList>
<CmPossibilityList guid='06425922-3258-4094-a9ec-3c2fe5b52b39'>
				<Name>
					<AUni
						ws='en'>Proper names</AUni>
				</Name>
</CmPossibilityList>
</CheckList>";

            var child = parent.Replace("Proper names", "My Proper names");

            using (var repositorySetup = new RepositorySetup("randy"))
            {
                repositorySetup.AddAndCheckinFile("Sample." + SharedConstants.List, parent);
                repositorySetup.ChangeFileAndCommit("Sample." + SharedConstants.List, 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);
            }
        }
Example #10
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());
            }
        }
 public void SynchNow_OnDefaultBranchAndAnotherBranchExists_DoesNotMergeWithIt()
 {
     using (var repo = new RepositorySetup("bob"))
     {
         repo.AddAndCheckinFile("test.txt", "hello");
         repo.AssertHeadCount(1);
         repo.ChangeFileOnNamedBranchAndComeBack("test.txt", "blah", "mybranch");
         //NB: this used to pass prior to hg 1.5, but, well, it shouldn't!
         //	Shouldn't there be two heads after the branch, above? (jh, April 2010)
         //			repo.AssertHeadCount(1);
         repo.ChangeFileAndCommit("test.txt", "hello there", "second");
         repo.AssertHeadCount(2);
         repo.CheckinAndPullAndMerge();
         repo.AssertHeadCount(2);
     }
 }
        public void Sync_ExistingRejectChangeSet_NotMergedIn()
        {
            using (var bob = new RepositorySetup("bob"))
            {
                bob.AddAndCheckinFile("test.txt", "original");

                bob.CreateRejectForkAndComeBack();

                bob.ChangeFileAndCommit("test.txt", "ok", "goodGuy");                 //move on so we have two distinct branches
                bob.AssertHeadCount(2);

                bob.CheckinAndPullAndMerge(null);

                Assert.AreEqual("goodGuy", bob.Repository.GetRevisionWorkingSetIsBasedOn().Summary);
                bob.AssertLocalRevisionNumber(3);
                bob.AssertHeadCount(2);
            }
        }
Example #13
0
        public void SampleDiff()
        {
            const string parent =
                @"<?xml version='1.0' encoding='utf-8'?>
<Lexicon>
<header>
<LexDb guid='06425922-3258-4094-a9ec-3c2fe5b52b39' >
	  <Introduction>
		<StText guid='45b78bcf-2400-48d5-a9c1-973447d36d4e'>
		  <DateModified val='2011-2-2 19:39:28.829' />
		  <Paragraphs>
			<ownseq class='StTxtPara' guid='9edbb6e1-2bdd-481c-b84d-26c69f22856c'>
			  <ParseIsCurrent val='False' />
			</ownseq>
		  </Paragraphs>
		</StText>
	  </Introduction>
</LexDb>
</header>
<LexEntry guid='016f2759-ed12-42a5-abcb-7fe3f53d05b0' />
</Lexicon>";

            var child = parent.Replace("False", "True");

            using (var repositorySetup = new RepositorySetup("randy"))
            {
                repositorySetup.AddAndCheckinFile(string.Format("{0}_01.{1}", SharedConstants.Lexicon, SharedConstants.Lexdb), parent);
                repositorySetup.ChangeFileAndCommit(string.Format("{0}_01.{1}", SharedConstants.Lexicon, SharedConstants.Lexdb), 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);
            }
        }
Example #14
0
        public void Find2WayDifferencesShouldReportOneChangeEvenWhenNoneArePresent()
        {
            // One 'change' reported, even for the exact same file.
            const string parent =
                @"<?xml version='1.0' encoding='utf-8'?>
<UserLexiconSettings>
</UserLexiconSettings>";

            using (var repositorySetup = new RepositorySetup("randy-" + Guid.NewGuid()))
            {
                repositorySetup.AddAndCheckinFile("some.ulsx", parent);
                repositorySetup.ChangeFileAndCommit("some.ulsx", 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   = _userLexiconSettingsFileHandler.Find2WayDifferences(firstFiR, firstFiR, hgRepository);
                Assert.AreEqual(1, result.Count());
                Assert.AreEqual("Edited", result.First().ActionLabel);
            }
        }
        public void Find2WayDifferencesShouldReportOneChange()
        {
            const string parent = "{\"modelversion\": 7000000}";
            // One change.
            const string child = "{\"modelversion\": 7000002}";

            using (var repositorySetup = new RepositorySetup("randy"))
            {
                repositorySetup.AddAndCheckinFile("FLExProject.ModelVersion", parent);
                repositorySetup.ChangeFileAndCommit("FLExProject.ModelVersion", 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);
                Assert.IsInstanceOf(typeof(FieldWorksModelVersionUpdatedReport), result[0]);
            }
        }
        public void SampleDiff()
        {
            const string parent =
                @"<?xml version='1.0' encoding='utf-8'?>
<ReferenceSystem>
	<ScrRefSystem guid='0a0be0c1-39c4-44d4-842e-231680c7cd56' >
		<Books>
			<ScrBookRef guid='51caa4a0-8cd1-4c66-acac-7daead917510'>
				<BookName>
					<AUni ws='en'>Genesis</AUni>
				</BookName>
			</ScrBookRef>
		</Books>
	</ScrRefSystem>
</ReferenceSystem>";

            var child = parent.Replace("Genesis", "Startup");

            using (var repositorySetup = new RepositorySetup("randy"))
            {
                repositorySetup.AddAndCheckinFile(SharedConstants.ScriptureReferenceSystemFilename, parent);
                repositorySetup.ChangeFileAndCommit(SharedConstants.ScriptureReferenceSystemFilename, 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);
            }
        }