コード例 #1
0
ファイル: CommitCop.cs プロジェクト: marksvc/chorus
 public CommitCop(HgRepository repository, ChorusFileTypeHandlerCollection handlers, IProgress progress)
 {
     _repository        = repository;
     _handlerCollection = handlers;
     _progress          = progress;
     ValidateModifiedFiles();
 }
コード例 #2
0
        public void CreateWithTestHandlerOnly_OnlyOneHandlerIsInTestCollection()
        {
            var handlers = ChorusFileTypeHandlerCollection.CreateWithTestHandlerOnly().Handlers;

            Assert.That(handlers, Has.Count.EqualTo(1));
            Assert.That(handlers.Select(x => x.GetType()), Has.Member(typeof(ChorusTestFileHandler)));
        }
コード例 #3
0
        public void LongWavFileIsFilteredOutAndNotInRepo()
        {
            using (var bob = new RepositorySetup("bob"))
            {
                var megabyteLongData = "long" + Environment.NewLine;
                while (megabyteLongData.Length < LargeFileFilter.Megabyte)
                {
                    megabyteLongData += megabyteLongData;
                }

                const string fileName = "big.wav";
                bob.ChangeFile(fileName, megabyteLongData);
                var fullPathname = Path.Combine(bob.ProjectFolderConfig.FolderPath, fileName);
                var pathToRepo   = bob.Repository.PathToRepo + Path.DirectorySeparatorChar;
                bob.Repository.TestOnlyAddSansCommit(fullPathname);
                var config = bob.ProjectFolderConfig;
                config.ExcludePatterns.Clear();
                config.IncludePatterns.Clear();
                config.IncludePatterns.Add("**.wav");

                var result = LargeFileFilter.FilterFiles(
                    bob.Repository,
                    config,
                    ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers());
                Assert.IsFalse(string.IsNullOrEmpty(result));
                var shortpath = fullPathname.Replace(pathToRepo, "");
                Assert.IsTrue(config.ExcludePatterns.Contains(shortpath));
                Assert.IsFalse(config.IncludePatterns.Contains(shortpath));
                bob.Repository.AddAndCheckinFiles(config.IncludePatterns, config.ExcludePatterns, "Some commit");
                bob.AssertFileDoesNotExistInRepository("big.wav");
            }
        }
コード例 #4
0
        public void CreateWithInstalledHandlers_HandlersFromAdditionalAssembly()
        {
            var handlers = ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers(
                new[] { SamplePluginPath }).Handlers;

            Assert.That(handlers.Select(x => x.GetType().Name), Has.Member("TestAFileTypeHandler"));
        }
コード例 #5
0
        public void NormallyExcludedNestedFileIsNotAddedByLargeFileFilter()
        {
            using (var bob = new RepositorySetup("bob"))
            {
                var megabyteLongData = "long" + Environment.NewLine;
                while (megabyteLongData.Length < LargeFileFilter.Megabyte)
                {
                    megabyteLongData += megabyteLongData;
                }

                var pathToRepo   = bob.Repository.PathToRepo + Path.DirectorySeparatorChar;
                var nestedFolder = Path.Combine(bob.Repository.PathToRepo, "nestedFolder");
                Directory.CreateDirectory(nestedFolder);
                const string largeVideoFilename = "whopper.mov";
                var          largeVideoPathname = Path.Combine("nestedFolder", largeVideoFilename);
                bob.ChangeFile(largeVideoPathname, megabyteLongData);
                bob.Repository.TestOnlyAddSansCommit(largeVideoPathname);

                var config = bob.ProjectFolderConfig;
                config.ExcludePatterns.Clear();
                config.ExcludePatterns.Add("**.mov");
                config.IncludePatterns.Clear();
                config.IncludePatterns.Add("**.*");

                var result = LargeFileFilter.FilterFiles(
                    bob.Repository,
                    config,
                    ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers());
                Assert.IsTrue(string.IsNullOrEmpty(result));

                var shortpath = largeVideoPathname.Replace(pathToRepo, "");
                Assert.IsFalse(config.ExcludePatterns.Contains(shortpath));
                Assert.IsFalse(config.IncludePatterns.Contains(shortpath));
            }
        }
コード例 #6
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));
            }
        }
