Mercurial > evolve
changeset 6318:3e488afe62f5
topic: use compat.InputError for conflicting CLI flags
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Thu, 07 Apr 2022 20:02:45 +0300 |
parents | 53d63b608230 |
children | 8c664ed9c103 |
files | hgext3rd/topic/__init__.py hgext3rd/topic/compat.py tests/test-topic.t |
diffstat | 3 files changed, 16 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Fri Oct 07 20:32:14 2022 -0400 +++ b/hgext3rd/topic/__init__.py Thu Apr 07 20:02:45 2022 +0300 @@ -192,6 +192,7 @@ from . import ( common, + compat, constants, destination, discovery, @@ -886,13 +887,13 @@ age = opts.get('age') if current and topic: - raise error.Abort(_(b"cannot use --current when setting a topic")) + raise compat.InputError(_(b"cannot use --current when setting a topic")) if current and clear: - raise error.Abort(_(b"cannot use --current and --clear")) + raise compat.InputError(_(b"cannot use --current and --clear")) if clear and topic: - raise error.Abort(_(b"cannot use --clear when setting a topic")) + raise compat.InputError(_(b"cannot use --clear when setting a topic")) if age and topic: - raise error.Abort(_(b"cannot use --age while setting a topic")) + raise compat.InputError(_(b"cannot use --age while setting a topic")) touchedrevs = set() if rev:
--- a/hgext3rd/topic/compat.py Fri Oct 07 20:32:14 2022 -0400 +++ b/hgext3rd/topic/compat.py Thu Apr 07 20:02:45 2022 +0300 @@ -9,6 +9,7 @@ from mercurial import ( cmdutil, + error, extensions, pycompat, util, @@ -49,3 +50,9 @@ return orig(repo, node, branch, bheads=bheads, opts=opts) return overridefn(_orig, repo, node, branch, bheads=bheads, tip=None, opts=opts) extensions.wrapfunction(cmdutil, 'commitstatus', _override) + +if util.safehasattr(error, 'InputError'): + InputError = error.InputError +else: + # hg <= 5.6 (8d72e29ad1e0) + InputError = error.Abort
--- a/tests/test-topic.t Fri Oct 07 20:32:14 2022 -0400 +++ b/tests/test-topic.t Thu Apr 07 20:02:45 2022 +0300 @@ -254,13 +254,13 @@ [1] $ hg topics --current somerandomtopic abort: cannot use --current when setting a topic - [255] + [10] $ hg topics --current --clear abort: cannot use --current and --clear - [255] + [10] $ hg topics --clear somerandomtopic abort: cannot use --clear when setting a topic - [255] + [10] Trying some invalid topicnames @@ -1154,7 +1154,7 @@ $ hg topics --age random abort: cannot use --age while setting a topic - [255] + [10] $ cd .. Test that topics doesn't confuse branchheads checking logic