# HG changeset patch # User Anton Shestakov # Date 1668950207 -14400 # Node ID 7650b38961a28a357cac2f6e379d9336a7d511b5 # Parent a456706491c0fbf3605561f13b68aaebfda8b74f prune: check user-supplied CLI flags in a modern way Calling the function twice because --biject is an alias to --pair. Technically they don't conflict with each other, only with --fold and --split. diff -r a456706491c0 -r 7650b38961a2 hgext3rd/evolve/cmdrewrite.py --- a/hgext3rd/evolve/cmdrewrite.py Tue Nov 15 16:52:16 2022 +0400 +++ b/hgext3rd/evolve/cmdrewrite.py Sun Nov 20 17:16:47 2022 +0400 @@ -920,10 +920,8 @@ fold = opts.get('fold') split = opts.get('split') - options = [o for o in (r'pair', r'fold', r'split') if opts.get(o)] - if 1 < len(options): - _opts = pycompat.sysbytes(r', '.join(options)) - raise error.Abort(_(b"can only specify one of %s") % _opts) + compat.check_at_most_one_arg(opts, 'pair', 'fold', 'split') + compat.check_at_most_one_arg(opts, 'biject', 'fold', 'split') if bookmarks: reachablefrombookmark = rewriteutil.reachablefrombookmark diff -r a456706491c0 -r 7650b38961a2 tests/test-prune.t --- a/tests/test-prune.t Tue Nov 15 16:52:16 2022 +0400 +++ b/tests/test-prune.t Sun Nov 20 17:16:47 2022 +0400 @@ -36,20 +36,20 @@ --------------------------------------- $ hg prune --fold --pair - abort: can only specify one of pair, fold - [255] + abort: cannot specify both --pair and --fold + [10] $ hg prune --fold --biject - abort: no revisions specified to prune - [255] + abort: cannot specify both --biject and --fold + [10] $ hg prune --split --fold - abort: can only specify one of fold, split - [255] + abort: cannot specify both --fold and --split + [10] $ hg prune --split --fold --pair - abort: can only specify one of pair, fold, split - [255] + abort: cannot specify both --pair and --fold + [10] $ hg prune --split --fold --biject - abort: can only specify one of fold, split - [255] + abort: cannot specify both --fold and --split + [10] Check simple case ----------------------------