Mercurial > hg > mercurial-source
changeset 33549:fbe9c4dcc8a0
bisect: improve option validation message
author | Brandon McCaig <bamccaig@gmail.com> |
---|---|
date | Fri, 09 Jun 2017 20:12:39 -0400 |
parents | 041d976b662a |
children | e5dd44f78ac6 |
files | mercurial/commands.py tests/test-bisect.t |
diffstat | 2 files changed, 63 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -9,6 +9,7 @@ import difflib import errno +import itertools import os import re import sys @@ -768,9 +769,22 @@ bad = True else: reset = True - elif extra or good + bad + skip + reset + extend + bool(command) > 1: + elif extra: raise error.Abort(_('incompatible arguments')) + incompatibles = { + '--bad': bad, + '--command': bool(command), + '--extend': extend, + '--good': good, + '--reset': reset, + '--skip': skip, + } + + for left, right in itertools.combinations(sorted(incompatibles), 2): + if incompatibles[left] and incompatibles[right]: + raise error.Abort(_('%s and %s are incompatible') % (left, right)) + if reset: hbisect.resetstate(repo) return
--- a/tests/test-bisect.t +++ b/tests/test-bisect.t @@ -611,3 +611,51 @@ date: Thu Jan 01 00:00:26 1970 +0000 summary: msg 26 +Test the validation message when exclusive options are used: + + $ hg bisect -r + $ hg bisect -b -c false + abort: --bad and --command are incompatible + [255] + $ hg bisect -b -e + abort: --bad and --extend are incompatible + [255] + $ hg bisect -b -g + abort: --bad and --good are incompatible + [255] + $ hg bisect -b -r + abort: --bad and --reset are incompatible + [255] + $ hg bisect -b -s + abort: --bad and --skip are incompatible + [255] + $ hg bisect -c false -e + abort: --command and --extend are incompatible + [255] + $ hg bisect -c false -g + abort: --command and --good are incompatible + [255] + $ hg bisect -c false -r + abort: --command and --reset are incompatible + [255] + $ hg bisect -c false -s + abort: --command and --skip are incompatible + [255] + $ hg bisect -e -g + abort: --extend and --good are incompatible + [255] + $ hg bisect -e -r + abort: --extend and --reset are incompatible + [255] + $ hg bisect -e -s + abort: --extend and --skip are incompatible + [255] + $ hg bisect -g -r + abort: --good and --reset are incompatible + [255] + $ hg bisect -g -s + abort: --good and --skip are incompatible + [255] + $ hg bisect -r -s + abort: --reset and --skip are incompatible + [255]