コード例 #7
0
        public void LargeMp3FileIsNotAllowed()
        {
            using (var bob = new RepositorySetup("bob"))
            {
                const string fileName         = "whopper.Mp3";
                var          megabyteLongData = "long" + Environment.NewLine;
                while (megabyteLongData.Length < LargeFileFilter.Megabyte)
                {
                    megabyteLongData += megabyteLongData;
                }
                bob.ChangeFile(fileName, megabyteLongData);
                var fullPathname = Path.Combine(bob.ProjectFolderConfig.FolderPath, fileName);
                var pathToRepo   = bob.Repository.PathToRepo + Path.DirectorySeparatorChar;
                bob.Repository.TestOnlyAddSansCommit(fileName);
                var config = bob.ProjectFolderConfig;
                config.ExcludePatterns.Clear();
                config.IncludePatterns.Clear();
                LiftFolder.AddLiftFileInfoToFolderConfiguration(config);

                var result = LargeFileFilter.FilterFiles(
                    bob.Repository,
                    config,
                    ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers());
                Assert.IsFalse(string.IsNullOrEmpty(result));
                var shortpath = fullPathname.Replace(pathToRepo, "");
                Assert.IsTrue(config.ExcludePatterns.Contains(shortpath));
                Assert.IsFalse(config.IncludePatterns.Contains(shortpath));
            }
        }
コード例 #8
0
        public void NormallyExcludedFwdataFileIsNotAddedByLargeFileFilter()
        {
            using (var bob = new RepositorySetup("bob"))
            {
                var megabyteLongData = "long" + Environment.NewLine;
                while (megabyteLongData.Length < LargeFileFilter.Megabyte)
                {
                    megabyteLongData += megabyteLongData;
                }

                var          pathToRepo          = bob.Repository.PathToRepo + Path.DirectorySeparatorChar;
                const string largeFwdataFilename = "whopper.fwdata";
                var          largeFwdataPathname = Path.Combine(pathToRepo, largeFwdataFilename);
                bob.ChangeFile(largeFwdataPathname, megabyteLongData);
                bob.Repository.TestOnlyAddSansCommit(largeFwdataPathname);

                var config = bob.ProjectFolderConfig;
                config.ExcludePatterns.Clear();
                config.ExcludePatterns.Add("*.fwdata");
                config.IncludePatterns.Clear();
                config.IncludePatterns.Add("*.*");

                var result = LargeFileFilter.FilterFiles(
                    bob.Repository,
                    config,
                    ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers());
                Assert.That(result, Is.Null.Or.Empty);

                var shortpath = largeFwdataPathname.Replace(pathToRepo, "");
                Assert.That(config.ExcludePatterns, Does.Not.Contain(shortpath));
                Assert.That(config.IncludePatterns, Does.Not.Contain(shortpath));
            }
        }
コード例 #9
0
 public void FixtureSetup()
 {
     _userLexiconSettingsFileHandler =
         (from handler in ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers().Handlers
          where handler.GetType().Name == "UserLexiconSettingsFileHandler"
          select handler).First();
 }
コード例 #10
0
        public void MakeSureOnlyOneHandlerIsInTestCollection()
        {
            var handlers = ChorusFileTypeHandlerCollection.CreateWithTestHandlerOnly().Handlers;

            Assert.AreEqual(1, handlers.Count());
            Assert.IsNotNull((from handler in handlers
                              where handler.GetType().Name == "ChorusTestFileHandler"
                              select handler).FirstOrDefault());
        }
