Mercurial > evolve
changeset 6330:7650b38961a2
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.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sun, 20 Nov 2022 17:16:47 +0400 |
parents | a456706491c0 |
children | 9c243e98d0be |
files | hgext3rd/evolve/cmdrewrite.py tests/test-prune.t |
diffstat | 2 files changed, 12 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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 ----------------------------