def main(unused_argv): project = db_client.MakeProjectContext(create_project=True, acquire_lock=False) try: if FLAGS.install_on_db_only: moe_app.RUN.ui.Info(( 'Project %s now exists on the MOE db. ' 'You can run local MOE commands (create_codebase, e.g.) to prepare. ' 'When you are ready to start using MOE for real:\n' '1) run moe change to create a change\n' '2) submit the change and note the equivalence\n' '3) start running moe auto\n') % project.config.name) return internal_revision = FLAGS.internal_revision if not internal_revision: raise app.UsageError( 'Must supply a revision using --internal_revision ' 'flag.') public_revision = FLAGS.public_revision context = InitCodebasesContext(project, internal_revision, public_revision) context.InitializeProject() moe_app.RUN.report.PrintSummary() finally: project.db.Disconnect()
def Run(self, unused_argv): project = db_client.MakeProjectContext() try: source_revision = FLAGS.source_revision source = FLAGS.source_repository if source not in base.REPOSITORIES: raise app.UsageError('source_repository should be one of %s' % str(base.REPOSITORIES)) if source == base.INTERNAL_STR: repository = project.internal_repository codebase_creator = project.internal_codebase_creator elif source == base.PUBLIC_STR: repository = project.public_repository codebase_creator = project.public_codebase_creator else: raise base.Error('Unexpected source: %s' % source) with moe_app.RUN.ui.BeginImmediateTask( 'head_revision', 'Determining Head Revision') as t: head_revision = repository.GetHeadRevision(source_revision) t.SetResult(head_revision) source_codebase = codebase_creator.Create(revision=head_revision) translated_codebase = translators.TranslateToProjectSpace( source_codebase, FLAGS.target_project_space, project.translators) moe_app.RUN.ui.Info('Codebase created at %s' % translated_codebase.Path()) finally: project.db.Disconnect()
def Run(self, argv): project = db_client.MakeProjectContext() try: revision = FLAGS.source_revision repository = FLAGS.repository if repository not in base.REPOSITORIES: raise app.UsageError('repository should be one of %s' % str(base.REPOSITORIES)) print 'Generating from and pushing into %s for MOE project %s' % ( repository, project.config.name) if repository == base.INTERNAL_STR: codebase_creator = project.internal_codebase_creator elif destination == base.PUBLIC_STR: codebase_creator = project.public_codebase_creator else: raise base.Error('Unexpected repository: %s' % destination) original_codebase = codebase_creator.Create(revision) codebase = codebase_utils.CreateModifiableCopy(original_codebase) for relative_filename in codebase.Walk(): filename = codebase.FilePath(relative_filename) if os.path.splitext(filename)[1] in EDITABLE_FILETYPES: file_util.Write(filename, file_util.Read(filename) + '\nMOE was here.\n') migration_strategy = config.MigrationStrategy( merge_strategy=base.ERROR, commit_strategy=base.LEAVE_PENDING, separate_revisions=False, copy_metadata=False) # TODO(dbentley): this creates the codebase just to make an editor. # We should make it possible to skip this step. destination_editor = codebase_creator.Create( revision).MakeEditor(migration_strategy) # TODO(dbentley): # We should be able to remove this additional_files_re, as it is # accounted for in the call to Codebase.Walk(). Unfortunately, we can't. # Why? Because a generated codebase is currently, incorrectly, getting # generated with the additional_files_re from the internal codebase, # even when it should be in the public project space. additional_files_re = ( project.config.public_repository_config.additional_files_re) pusher = push_codebase.CodebasePusher( codebase, destination_editor, files_to_ignore_re=additional_files_re) pusher.Push() moe_app.RUN.report.PrintSummary() finally: project.db.Disconnect()
def main(unused_argv): project = db_client.MakeProjectContext() try: context = ManageCodebasesContext( project, internal_revision=FLAGS.internal_revision) context.ManageCodebases() return context.return_code finally: project.db.Disconnect()
def main(unused_argv): project = db_client.MakeProjectContext() try: internal_codebase = project.internal_codebase_creator.Create( FLAGS.internal_revision > 0 and FLAGS.internal_revision or project.internal_repository.GetHeadRevision()) public_codebase = project.public_codebase_creator.Create( FLAGS.public_revision > 0 and FLAGS.public_revision or project.public_repository.GetHeadRevision()) diff_obj = base.AreCodebasesDifferent(internal_codebase, public_codebase, project.config.noisy_files_re, record_full_diffs=True) moe_app.RUN.ui.Info('\n===== Begin diff_codebases =====\n') moe_app.RUN.ui.Info(str(diff_obj)) finally: project.db.Disconnect()
def Run(self, argv): unused_project = db_client.MakeProjectContext() task = moe_app.RUN.ui.BeginIntermediateTask('check_config', 'Checking Config') with task: moe_app.RUN.ui.Info('Success!')
def main(unused_args): project = db_client.MakeProjectContext() try: # TODO(dbentley): this code should use functions in the logic module # to know what revision to apply against. # TODO(dbentley): we shouldn't have to make a client just to get the config # NB(dbentley): this also saves the project, so we call it all the time # to save the config. source_revision = FLAGS.source_revision destination_revision = FLAGS.destination_revision destination = FLAGS.destination if destination not in base.REPOSITORIES: raise app.UsageError('destination should be one of %s' % str(base.REPOSITORIES)) print 'Pushing codebase for MOE project %s into %s' % ( project.config.name, destination) if destination == base.INTERNAL_STR: source_codebase_creator = project.public_codebase_creator destination_codebase_creator = project.internal_codebase_creator elif destination == base.PUBLIC_STR: source_codebase_creator = project.internal_codebase_creator destination_codebase_creator = project.public_codebase_creator else: raise base.Error('Unexpected destination: %s' % destination) if FLAGS.codebase: source_codebase = codebase_utils.Codebase(FLAGS.codebase) else: source_codebase = source_codebase_creator.Create(source_revision) migration_strategy = config.MigrationStrategy( merge_strategy=base.ERROR, commit_strategy=base.LEAVE_PENDING, separate_revisions=False, copy_metadata=False) # TODO(dbentley): this creates the codebase just to make an editor. # We should make it possible to skip this step. destination_editor = destination_codebase_creator.Create( destination_revision).MakeEditor(migration_strategy) # TODO(dbentley): # We should be able to remove this additional_files_re, as it is # accounted for in the call to Codebase.Walk(). Unfortunately, we can't. # Why? Because a generated codebase is currently, incorrectly, getting # generated with the additional_files_re from the internal codebase, # even when it should be in the public project space. additional_files_re = ( project.config.public_repository_config.additional_files_re) pusher = CodebasePusher(source_codebase, destination_editor, report=None, files_to_ignore_re=additional_files_re) pusher.Push() moe_app.RUN.report.PrintSummary() finally: project.db.Disconnect()
def assertSucceeds(self, create_project=False): project = db_client.MakeProjectContext(create_project=create_project) self.assertEqual(type(project), moe_project.MoeProjectContext)