コード例 #11
0
        public static int Main(string[] args)
        {
            try
            {
                string ourFilePath;
                string commonFilePath;
                string theirFilePath;

                if (Platform.IsMono)
                {
                    ourFilePath    = args[0];
                    commonFilePath = args[1];
                    theirFilePath  = args[2];
                }
                else
                {
                    // Convert the input arguments from cp1252 -> utf8 -> ucs2
                    // It always seems to be 1252, even when the input code page is actually something else. CP 2012-03
                    // var inputEncoding = Console.InputEncoding;
                    var inputEncoding = Encoding.GetEncoding(1252);
                    ourFilePath    = Encoding.UTF8.GetString(inputEncoding.GetBytes(args[0]));
                    commonFilePath = Encoding.UTF8.GetString(inputEncoding.GetBytes(args[1]));
                    theirFilePath  = Encoding.UTF8.GetString(inputEncoding.GetBytes(args[2]));
                    Console.WriteLine("ChorusMerge: Input encoding {0}",
                                      inputEncoding.EncodingName);
                }

                //this was originally put here to test if console writes were making it out to the linux log or not
                Console.WriteLine("ChorusMerge: {0}, {1}, {2}", ourFilePath, commonFilePath, theirFilePath);

#if RUNINDEBUGGER
                var order = new MergeOrder(ourFilePath, commonFilePath, theirFilePath, new MergeSituation(ourFilePath, "Me", "CHANGETHIS", "YOU", "CHANGETHIS", MergeOrder.ConflictHandlingModeChoices.WeWin));
#else
                MergeOrder order = MergeOrder.CreateUsingEnvironmentVariables(ourFilePath, commonFilePath, theirFilePath);
#endif
                var handlers = ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers();
                var handler  = handlers.GetHandlerForMerging(order.pathToOurs);

                //DispatchingMergeEventListener listenerDispatcher = new DispatchingMergeEventListener();
                //using (HumanLogMergeEventListener humanListener = new HumanLogMergeEventListener(order.pathToOurs + ".ChorusNotes.txt"))
                using (var xmlListener = new ChorusNotesMergeEventListener(order.pathToOurs + ".NewChorusNotes"))
                {
//                    listenerDispatcher.AddEventListener(humanListener);
//                    listenerDispatcher.AddEventListener(xmlListener);
                    order.EventListener = xmlListener;

                    handler.Do3WayMerge(order);
                }
            }
            catch (Exception e)
            {
                ErrorWriter.WriteLine("ChorusMerge Error: " + e.Message);
                ErrorWriter.WriteLine(e.StackTrace);
                return(1);
            }
            return(0);           //no error
        }
コード例 #12
0
ファイル: Synchronizer.cs プロジェクト: nishanth2143/chorus
 public Synchronizer(string localRepositoryPath, ProjectFolderConfiguration project, IProgress progress)
 {
     _progress              = progress;
     _project               = project;
     _localRepositoryPath   = localRepositoryPath;
     _handlers              = ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers();
     ExtraRepositorySources = new List <RepositoryAddress>();
     ExtraRepositorySources.Add(RepositoryAddress.Create(RepositoryAddress.HardWiredSources.UsbKey, "USB flash drive", false));
 }
コード例 #13
0
        public void SmallFileInNonExcludedFolderNotFilteredByExclusionAtDeeperNesting()
        {
            //Put a small file in [repo]\Cache and a large file in [repo]\foo\SomeLayer\Cache
            //exclude \foo\**\Cache, make sure that [repo]\Cache\smallFile was not filtered out.
            // Make sure that [repo]\foo\SomeLayer\Cache\largfile was not reported as being a large file.
            using (var bob = new RepositorySetup("bob"))
            {
                var smallData = "small" + Environment.NewLine;
                while (smallData.Length < LargeFileFilter.Megabyte / 3)
                {
                    smallData += smallData;
                }
                var pathToRepo  = bob.Repository.PathToRepo + Path.DirectorySeparatorChar;
                var cacheAtRoot = Path.Combine(bob.Repository.PathToRepo, "Cache");
                Directory.CreateDirectory(cacheAtRoot);
                const string smallVideoFilename       = "dinky.mov";
                var          smallNestedVideoPathname = Path.Combine(cacheAtRoot, smallVideoFilename);
                bob.ChangeFile(smallNestedVideoPathname, smallData);
                bob.Repository.TestOnlyAddSansCommit(smallNestedVideoPathname);

                var megabyteLongData = "long" + Environment.NewLine;
                while (megabyteLongData.Length < LargeFileFilter.Megabyte)
                {
                    megabyteLongData += megabyteLongData;
                }
                var fooAtRoot = Path.Combine(bob.Repository.PathToRepo, "foo");
                Directory.CreateDirectory(fooAtRoot);
                var firstLayerBelowFoo = Path.Combine(fooAtRoot, "SomeLayer");
                Directory.CreateDirectory(firstLayerBelowFoo);
                var nestedCacheFolder = Path.Combine(firstLayerBelowFoo, "Cache");
                Directory.CreateDirectory(nestedCacheFolder);
                const string largeVideoFilename       = "whopper.mov";
                var          largeNestedVideoPathname = Path.Combine(nestedCacheFolder, largeVideoFilename);
                bob.ChangeFile(largeNestedVideoPathname, megabyteLongData);
                bob.Repository.TestOnlyAddSansCommit(largeNestedVideoPathname);

                var config = bob.ProjectFolderConfig;
                config.ExcludePatterns.Clear();
                config.ExcludePatterns.Add(Path.Combine("foo", Path.Combine("**", "Cache")));
                config.IncludePatterns.Clear();
                config.IncludePatterns.Add("**.*");

                var result = LargeFileFilter.FilterFiles(
                    bob.Repository,
                    config,
                    ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers());
                Assert.True(string.IsNullOrEmpty(result), @"Cache folder at root was improperly filtered by foo\**\Cache");

                var shortpath = largeNestedVideoPathname.Replace(pathToRepo, null);
                Assert.IsFalse(config.ExcludePatterns.Contains(shortpath));
                Assert.IsFalse(config.IncludePatterns.Contains(shortpath));

                shortpath = smallNestedVideoPathname.Replace(pathToRepo, null);
                Assert.IsFalse(config.ExcludePatterns.Contains(shortpath));
                Assert.IsFalse(config.IncludePatterns.Contains(shortpath));
            }
        }
