diff --git a/revup/topic_stack.py b/revup/topic_stack.py index d718eb0..5945697 100644 --- a/revup/topic_stack.py +++ b/revup/topic_stack.py @@ -513,13 +513,43 @@ async def populate_reviews( if relative_topic: topic.relative_topic = self.topics[relative_topic] + + if labels is not None: + topic.tags[TAG_LABEL].update([label.lower() for label in labels.split(",")]) + + if user_aliases is not None: + for mapping in user_aliases.split(","): + # Map usernames from alias -> user_target + alias, _, user_target = mapping.partition(":") + for tag in [TAG_REVIEWER, TAG_ASSIGNEE]: + if alias in topic.tags[tag]: + topic.tags[tag].remove(alias) + topic.tags[tag].add(user_target) + + if auto_add_users in ("r2a", "both"): + topic.tags[TAG_ASSIGNEE].update(topic.tags[TAG_REVIEWER]) + if auto_add_users in ("a2r", "both"): + topic.tags[TAG_REVIEWER].update(topic.tags[TAG_ASSIGNEE]) + + seen_topics[name] = topic + + if limit_topics: + for name in limit_topics: + if name not in self.topics: + logging.warning(f"Couldn't find any topic named {name}") + + await self.populate_relative_reviews(uploader) + + async def populate_relative_reviews(self, uploader: str) -> None: + for name, topic in list(self.topics.items()): + if topic.relative_topic: if len(topic.tags[TAG_BRANCH]) == 0: topic.tags[TAG_BRANCH].update(topic.relative_topic.tags[TAG_BRANCH]) elif not topic.tags[TAG_BRANCH].issubset(topic.relative_topic.tags[TAG_BRANCH]): raise RevupUsageException( f"Topic {name} has branches" f" {topic.tags[TAG_BRANCH] - topic.relative_topic.tags[TAG_BRANCH]} not in" - f" relative topic {relative_topic}" + f" relative topic {topic.relative_topic.name}" ) if len(topic.tags[TAG_RELATIVE_BRANCH]) == 0: @@ -531,8 +561,8 @@ async def populate_reviews( != topic.relative_topic.tags[TAG_RELATIVE_BRANCH] ): raise RevupUsageException( - f"Topic {name} and relative topic {relative_topic} have differing relative " - f"branches, {topic.tags[TAG_RELATIVE_BRANCH]} vs " + f"Topic {name} and relative topic {topic.relative_topic.name} have " + f"differing relative branches, {topic.tags[TAG_RELATIVE_BRANCH]} vs " f"{topic.relative_topic.tags[TAG_RELATIVE_BRANCH]}" ) else: @@ -571,7 +601,7 @@ async def populate_reviews( ): raise RevupUsageException( f"Topic {name} has uploader '{topic.tags[TAG_UPLOADER]}' while relative topic" - f" {relative_topic} has uploader" + f" {topic.relative_topic.name} has uploader" f" {topic.relative_topic.tags[TAG_UPLOADER] or '{}'}" ) topic_uploader = min(topic.tags[TAG_UPLOADER]) if topic.tags[TAG_UPLOADER] else uploader @@ -583,18 +613,6 @@ async def populate_reviews( if extra_label: topic.tags[TAG_LABEL].add(extra_label.lower()) - if labels is not None: - topic.tags[TAG_LABEL].update([label.lower() for label in labels.split(",")]) - - if user_aliases is not None: - for mapping in user_aliases.split(","): - # Map usernames from alias -> user_target - alias, _, user_target = mapping.partition(":") - for tag in [TAG_REVIEWER, TAG_ASSIGNEE]: - if alias in topic.tags[tag]: - topic.tags[tag].remove(alias) - topic.tags[tag].add(user_target) - for branch in topic.tags[TAG_BRANCH]: review = Review(topic) # Track whether we need to query for the relative pr @@ -628,18 +646,6 @@ async def populate_reviews( # Don't add draft as a label since its instead used to mark a pr as a draft topic.tags[TAG_LABEL].discard("draft") - if auto_add_users in ("r2a", "both"): - topic.tags[TAG_ASSIGNEE].update(topic.tags[TAG_REVIEWER]) - if auto_add_users in ("a2r", "both"): - topic.tags[TAG_REVIEWER].update(topic.tags[TAG_ASSIGNEE]) - - seen_topics[name] = topic - - if limit_topics: - for name in limit_topics: - if name not in self.topics: - logging.warning(f"Couldn't find any topic named {name}") - async def mark_rebases(self, skip_rebase: bool) -> None: """ Scan all topics and compare patch-ids to remote patch-ids. Appropriately mark any