def fetch_change_list(change_list): """Convert a list of changes or change ranges into a list of ChangeInfo The input list accepts the following string elements: - a change number: POSITIVE - a range of change numbers: POSITIVE..POSITIVE - a change-id: I[0-9a-f]{8,40} :param change_list: the list of changes :type change_list: list[str] :rtype: list[ChangeInfo] """ change_ids = [] for change in change_list: if CHANGE_ID.match(change) or LEGACY_CHANGE_ID.match(change): change_ids.append(change) elif LEGACY_CHANGE_ID_RANGE.match(change): change_ids.extend([str(i) for i in expand_change_range(change)]) else: warn('invalid Change-Id: %s' % change) change_infos = [] for change_id in change_ids: try: change_infos.append(Gerrit.get_change(change_id)) except NoSuchChangeError: pass return change_infos
def run(self, arguments, *args, **kwargs): change_id, score, message, label = self.parse_command_line(arguments) try: change = Gerrit.get_change(change_id) if message is None: initial_content = [ '', ('# Please enter the comment message for your review. ' 'Lines starting'), "# with '#' will be ignored.", '#' ] initial_content.extend( ['# %s' % line for line in change.raw_str().splitlines()]) initial_content.append('#') message = raw_input_editor(os.linesep.join(initial_content)) message = strip_comments(message) if score is None: score = ask('Please enter your review score', Gerrit.SCORES) review = Gerrit.set_review(score, message, change.uuid, label) except NoSuchChangeError as why: self.log.debug(str(why)) fail('invalid change') except PyCRError as why: fail('cannot post review', why) print Formatter.format(self.tokenize(change, review))
def run(self, arguments, *args, **kwargs): change_id = self.parse_command_line(arguments) try: change = Gerrit.get_change(change_id) if not Gerrit.submit(change.uuid): fail('change could not be merged') except NoSuchChangeError as why: self.log.debug(str(why)) fail('invalid change') except PyCRError as why: fail('cannot submit', why) print Formatter.format(self.tokenize(change))