コード例 #14
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");
         }
         bob.AssertLocalRevisionNumber(0);
     }
 }
コード例 #15
0
 public ChangesInRevisionModel(RevisionInspector revisionInspector,
                               ChangedRecordSelectedEvent changedRecordSelectedEventToRaise,
                               NavigateToRecordEvent navigateToRecordEventToRaise,
                               RevisionSelectedEvent revisionSelectedEventToSubscribeTo,
                               ChorusFileTypeHandlerCollection fileHandlers)
 {
     _revisionInspector = revisionInspector;
     _changedRecordSelectedEventToRaise = changedRecordSelectedEventToRaise;
     _navigateToRecordEvent             = navigateToRecordEventToRaise;
     _fileHandlers = fileHandlers;
     revisionSelectedEventToSubscribeTo.Subscribe(SetRevision);
 }
コード例 #16
0
ファイル: CommitCopTests.cs プロジェクト: sillsdev/chorus
 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");
             Assert.That(cop.ValidationResult, Is.Null.Or.Empty);
         }
         bob.AssertLocalRevisionNumber(0);
     }
 }
コード例 #17
0
        public ChangeReportView(ChorusFileTypeHandlerCollection handlers, ChangedRecordSelectedEvent changedRecordSelectedEvent, HgRepository repository, IEnumerable <IWritingSystem> writingSystems)
        {
            this.Font   = SystemFonts.MessageBoxFont;
            _handlers   = handlers;
            _repository = repository;
            InitializeComponent();
            _normalChangeDescriptionRenderer.Font = SystemFonts.MessageBoxFont;
            changedRecordSelectedEvent.Subscribe(r => LoadReport(r));
#if !MONO
            _normalChangeDescriptionRenderer.Navigated += webBrowser1_Navigated;
#endif
            _styleSheet = CreateStyleSheet(writingSystems);
        }
コード例 #18
0
        public void CreateWithInstalledHandlers_ContainsTestAFileTypeHandler()
        {
            string samplePluginDllPath  = SamplePluginPath;
            var    samplePluginPathname = Path.Combine(BaseDir, "Tests-ChorusPlugin.dll");

            if (File.Exists(samplePluginDllPath))
            {
                File.Copy(samplePluginDllPath, samplePluginPathname, true);
            }

            var handlers = ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers().Handlers;

            Assert.That(handlers.Select(x => x.GetType().Name), Has.Member("TestAFileTypeHandler"));
        }
