Mercurial > hg-stable
changeset 26364:6e9c2aab9925
dispatch: don't stack trace on commands like `hg .log`
This used to stack trace because it raised a util.Abort which wasn't
handled in this block. We now handle it. Additionally, we error out
earlier instead of plodding on and showing the "log" entry of the
plain `hg help` output.
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Fri, 25 Sep 2015 11:16:20 -0400 |
parents | f29ee23bf361 |
children | 33af0c53aeff |
files | mercurial/commands.py mercurial/dispatch.py tests/test-help.t |
diffstat | 3 files changed, 23 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Fri Sep 25 12:38:20 2015 +0800 +++ b/mercurial/commands.py Fri Sep 25 11:16:20 2015 -0400 @@ -4020,7 +4020,11 @@ formatted, pruned = minirst.format(text, textwidth, keep=keep, section=section) - if section and not formatted: + + # We could have been given a weird ".foo" section without a name + # to look for, or we could have simply failed to found "foo.bar" + # because bar isn't a section of foo + if section and not (formatted and name): raise util.Abort(_("help section not found")) if 'verbose' in pruned:
--- a/mercurial/dispatch.py Fri Sep 25 12:38:20 2015 +0800 +++ b/mercurial/dispatch.py Fri Sep 25 11:16:20 2015 -0400 @@ -253,7 +253,7 @@ # check if the command is in a disabled extension # (but don't check for extensions themselves) commands.help_(ui, inst.args[0], unknowncmd=True) - except error.UnknownCommand: + except (error.UnknownCommand, util.Abort): suggested = False if len(inst.args) == 2: sim = _getsimilar(inst.args[1], inst.args[0])
--- a/tests/test-help.t Fri Sep 25 12:38:20 2015 +0800 +++ b/tests/test-help.t Fri Sep 25 11:16:20 2015 -0400 @@ -616,6 +616,23 @@ [255] +Make sure that we don't run afoul of the help system thinking that +this is a section and erroring out weirdly. + + $ hg .log + hg: unknown command '.log' + (did you mean one of log?) + [255] + + $ hg log. + hg: unknown command 'log.' + (did you mean one of log?) + [255] + $ hg pu.lh + hg: unknown command 'pu.lh' + (did you mean one of pull, push?) + [255] + $ cat > helpext.py <<EOF > import os > from mercurial import cmdutil, commands