Пример #1
0
        private static void SaveMongoDb(Options.SaveOptions options)
        {
            if (!options.Project.StartsWith("sf_"))
            {
                options.Project = "sf_" + options.Project;
            }

            var patchFiles = Directory.GetFiles(MongoHelper.GetMongoPatchDir(options.ModelVersion.ToString()), "*.patch");
            var lastNumber = 0;

            if (patchFiles != null && patchFiles.Length > 0)
            {
                Array.Sort(patchFiles);
                var patchNoStr = Path.GetFileName(patchFiles[patchFiles.Length - 1]).Substring(0, 4);
                lastNumber = int.Parse(patchNoStr);
            }
            if (_mongoHelper == null)
            {
                _mongoHelper = new MongoHelper(options.Project, true, false);
            }
            _mongoHelper.SaveDatabase(MongoHelper.GetMongoPatchDir(options.ModelVersion.ToString()),
                                      options.ModelVersion.ToString(), options.CommitMsg, lastNumber + 1);

            Console.WriteLine("Successfully saved mongo database");
        }
Пример #2
0
        private static void Merge(Options.MergeOptions options)
        {
            RobustIO.DeleteDirectoryAndContents(options.WorkDir);
            Settings.TempDir = options.WorkDir;

            // restore previous data
            var restoreOptions = new Options.RestoreOptions(options);

            RestoreLanguageDepot(restoreOptions);
            RestoreMongoDb(restoreOptions);

            // run merge
            LfMergeHelper.Run($"--project {options.Project} --clone --action=Synchronize");
            Console.WriteLine("Successfully merged test data");

            // save merged data
            var saveOptions = new Options.SaveOptions(options)
            {
                WorkDir   = Path.Combine(options.WorkDir, "LanguageDepot"),
                CommitMsg = options.CommitMsg ?? "Merged test data"
            };

            SaveLanguageDepot(saveOptions);
            SaveLanguageDepotNoOpPatchIfNecessary(options.ModelVersion, options.LanguageDepotVersion + 1);
            SaveMongoDb(saveOptions);
        }
Пример #3
0
        private static void SaveLanguageDepot(Options.SaveOptions options)
        {
            var patchDir = Path.Combine(Settings.DataDir, options.ModelVersion.ToString());
            var hgDir    = string.IsNullOrEmpty(options.WorkDir)
                                ? Path.Combine(Settings.TempDir, "LanguageDepot")
                                : options.WorkDir;

            Directory.CreateDirectory(patchDir);

            var output = Run("hg", "log --template \"{rev} \"", hgDir);
            var revs   = output.Trim().Trim('\r', '\n').Split(' ').Reverse();
            var count  = 0;

            foreach (var rev in revs)
            {
                var patchFile = Path.Combine(patchDir, $"r{rev}.patch");
                if (File.Exists(patchFile))
                {
                    continue;
                }

                Run("hg", $"export -r {rev} --output {patchFile}", hgDir);
                Console.WriteLine($"Saved file {patchFile}");
                count++;
            }

            if (count > 0)
            {
                Console.WriteLine($"Successfully saved language depot patches in {patchDir}");
            }
        }
Пример #4
0
        private static void Save(Options.SaveOptions options)
        {
            Settings.TempDir = options.WorkDir;

            if (options.SaveLanguageDepot)
            {
                SaveLanguageDepot(options);
            }

            if (!options.SaveMongoDb)
            {
                return;
            }

            MongoHelper.Initialize(options.ModelVersion.ToString());
            SaveMongoDb(options);
        }