コード例 #19
0
        public void LargeFileInNonExcludedFolderFiltered()
        {
            //Put a large file in [repo]\Cache and in [repo]\foo\SomeLayer\Cache
            //exclude \foo\**\Cache, make sure that [repo]\Cache\largeFile was filtered out.
            using (var bob = new RepositorySetup("bob"))
            {
                var megabyteLongData = "long" + Environment.NewLine;
                while (megabyteLongData.Length < LargeFileFilter.Megabyte)
                {
                    megabyteLongData += megabyteLongData;
                }
                var pathToRepo  = bob.Repository.PathToRepo + Path.DirectorySeparatorChar;
                var cacheAtRoot = Path.Combine(bob.Repository.PathToRepo, "Cache");
                Directory.CreateDirectory(cacheAtRoot);
                const string biggieNonexcludedFileName            = "biggie.mov";
                var          biggieNestedNonExcludedVideoPathname = Path.Combine(cacheAtRoot, biggieNonexcludedFileName);
                bob.ChangeFile(biggieNestedNonExcludedVideoPathname, megabyteLongData);
                bob.Repository.TestOnlyAddSansCommit(biggieNestedNonExcludedVideoPathname);

                var fooAtRoot = Path.Combine(bob.Repository.PathToRepo, "foo");
                Directory.CreateDirectory(fooAtRoot);
                var firstLayerBelowFoo = Path.Combine(fooAtRoot, "SomeLayer");
                Directory.CreateDirectory(firstLayerBelowFoo);
                var nestedCacheFolder = Path.Combine(firstLayerBelowFoo, "Cache");
                Directory.CreateDirectory(nestedCacheFolder);
                const string largeVideoFilename       = "whopper.mov";
                var          largeNestedVideoPathname = Path.Combine(nestedCacheFolder, largeVideoFilename);
                bob.ChangeFile(largeNestedVideoPathname, megabyteLongData);
                bob.Repository.TestOnlyAddSansCommit(largeNestedVideoPathname);

                var config = bob.ProjectFolderConfig;
                config.ExcludePatterns.Clear();
                config.ExcludePatterns.Add(Path.Combine("foo", Path.Combine("**", "Cache")));
                config.IncludePatterns.Clear();
                config.IncludePatterns.Add("**.*");

                var result = LargeFileFilter.FilterFiles(
                    bob.Repository,
                    config,
                    ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers());
                Assert.That(result, Is.Not.Null.And.Not.Empty, @"Cache folder at root wasn't properly filtered by large file filer in [repo]\Cache\biggie.mov");
                var shortpath = largeNestedVideoPathname.Replace(pathToRepo, null);
                Assert.That(config.ExcludePatterns, Does.Not.Contain(shortpath));
                Assert.That(config.IncludePatterns, Does.Not.Contain(shortpath));

                shortpath = biggieNestedNonExcludedVideoPathname.Replace(pathToRepo, null);
                Assert.That(config.ExcludePatterns, Does.Contain(shortpath));
                Assert.That(config.IncludePatterns, Does.Not.Contain(shortpath));
            }
        }
コード例 #20
0
        public void TestFixtureSetup()
        {
            _handlersColl = ChorusFileTypeHandlerCollection.CreateWithTestHandlerOnly();
            var testHandler = (from handler in _handlersColl.Handlers
                               select handler).First();

            _goodData = "good" + Environment.NewLine;
            for (var i = 1; i < testHandler.MaximumFileSize; i += _goodData.Length)
            {
                _goodData += _goodData;
            }

            _longData = _goodData + _goodData;
        }
コード例 #21
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());
            }
        }
コード例 #22
0
ファイル: CommitCopTests.cs プロジェクト: sillsdev/chorus
 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.That(cop.ValidationResult, Is.Not.Null.And.Not.Empty);
             bob.Repository.Commit(false, "bad data");
         }
         Debug.WriteLine(bob.Repository.GetLog(-1));
         bob.AssertHeadCount(1);
         bob.AssertLocalRevisionNumber(2);
         bob.AssertFileContents("test.chorusTest", "hello");
     }
 }
コード例 #23
0
ファイル: CommitCopTests.cs プロジェクト: sillsdev/chorus
 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.That(cop.ValidationResult, Is.Null.Or.Empty);
         }
         bob.AssertHeadCount(1);
         bob.AssertLocalRevisionNumber(1);
         bob.AssertFileExistsInRepository("test2.chorusTest");
         bob.AssertFileContents("test.chorusTest", "aloha");
         bob.AssertFileContents("test2.chorusTest", "hi");
     }
 }
コード例 #24
0
ファイル: CommitCopTests.cs プロジェクト: sillsdev/chorus
 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, Does.Contain("Failed"));
         }
         Debug.WriteLine(bob.Repository.GetLog(-1));
         bob.AssertHeadCount(1);
         bob.AssertLocalRevisionNumber(2);
         bob.AssertFileDoesNotExistInRepository("test.chorusTest");
         bob.AssertFileExistsInRepository("validfile.chorustest");
     }
 }
コード例 #25
0
ファイル: CommitCopTests.cs プロジェクト: sillsdev/chorus
        public void VeryFirstCommit_Invalid_Throws()
        {
            string validationResult = null;

            Assert.Throws <ApplicationException>(() =>
            {
                using (var bob = new RepositorySetup("bob"))
                {
                    bob.ChangeFile("test.chorusTest", ChorusTestFileHandler.GetInvalidContents());
                    using (var cop = new CommitCop(bob.Repository, ChorusFileTypeHandlerCollection.CreateWithTestHandlerOnly(), bob.Progress))
                    {
                        bob.Repository.AddAndCheckinFile("test.chorusTest");
                        // ReSharper disable once ReturnValueOfPureMethodIsNotUsed - SUT
                        validationResult = cop.ValidationResult;
                    }
                }
            });
            Assert.That(validationResult, Does.Contain("Failed"));
        }
コード例 #26
0
        public void FixtureSetup()
        {
            _handler = (ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers().Handlers.Where(
                            handler => handler.GetType().Name == "LdmlFileHandler")).First();

            _goodXmlTempFile = TempFile.WithExtension(".ldml");
#if MONO
            File.WriteAllText(_goodXmlTempFile.Path, "<?xml version='1.0' encoding='utf-8'?>" + Environment.NewLine + "<ldml>" + Environment.NewLine + "</ldml>");
#else
            File.WriteAllText(_goodXmlTempFile.Path, "<?xml version='1.0' encoding='utf-8'?>" + Environment.NewLine + "<ldml />");
#endif
            _illformedXmlTempFile = TempFile.WithExtension(".ldml");
            File.WriteAllText(_illformedXmlTempFile.Path, "<?xml version='1.0' encoding='utf-8'?>" + Environment.NewLine + "<ldml>");

            _goodXmlButNotLdmlTempFile = TempFile.WithExtension(".ldml");
            File.WriteAllText(_goodXmlButNotLdmlTempFile.Path, "<?xml version='1.0' encoding='utf-8'?>" + Environment.NewLine + "<nonldmlstuff />");

            _nonXmlTempFile = TempFile.WithExtension(".txt");
            File.WriteAllText(_nonXmlTempFile.Path, "This is not an ldml file." + Environment.NewLine);
        }
コード例 #27
0
        public void FixtureSetup()
        {
            _handler = (ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers().Handlers.Where(
                            handler => handler.GetType().Name == "ProjectLexiconSettingsFileHandler")).First();

            _goodXmlTempFile = TempFile.WithExtension(".plsx");
#if MONO
            File.WriteAllText(_goodXmlTempFile.Path, "<?xml version='1.0' encoding='utf-8'?>" + Environment.NewLine + "<ProjectLexiconSettings>" + Environment.NewLine + "</ProjectLexiconSettings>");
#else
            File.WriteAllText(_goodXmlTempFile.Path, "<?xml version='1.0' encoding='utf-8'?>" + Environment.NewLine + "<ProjectLexiconSettings />");
#endif
            _illformedXmlTempFile = TempFile.WithExtension(".plsx");
            File.WriteAllText(_illformedXmlTempFile.Path, "<?xml version='1.0' encoding='utf-8'?>" + Environment.NewLine + "<ProjectLexiconSettings>");

            _goodXmlButNotProjectLexiconSettingsTempFile = TempFile.WithExtension(".plsx");
            File.WriteAllText(_goodXmlButNotProjectLexiconSettingsTempFile.Path, "<?xml version='1.0' encoding='utf-8'?>" + Environment.NewLine + "<nonProjectLexiconSettingsstuff />");

            _nonXmlTempFile = TempFile.WithExtension(".txt");
            File.WriteAllText(_nonXmlTempFile.Path, "This is not a project lexicon settings file." + Environment.NewLine);
        }
コード例 #28
0
        public void LargeFileInExcludedDeeplyNestedPathIsNotFilteredOut()
        {
            using (var bob = new RepositorySetup("bob"))
            {
                var megabyteLongData = "long" + Environment.NewLine;
                while (megabyteLongData.Length < LargeFileFilter.Megabyte)
                {
                    megabyteLongData += megabyteLongData;
                }

                var pathToRepo = bob.Repository.PathToRepo + Path.DirectorySeparatorChar;
                var firstLayer = Path.Combine(bob.Repository.PathToRepo, "FirstLayer");
                Directory.CreateDirectory(firstLayer);
                var secondLayer = Path.Combine(firstLayer, "SecondLayer");
                Directory.CreateDirectory(secondLayer);
                var nestedFolder = Path.Combine(secondLayer, "Cache");
                Directory.CreateDirectory(nestedFolder);
                const string largeVideoFilename = "whopper.mov";
                var          largeVideoPathname = Path.Combine(nestedFolder, largeVideoFilename);
                bob.ChangeFile(largeVideoPathname, megabyteLongData);
                bob.Repository.TestOnlyAddSansCommit(largeVideoPathname);

                var config = bob.ProjectFolderConfig;
                config.ExcludePatterns.Clear();
                config.ExcludePatterns.Add(Path.Combine("FirstLayer", Path.Combine("**", "Cache")));
                config.IncludePatterns.Clear();
                config.IncludePatterns.Add("**.*");

                var result = LargeFileFilter.FilterFiles(
                    bob.Repository,
                    config,
                    ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers());
                Assert.That(result, Is.Null.Or.Empty);

                var shortpath = largeVideoPathname.Replace(pathToRepo, "");
                Assert.That(config.ExcludePatterns, Does.Not.Contain(shortpath));
                Assert.That(config.IncludePatterns, Does.Not.Contain(shortpath));
            }
        }
