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): changes, to_add, to_del = self.parse_command_line(arguments) assert changes, 'unexpected empty list' for idx, change in enumerate(changes): added = [] deleted = [] # Add reviewers for account_id in to_add: try: reviewers = Gerrit.add_reviewer(change.uuid, account_id) if reviewers: added.extend(reviewers) except PyCRError as why: warn( '{}: cannot assign reviewer {}'.format( change.change_id[:9], account_id), why) # Delete reviewers for account_id in to_del: try: review = Gerrit.delete_reviewer(change.uuid, account_id) if review: deleted.append(review.reviewer) except PyCRError as why: warn( '{}: cannot delete reviewer {}'.format( change.change_id[:9], account_id), why) print Formatter.format(self.tokenize(idx, change, added, deleted))
def run(self, arguments, *args, **kwargs): changes, to_add, to_del = self.parse_command_line(arguments) assert changes, 'unexpected empty list' for idx, change in enumerate(changes): added = [] deleted = [] # Add reviewers for account_id in to_add: try: reviewers = Gerrit.add_reviewer(change.uuid, account_id) if reviewers: added.extend(reviewers) except PyCRError as why: warn('{}: cannot assign reviewer {}'.format( change.change_id[:9], account_id), why) # Delete reviewers for account_id in to_del: try: review = Gerrit.delete_reviewer(change.uuid, account_id) if review: deleted.append(review.reviewer) except PyCRError as why: warn('{}: cannot delete reviewer {}'.format( change.change_id[:9], account_id), why) print Formatter.format(self.tokenize(idx, change, added, deleted))
def run(self, arguments, *args, **kwargs): """ The entry point for the SUBMIT command. Rebase revision. PARAMETERS arguments: a list of command-line arguments to parse """ change_id = Submit.parse_command_line(arguments) try: change = Gerrit.get_change(change_id) if not Gerrit.submit(change.uuid): fail('submit 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(Submit.tokenize(change))
def run(self, arguments, *args, **kwargs): account_id = self.parse_command_line(arguments) try: changes = Gerrit.get_starred_changes(account_id or 'self') except PyCRError as why: fail('cannot list account starred changes', why) with Pager(command=self.name): for idx, change in enumerate(changes): print Formatter.format(self.tokenize(idx, change))
def run(self, arguments, *args, **kwargs): change_id = self.parse_command_line(arguments) try: change = Gerrit.rebase(change_id) except NoSuchChangeError as why: self.log.debug(str(why)) fail('invalid change') except PyCRError as why: fail('cannot rebase', why) print Formatter.format(self.tokenize(change))
def run(self, arguments, *args, **kwargs): changes = self.parse_command_line(arguments) assert changes, 'unexpected empty list' with Pager(command=self.name): for idx, change in enumerate(changes): try: reviews = Gerrit.get_reviews(change.uuid) patch = Gerrit.get_patch(change.uuid) except PyCRError as why: warn('%s: cannot list reviewers' % change.change_id[:9], why) continue print Formatter.format( self.tokenize(idx, change, reviews, patch))
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))
def run(self, arguments, *args, **kwargs): owner, status, watched = self.parse_command_line(arguments) try: if watched: changes = Gerrit.list_watched_changes(status=status) else: changes = Gerrit.list_changes(status=status, owner=owner) except QueryError as why: # No result, not an error self.log.debug(str(why)) return except PyCRError as why: fail('cannot list changes', why) with Pager(command=self.name): for idx, change in enumerate(changes): print Formatter.format(self.tokenize(idx, change))
def __str__(self): return Formatter.format(self.tokenize())