From cfe90675a04290d966778290cd5c681b7adeff83 Mon Sep 17 00:00:00 2001 From: Jerry Zhang Date: Fri, 24 Mar 2023 16:28:44 -0700 Subject: [PATCH] Allow specifying topics to upload As a list of multiple arguments to upload. If topics are specified, only those topics will be uploaded. Those topics will also ignore no-self-authored-only. Any topics that aren't found will warn. Topic: onlytopics Reviewers: brian-k --- docs/upload.md | 7 ++++++- revup/revup.py | 1 + revup/topic_stack.py | 14 +++++++++++++- revup/upload.py | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/upload.md b/docs/upload.md index f71a186..e0f796d 100644 --- a/docs/upload.md +++ b/docs/upload.md @@ -9,7 +9,7 @@ revup upload - Modify or create code reviews. `[--rebase] [--relative-chain] [--skip-confirm] [--dry-run]` `[--status] [--no-cherry-pick] [--no-update-pr-body] [--review-graph]` `[--trim-tags] [--create-local-branches] [--patchsets] [--auto-add-users=]` -`[--labels=]` +`[--labels=] ` # DESCRIPTION @@ -96,6 +96,11 @@ that conflicts will not happen. # OPTIONS +**``** +: Optionally specify any number of topic names to upload. If none are +specified, all topics are uploaded. If topics are specified they will +be uploaded regardless of author. + **--help, -h** : Show this help page. diff --git a/revup/revup.py b/revup/revup.py index 1886b66..90f6305 100755 --- a/revup/revup.py +++ b/revup/revup.py @@ -228,6 +228,7 @@ async def main() -> int: p.add_argument("--base-branch", "-b") p.add_argument("--relative-branch", "-e") + upload_parser.add_argument("topics", nargs="*") upload_parser.add_argument("--rebase", "-r", action="store_true") upload_parser.add_argument("--skip-confirm", "-s", action="store_true") upload_parser.add_argument("--dry-run", "-d", action="store_true") diff --git a/revup/topic_stack.py b/revup/topic_stack.py index f504e6c..051d930 100644 --- a/revup/topic_stack.py +++ b/revup/topic_stack.py @@ -416,6 +416,7 @@ async def populate_reviews( user_aliases: str = "", auto_add_users: str = "", self_authored_only: bool = False, + limit_topics: Optional[List[str]] = None, ) -> None: """ Populate reviews for already-parsed topics. Verify base branch and relative topic info to @@ -423,7 +424,13 @@ async def populate_reviews( """ seen_topics: Dict[str, Topic] = {} for name, topic in list(self.topics.items()): - relative_topic = "" + if limit_topics: + if name not in limit_topics: + # If an explicit list was specified, don't upload other topics + continue + # Disable the self authored check if this topic was explicitly given + self_authored_only = False + limit_topics.remove(name) if self_authored_only: # Don't upload if this topic doesn't have commits authored by the current user @@ -443,6 +450,7 @@ async def populate_reviews( if len(topic.tags[TAG_UPLOADER]) > 1: 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] elif len(topic.tags[TAG_RELATIVE]) > 1: @@ -609,6 +617,10 @@ async def populate_reviews( seen_topics[name] = topic + if limit_topics: + for name in limit_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 diff --git a/revup/upload.py b/revup/upload.py index 321570f..f90d989 100644 --- a/revup/upload.py +++ b/revup/upload.py @@ -39,6 +39,7 @@ async def main( user_aliases=args.user_aliases, auto_add_users=args.auto_add_users, self_authored_only=args.self_authored_only, + limit_topics=args.topics, ) if not args.dry_run: