From be60f23b63ec83fe53d061c21433fef05f3050b3 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Mon, 9 Dec 2024 19:18:10 +0100 Subject: [PATCH] repopick: Use add_mutually_exclusive_group() where possible Change-Id: I7e38e2371d075afd53200d60703eb4466fff07e3 --- build/tools/repopick.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/build/tools/repopick.py b/build/tools/repopick.py index 43cc2845be..f255ebbe25 100755 --- a/build/tools/repopick.py +++ b/build/tools/repopick.py @@ -257,10 +257,11 @@ def main(): action="store_true", help='shortcut to "--start-branch auto --abandon-first --ignore-missing"', ) - parser.add_argument( + group = parser.add_mutually_exclusive_group() + group.add_argument( "-q", "--quiet", action="store_true", help="print as little as possible" ) - parser.add_argument( + group.add_argument( "-v", "--verbose", action="store_true", @@ -278,13 +279,14 @@ def main(): parser.add_argument( "-P", "--path", metavar="", help="use the specified path for the change" ) - parser.add_argument( + group = parser.add_mutually_exclusive_group() + group.add_argument( "-t", "--topic", metavar="", help="pick all commits from a specified topic" ) - parser.add_argument( + group.add_argument( "-H", "--hashtag", metavar="", help="pick all commits from a specified hashtag" ) - parser.add_argument( + group.add_argument( "-Q", "--query", metavar="", help="pick all commits using the specified query" ) parser.add_argument( @@ -327,13 +329,6 @@ def main(): args.ignore_missing = True if not args.start_branch: args.start_branch = ["auto"] - if args.quiet and args.verbose: - parser.error("--quiet and --verbose cannot be specified together") - - if (1 << bool(args.change_number) << bool(args.topic) << bool(args.hashtag) << bool(args.query)) != 2: - parser.error( - "One (and only one) of change_number, topic, hashtag and query are allowed" - ) # Change current directory to the top of the tree if "ANDROID_BUILD_TOP" in os.environ: