def ManageCodebases(self): """Manage codebases. This is the entry point to the one-button MOE.""" try: if self._internal_revision == -1: internal_revision = None else: internal_revision = str(self._internal_revision) task = moe_app.RUN.ui.BeginImmediateTask( 'get_internal_head', 'Determining current internal revision ' '(override with --internal_revision)') with task: current_internal_revision = ( self.project.internal_repository.GetHeadRevision( internal_revision)) task.SetResult(current_internal_revision) task = moe_app.RUN.ui.BeginImmediateTask( 'get_public_head', 'Determining current public revision') with task: current_public_revision = ( self.project.public_repository.GetHeadRevision()) task.SetResult(current_public_revision) current = base.Correspondence(current_internal_revision, current_public_revision) book = self._PerformBookkeeping(current) book.Describe() actionlist = self._ChooseActions(book) state = actions.ActionState( self.project.internal_codebase_creator, self.project.public_codebase_creator, # TODO(dbentley): get rid of report and temp_dir self._report, self.project.db, self._temp_dir, actionlist) while actionlist: (current_action, state.actions) = (actionlist[0], actionlist[1:]) result = current_action.Perform(**state.Dict()) state.MergeUpdate(result) actionlist = state.actions self._report.PrintSummary() self.return_code = self._report.GetReturnCode() finally: self.project.db.Disconnect()
def Equivalence(internal_revision, public_revision): """An Equivalence is a marker that two codebases are equivalent. MOE works to keep codebases equivalent, and so many tools want to start from the last equivalence. Equivalent codebases are likely to have differences between files. E.g. if only noisy files differ, the codebases will be different / but equivalent. An Equivalence is a special case of a Correspondence. Args: internal_revision: str, the internal revision that is equivalent. public_revision: str, the public revision that is equivalent. Returns: An Equivalence. """ return base.Correspondence(internal_revision, public_revision)
def VerifyEquivalences(db, internal_repository, public_repository): """Verify equivalences, for each marking it verified or invalid. Args: db: MoeDbClient internal_repository: SourceControlRepository public_repository: SourceControlRepository """ equivalences = db.FindUnverifiedEquivalences() for e in equivalences: verified_internal_revision = internal_repository.GetHeadRevision( e.internal_revision) verified_public_revision = public_repository.GetHeadRevision( e.public_revision) if verified_internal_revision and verified_public_revision: new_equivalence = base.Correspondence(verified_internal_revision, verified_public_revision) db.NoteEquivalence(new_equivalence) if (verified_internal_revision != e.internal_revision or verified_public_revision != e.public_revision): if verified_internal_revision and verified_public_revision: moe_app.RUN.ui.Info( ('Found invalid Equivalence. (Replaced with:)\n' 'Internal Revision: %s (%s)\n' 'Public Revision: %s (%s)') % (e.internal_revision, verified_internal_revision, e.public_revision, verified_public_revision)) else: moe_app.RUN.ui.Info( ('Found invalid Equivalence.\n' 'Internal Revision: %s\n' 'Public Revision: %s') % (e.internal_revision, e.public_revision)) db.NoteEquivalence(e, verification_status=base.VERIFICATION_INVALID)
def FindUnverifiedEquivalences(self): return [ base.Correspondence('1001', '1'), base.Correspondence('1003', '3') ]
def EquivalencesFromDicts(equivalence_dicts): return [ base.Correspondence(e['internal_revision']['rev_id'], e['public_revision']['rev_id']) for e in equivalence_dicts ]