diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py index 0bc71f45d3623b231cc3975b48feccce79d1231e_bWVyY3VyaWFsL2Rpc3BhdGNoLnB5..b3376fba4ab91c8fd6c02c3424d785b466f50836_bWVyY3VyaWFsL2Rpc3BhdGNoLnB5 100644 --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -59,6 +59,13 @@ # probably be investigated and tweaked. return [s for s in symbols if sim(s) > 0.6] +def _reportsimilar(write, similar): + if len(similar) == 1: + write(_("(did you mean %s?)\n") % similar[0]) + elif similar: + ss = ", ".join(sorted(similar)) + write(_("(did you mean one of %s?)\n") % ss) + def _formatparse(write, inst): similar = [] if isinstance(inst, error.UnknownIdentifier): @@ -71,12 +78,7 @@ write(_("unexpected leading whitespace\n")) else: write(_("hg: parse error: %s\n") % inst.args[0]) - if similar: - if len(similar) == 1: - write(_("(did you mean %r?)\n") % similar[0]) - else: - ss = ", ".join(sorted(similar)) - write(_("(did you mean one of %s?)\n") % ss) + _reportsimilar(write, similar) def dispatch(req): "run the command specified in req.args" @@ -262,8 +264,7 @@ if len(inst.args) == 2: sim = _getsimilar(inst.args[1], inst.args[0]) if sim: - ui.warn(_('(did you mean one of %s?)\n') % - ', '.join(sorted(sim))) + _reportsimilar(ui.warn, sim) suggested = True if not suggested: commands.help_(ui, 'shortlist') diff --git a/tests/test-alias.t b/tests/test-alias.t index 0bc71f45d3623b231cc3975b48feccce79d1231e_dGVzdHMvdGVzdC1hbGlhcy50..b3376fba4ab91c8fd6c02c3424d785b466f50836_dGVzdHMvdGVzdC1hbGlhcy50 100644 --- a/tests/test-alias.t +++ b/tests/test-alias.t @@ -360,7 +360,7 @@ sub $ hg --cwd .. subalias > /dev/null hg: unknown command 'subalias' - (did you mean one of idalias?) + (did you mean idalias?) [255] $ hg -R .. subalias > /dev/null hg: unknown command 'subalias' @@ -364,7 +364,7 @@ [255] $ hg -R .. subalias > /dev/null hg: unknown command 'subalias' - (did you mean one of idalias?) + (did you mean idalias?) [255] @@ -372,7 +372,7 @@ $ hg mainalias > /dev/null hg: unknown command 'mainalias' - (did you mean one of idalias?) + (did you mean idalias?) [255] $ hg -R .. mainalias main diff --git a/tests/test-help.t b/tests/test-help.t index 0bc71f45d3623b231cc3975b48feccce79d1231e_dGVzdHMvdGVzdC1oZWxwLnQ=..b3376fba4ab91c8fd6c02c3424d785b466f50836_dGVzdHMvdGVzdC1oZWxwLnQ= 100644 --- a/tests/test-help.t +++ b/tests/test-help.t @@ -645,8 +645,8 @@ $ hg .log hg: unknown command '.log' - (did you mean one of log?) + (did you mean log?) [255] $ hg log. hg: unknown command 'log.' @@ -649,8 +649,8 @@ [255] $ hg log. hg: unknown command 'log.' - (did you mean one of log?) + (did you mean log?) [255] $ hg pu.lh hg: unknown command 'pu.lh' diff --git a/tests/test-revset.t b/tests/test-revset.t index 0bc71f45d3623b231cc3975b48feccce79d1231e_dGVzdHMvdGVzdC1yZXZzZXQudA==..b3376fba4ab91c8fd6c02c3424d785b466f50836_dGVzdHMvdGVzdC1yZXZzZXQudA== 100644 --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -1482,7 +1482,7 @@ Bogus function gets suggestions $ log 'add()' hg: parse error: unknown identifier: add - (did you mean 'adds'?) + (did you mean adds?) [255] $ log 'added()' hg: parse error: unknown identifier: added @@ -1486,7 +1486,7 @@ [255] $ log 'added()' hg: parse error: unknown identifier: added - (did you mean 'adds'?) + (did you mean adds?) [255] $ log 'remo()' hg: parse error: unknown identifier: remo @@ -1499,7 +1499,7 @@ Bogus function with a similar internal name doesn't suggest the internal name $ log 'matches()' hg: parse error: unknown identifier: matches - (did you mean 'matching'?) + (did you mean matching?) [255] Undocumented functions aren't suggested as similar either