def pull(self, rietveld_info): """Updates Rietveld info with metadata from code review server. If successful, sets state to PRINT_INFO. Args: rietveld_info: RietveldInfo object for the current branch. """ success, rietveld_info = utils.update_rietveld_metadata_from_issue( current_branch=self.__branch, rietveld_info=rietveld_info) if success: print 'Metadata update from code server succeeded.' else: print 'Metadata update from code server failed.' self.state = self.PRINT_INFO self.advance(rietveld_info)
def update_from_metadata(self): """Updates Rietveld info with metadata from code review server. If successful, sets state to ENTER_DETACHED_STATE, otherwise sets to FINISHED. In either case, advances the state machine. """ success, rietveld_info = utils.update_rietveld_metadata_from_issue( rietveld_info=self.__rietveld_info) if success: # TODO(dhermes): This assumes rietveld_info.review_info is not None. self.__subject = rietveld_info.review_info.subject self.__description = rietveld_info.review_info.description self.state = self.ENTER_DETACHED_STATE else: # TODO(dhermes): Make this a constant. print 'Metadata update from code server failed.' self.state = self.FINISHED self.advance()
def update_metadata(self, issue=None, initial_subject=None, initial_description=None): """Updates the Rietveld metadata associated with the current branch. If successful, sets state to FINISHED and advances the state machine. NOTE: This assumes initial_subject and initial_description are either both null or both strings and leaves it up to the caller to check. Args: issue: Integer; containing an ID of a code review issue. initial_subject: String containing the commit subject. Used when creating a new issue via upload.py. Defaults to None. initial_description: String containing the commit description. Used when creating a new issue via upload.py. Defaults to None. """ review_info = utils.ReviewInfo(last_commit=self.__current_head) # TODO(dhermes): Throw exception if one of these is None while the # the other isn't? if issue is not None and initial_subject is not None: review_info.issue = issue review_info.subject = initial_subject if initial_description != initial_subject: review_info.description = initial_description else: review_info.description = '' self.__rietveld_info.review_info = review_info self.__rietveld_info.save() success, _ = utils.update_rietveld_metadata_from_issue( rietveld_info=self.__rietveld_info) if success: print 'Metadata update from code server succeeded.' else: print 'Metadata update from code server failed.' print 'To try again run:' print '\tgit rv getinfo --pull-metadata' self.state = self.FINISHED self.advance()