Skip to content

Commit

Permalink
upload: Allow arbitrary topic order
Browse files Browse the repository at this point in the history
Fixes: #156
  • Loading branch information
jerry-skydio committed Mar 12, 2024
1 parent 0a455aa commit 5732850
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions revup/topic_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@ async def populate_reviews(
Populate reviews for already-parsed topics. Verify base branch and relative topic info to
ensure it is valid.
"""
seen_topics: Dict[str, Topic] = {}
last_topic = None
# Copy topics before iterating so it's safe to delete from the original dict
for name, topic in list(self.topics.items()):
if limit_topics:
if name not in limit_topics:
Expand Down Expand Up @@ -500,8 +501,8 @@ async def populate_reviews(
raise RevupUsageException(f"Can't specify more than one uploader for topic {name}!")

relative_topic = ""
if force_relative_chain and seen_topics:
relative_topic = list(seen_topics)[-1]
if force_relative_chain and last_topic is not None:
relative_topic = last_topic
elif len(topic.tags[TAG_RELATIVE]) > 1:
raise RevupUsageException(
"Can't specify more than 1 relative topic per topic! Got"
Expand All @@ -513,21 +514,12 @@ async def populate_reviews(
# all the base branches for the relative topic. However it can't specify
# any base branches the relative topic doesn't have.
relative_topic = min(topic.tags[TAG_RELATIVE])
if relative_topic not in seen_topics:
if relative_topic in self.topics:
# Relative topics can have interleaved commits, however the first commit of
# the relative topic must come before the first commit of this topic. This
# prevents cycles of relatives.
raise RevupUsageException(
f"Topic '{name}' is relative to '{relative_topic}' but doesn't appear"
" after it"
)
else:
logging.warning(
f"Relative topic '{relative_topic}' not found in stack, assuming it was"
" merged"
)
relative_topic = ""
if relative_topic not in self.topics:
logging.warning(
f"Relative topic '{relative_topic}' not found in stack, assuming it was"
" merged"
)
relative_topic = ""

if self.repo_info and self.fork_info and self.fork_info.owner != self.repo_info.owner:
if len(topic.tags[TAG_RELATIVE_BRANCH]) > 1:
Expand All @@ -545,7 +537,8 @@ async def populate_reviews(
if relative_topic:
topic.relative_topic = self.topics[relative_topic]

seen_topics[name] = topic
# Track the last actually used topic for the relative-chain feature
last_topic = name

for name, topic in self.topological_topics():
if topic.relative_topic:
Expand Down

0 comments on commit 5732850

Please sign in to comment.