コード例 #29
0
        public static void Inject(ContainerBuilder builder, string projectPath, SyncUIFeatures syncDialogFeatures)
        {
            //TODO: shouldn't we have people provide the whole project configuration? Otherwise, we have an empty set of
            //include/exlcude patterns, so new files aren't going to get added.  Maybe if we're going to do that, it
            //doesn't make sense for this to do the injecting at all... maybe the client should do it.  Similar issue
            //below, with SyncUIFeatures

            builder.Register <ProjectFolderConfiguration>(
                c => new ProjectFolderConfiguration(projectPath)).InstancePerLifetimeScope();

            builder.RegisterType <NavigateToRecordEvent>().InstancePerLifetimeScope();

            builder.RegisterInstance(new NullProgress()).As <IProgress>();
            builder.Register <Synchronizer>(c => Chorus.sync.Synchronizer.FromProjectConfiguration(
                                                c.Resolve <ProjectFolderConfiguration>(), new NullProgress()));
            builder.Register <HgRepository>(c => HgRepository.CreateOrUseExisting(projectPath, new NullProgress())).InstancePerLifetimeScope();


            //this is a sad hack... I don't know how to simly override the default using the container,
            //which I'd rather do, and just leave this to pushing in the "normal"
            builder.Register <SyncUIFeatures>(c => syncDialogFeatures).As <SyncUIFeatures>().SingleInstance();

            builder.RegisterInstance(new EmbeddedMessageContentHandlerRepository());

            builder.RegisterInstance(ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers()).SingleInstance();

            builder.RegisterType <SyncPanel>().InstancePerLifetimeScope();
            builder.RegisterType <SyncControlModel>().InstancePerLifetimeScope();
            builder.RegisterType <SyncDialog>().InstancePerDependency();           //NB: was FactoryScoped() before switch to autofac 2, which corresponds to this InstancePerDependency
            builder.RegisterGeneratedFactory <SyncDialog.Factory>().InstancePerLifetimeScope();
            builder.RegisterType <Chorus.UI.Misc.TroubleshootingView>().InstancePerLifetimeScope();

            RegisterSyncStuff(builder);
            RegisterReviewStuff(builder);
            RegisterSettingsStuff(builder);

            InjectNotesUI(builder);
        }
コード例 #30
0
        public void FixtureSetup()
        {
            _handler = (ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers().Handlers.Where(
                            handler => handler.GetType().Name == "LdmlFileHandler")).First();

            _goodXmlTempFile = TempFile.WithExtension(".ldml");
            var nl = Environment.NewLine;

            File.WriteAllText(_goodXmlTempFile.Path, Platform.IsMono ?
                              $"<?xml version='1.0' encoding='utf-8'?>{nl}<ldml>{nl}</ldml>" :
                              $"<?xml version='1.0' encoding='utf-8'?>{nl}<ldml />");
            _illformedXmlTempFile = TempFile.WithExtension(".ldml");
            File.WriteAllText(_illformedXmlTempFile.Path,
                              $"<?xml version='1.0' encoding='utf-8'?>{nl}<ldml>");

            _goodXmlButNotLdmlTempFile = TempFile.WithExtension(".ldml");
            File.WriteAllText(_goodXmlButNotLdmlTempFile.Path,
                              $"<?xml version='1.0' encoding='utf-8'?>{nl}<nonldmlstuff />");

            _nonXmlTempFile = TempFile.WithExtension(".txt");
            File.WriteAllText(_nonXmlTempFile.Path,
                              $"This is not an ldml file.{nl}");
        }