Skip to content

Commit

Permalink
upload: Split populate reviews into 2 phases
Browse files Browse the repository at this point in the history
This sets the function up to allow arbitrary topic
order in the future.

The first pass handles finding the relative topic, but
does not assume it's already populated. The second pass
needs to assume that the relative is already populated
since it uses it, so it needs to be done in topological
order.
  • Loading branch information
jerry-skydio committed Mar 12, 2024
1 parent df29593 commit edb2370
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions revup/topic_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,18 @@ async def populate_reviews(

if relative_topic:
topic.relative_topic = self.topics[relative_topic]

seen_topics[name] = topic

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:
Expand All @@ -531,8 +536,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:
Expand Down Expand Up @@ -571,7 +576,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
Expand Down Expand Up @@ -633,8 +638,6 @@ async def populate_reviews(
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:
Expand Down

0 comments on commit edb2370

Please sign in to comment.